Changeset 169
- Timestamp:
- 08/20/08 18:52:42 (3 months ago)
- Files:
-
- trunk/microfacts/controllers/thread.py (modified) (3 diffs)
- trunk/microfacts/public/behaviour/app/controllers/geochronopage_controller.js (added)
- trunk/microfacts/public/behaviour/lib/mapcontroller.js (modified) (2 diffs)
- trunk/microfacts/public/behaviour/lib/timelinecontroller.js (modified) (1 diff)
- trunk/microfacts/public/behaviour/load.js (modified) (1 diff)
- trunk/microfacts/templates/thread/layout.html (modified) (1 diff)
- trunk/microfacts/templates/thread/read_geochrono.html (copied) (copied from trunk/microfacts/templates/thread/read_timeline.html) (2 diffs)
- trunk/microfacts/templates/thread/update.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/microfacts/controllers/thread.py
r163 r169 69 69 html = fc.read_core(id) 70 70 c.factlet_info = genshi.XML(html) 71 self._set_json_payload() 71 72 return render('thread/read') 72 73 else: … … 92 93 abort(mode.response_code) 93 94 95 def read_geochrono(self, id): 96 c.has_inline_edit = False 97 try: 98 id = int(id) 99 except: 100 id = 0 101 mode = EntityGet('/thread/%s' % id).execute() 102 if mode.response_code == 200: 103 c.thread = mode.entity 104 if len(c.thread.factlets) > 0: 105 import microfacts.controllers.factlet 106 id = c.thread.factlets[0].id 107 fc = microfacts.controllers.factlet.FactletController() 108 html = fc.read_core(id) 109 c.factlet_info = genshi.XML(html) 110 self._set_json_payload() 111 return render('thread/read_geochrono') 112 else: 113 abort(mode.response_code) 114 94 115 def update(self, id): 95 116 c.has_inline_edit = True … … 103 124 c.thread = mode.entity 104 125 105 converter = microfacts.lib.json.FactletConverter() 106 factlets_as_dicts = converter.from_domain_objects(c.thread.factlets, id_only=False) 107 c.thread_factlets_json = simplejson.dumps(factlets_as_dicts) 108 109 thread_converter = microfacts.lib.json.ThreadConverter() 110 thread_as_dict = thread_converter.from_domain_object(c.thread) 111 c.thread_as_json = simplejson.dumps(thread_as_dict) 126 self._set_json_payload() 112 127 return render('thread/update') 113 128 else: 114 129 abort(mode.response_code) 115 130 131 def _set_json_payload(self): 132 converter = microfacts.lib.json.FactletConverter() 133 factlets_as_dicts = converter.from_domain_objects(c.thread.factlets, id_only=False) 134 c.thread_factlets_json = simplejson.dumps(factlets_as_dicts) 135 thread_converter = microfacts.lib.json.ThreadConverter() 136 thread_as_dict = thread_converter.from_domain_object(c.thread) 137 c.thread_as_json = simplejson.dumps(thread_as_dict) 138 trunk/microfacts/public/behaviour/lib/mapcontroller.js
r155 r169 6 6 initialize: function (element) { 7 7 this.element = element; 8 //if (! this.element.id) { 9 // console.error("Map element has no id attribute."); 10 // Now die. 11 //} 8 12 this.initMap(); 9 13 //this.addEvent('factletSelect', this.onFactletSelected.bind(this)); … … 145 149 this.selectedFeature.popup.destroy(); 146 150 this.selectedFeature.popup = null; 151 }, 152 153 onThreadStart: function() { 154 console.log("MapController saw threadStart event"); 155 console.log(arguments); 156 this.thread = arguments[0]; 157 this.factlets = arguments[1]; 158 console.log(this.thread); 159 console.log("Map factlets:"); 160 console.log(this.factlets); 161 var factletsData = []; 162 this.factlets.each(function (factlet) { 163 if (factlet.data.location) { 164 factletsData.push(factlet.data); 165 } 166 }); 167 console.log("Factlet data:"); 168 console.log(factletsData); 169 this.drawFactlets(factletsData); 147 170 } 148 171 }); trunk/microfacts/public/behaviour/lib/timelinecontroller.js
r154 r169 97 97 // onFeatureUnselect: function(feature) { 98 98 // this.fireEvent('factletUnselect', feature.data.factlet); 99 }, 100 101 onThreadStart: function() { 102 console.log("TimelineController saw threadStart event"); 103 console.log(arguments); 104 this.thread = arguments[0]; 105 this.factlets = arguments[1]; 106 console.log(this.thread); 107 console.log("Timeline factlets:"); 108 console.log(this.factlets); 109 var factletsData = []; 110 this.factlets.each(function (factlet) { 111 if (factlet.data.start) { 112 factletsData.push(factlet.data); 113 } 114 }); 115 console.log("Factlet data:"); 116 console.log(factletsData); 117 this.drawFactlets(factletsData); 99 118 } 119 100 120 }); 101 121 trunk/microfacts/public/behaviour/load.js
r160 r169 185 185 }); 186 186 187 loader.addModule({ 188 name: "geochronopagecontroller", 189 type: "js", 190 path: "app/controllers/geochronopage_controller.js?" + Math.random(), 191 requires: ['model', 'domainobject', 'view', 'controller', 'thread', 'factlet', 'mapcontroller', 'timelinecontroller'], 192 varName: "GeochronoPageController" 193 }); 194 trunk/microfacts/templates/thread/layout.html
r118 r169 38 38 ${select('aside')} 39 39 ${select('*[local-name()!="aside"]|text()')} 40 <script type="text/javascript" charset="utf-8"> 41 var payloadThread = ${c.thread_as_json}; 42 var payloadThreadFactlets = ${c.thread_factlets_json}; 43 </script> 44 40 45 </body> 41 46 </py:match> trunk/microfacts/templates/thread/read_geochrono.html
r107 r169 9 9 <xi:include href="layout.html" /> 10 10 11 <py:def function="pagecontrollername">geochronopagecontroller</py:def> 12 11 13 <head> 12 14 <title>View - ${c.thread.title}</title> … … 14 16 15 17 <body> 16 <aside id="thread-control-${c.thread.id}">17 <h2>Thread control:</h2>18 <p>To move between different Factlets in the Thread either use the19 controls below or click on the relevant Factlet in the thread list.</p>20 <form>21 <input type="button" value="« Previous" class="prev" />22 <input type="button" value="Next »" class="next" />23 </form>24 <p>25 ${h.link_to("Edit This Thread »", h.url_for(controller='thread',26 action='update'))}27 </p>28 </aside>29 18 30 <aside id="thread-timeline-control-${c.thread.id}"> 31 <h2>Timeline control:</h2> 32 <p>To scroll the timeline click and drag horizontally (in any band). To resize the timeline click and drag vertically.</p> 33 <p><strong>TODO: make these buttons functional (js only)</strong></p> 34 <form> 35 <input type="button" value="Show Timeline" class="show" /> 36 <input type="button" value="Hide Timeline" class="hide" /> 37 </form> 38 <p><strong>TODO: might want to move to having an explicit thread timeline view in which timeline is vertical and replaces the factlet-info box on the right ...</strong></p> 39 </aside> 40 41 <div id="thread-${c.thread.id}" class="thread"> 42 43 <h2 id="thread-title"> 44 Thread: ${c.thread.title} 45 (${h.link_to("Edit", h.url_for(controller='thread', action='update'))}) 46 </h2> 47 <div id="thread-timeline" style="height: 150px; border: 1px solid #aaa; margin-bottom: 20px;"></div> 48 49 <py:choose> 50 <div py:when="len(c.thread.factlets) > 0" class="thread-factlets"> 51 52 <py:for each="factlet in c.thread.factlets"> 53 <div id="factlet-${factlet['id']}" class="factlet"> 54 <h3 class="factlet-title">${factlet['title']}</h3> 55 <!--! p class="factlet-description">${factlet['description'] and " ".join(factlet['description'].split(' ')[:35]) + "..." or "no description"}</p--> 56 </div> 57 </py:for> 58 59 </div><!--! /thread-factlets --> 60 <p py:otherwise=""> 61 There are no factlets in this thread. Would you like to 62 ${h.link_to("add a new one", h.url_for(controller='factlet', action='new'))}? 63 </p> 64 </py:choose> 65 </div><!--! /thread --> 66 67 <div id="factlet-info"> 68 ${c.factlet_info} 69 </div> 19 <div id="map" style="height:200px; width:300px"></div> 20 <div id="timeline" style="height:200px; width: 100%"></div> 70 21 71 22 </body> trunk/microfacts/templates/thread/update.html
r163 r169 15 15 </head> 16 16 17 <script type="text/javascript" charset="utf-8">18 var payloadThread = ${c.thread_as_json};19 var payloadThreadFactlets = ${c.thread_factlets_json};20 </script>21 22 17 <body> 23 18 <aside id="thread-control-${c.thread.id}" py:if="len(c.thread.factlets) > 0">
