Changeset 169

Show
Ignore:
Timestamp:
08/20/08 18:52:42 (3 months ago)
Author:
johnbywater
Message:

Adding geochrono page.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/microfacts/controllers/thread.py

    r163 r169  
    6969                html = fc.read_core(id) 
    7070                c.factlet_info = genshi.XML(html) 
     71            self._set_json_payload() 
    7172            return render('thread/read') 
    7273        else: 
     
    9293            abort(mode.response_code) 
    9394 
     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 
    94115    def update(self, id): 
    95116        c.has_inline_edit = True 
     
    103124            c.thread = mode.entity 
    104125 
    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() 
    112127            return render('thread/update') 
    113128        else: 
    114129            abort(mode.response_code) 
    115130 
     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  
    66    initialize: function (element) { 
    77        this.element = element; 
     8        //if (! this.element.id) { 
     9        //    console.error("Map element has no id attribute."); 
     10            // Now die. 
     11        //} 
    812        this.initMap(); 
    913        //this.addEvent('factletSelect', this.onFactletSelected.bind(this)); 
     
    145149        this.selectedFeature.popup.destroy(); 
    146150        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); 
    147170    } 
    148171}); 
  • trunk/microfacts/public/behaviour/lib/timelinecontroller.js

    r154 r169  
    9797//    onFeatureUnselect: function(feature) { 
    9898//        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); 
    99118    } 
     119 
    100120}); 
    101121 
  • trunk/microfacts/public/behaviour/load.js

    r160 r169  
    185185}); 
    186186 
     187loader.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  
    3838      ${select('aside')} 
    3939      ${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 
    4045    </body> 
    4146  </py:match> 
  • trunk/microfacts/templates/thread/read_geochrono.html

    r107 r169  
    99  <xi:include href="layout.html" /> 
    1010 
     11  <py:def function="pagecontrollername">geochronopagecontroller</py:def> 
     12 
    1113  <head> 
    1214    <title>View - ${c.thread.title}</title> 
     
    1416 
    1517  <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 the 
    19       controls below or click on the relevant Factlet in the thread list.</p> 
    20       <form> 
    21         <input type="button" value="&laquo; Previous" class="prev" /> 
    22         <input type="button" value="Next &raquo;" class="next" /> 
    23       </form> 
    24       <p> 
    25         ${h.link_to("Edit This Thread &raquo;", h.url_for(controller='thread', 
    26         action='update'))} 
    27       </p> 
    28     </aside> 
    2918 
    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> 
    7021 
    7122  </body> 
  • trunk/microfacts/templates/thread/update.html

    r163 r169  
    1515  </head> 
    1616 
    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    
    2217  <body> 
    2318    <aside id="thread-control-${c.thread.id}" py:if="len(c.thread.factlets) > 0">