Changeset b3374f6 in OpenWorkouts-current for ow/templates


Ignore:
Timestamp:
Feb 12, 2019, 5:55:33 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
c999b73e
Parents:
f713dbc
Message:

(#52) - Make map screenshot generation async and non-blocker of the dashboard
and user profile pages:

  • workout.map_screenshot is a property again, returns a string with the static path (suitable for use with request.static_url()) for the map screenshot file if exists, none otherwise
  • added a couple of helpers to build the proper screenshot name and full path on the filesystem
  • added a view to generate the map if needed, returning the full static url to the screenshot file in a json-encoded stream
  • added a new js ow tool that looks for workouts that still don't have a map screenshot, calling the view to generate that screenshot and updating the map screenshot when the file is ready
  • modified the dashboard and user profile templates, so a dummy/placeholder image is shown when no map screenshot is yet ready, plus setup and calls for the js tool that generates the maps.
Location:
ow/templates
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ow/templates/dashboard.pt

    rf713dbc rb3374f6  
    7979
    8080            <div class="workout-map" tal:condition="workout.has_gpx">
    81                 <a href="" tal:attributes="href request.resource_url(workout)">
    82                     <img src="" tal:attributes="src workout.map_screenshot(request);
    83                               alt workout.title; title workout.title">
    84                 </a>
     81              <a href="" tal:attributes="href request.resource_url(workout)">
     82                <tal:has-screenshot tal:condition="workout.map_screenshot is not None">
     83                  <img src="" tal:attributes="src request.static_url(workout.map_screenshot);
     84                            alt workout.title; title workout.title">
     85                </tal:has-screenshot>
     86                <tal:has-not-screenshot tal:condition="workout.map_screenshot is None">
     87                  <img src="" tal:attributes="src request.static_url('ow:static/media/img/no_map.png');
     88                            alt workout.title; title workout.title; class 'js-needs-map'">
     89                </tal:has-not-screenshot>
     90              </a>
    8591            </div>
    8692
     
    193199
    194200    <script type="text/javascript">
     201
     202     var map_shots = owjs.map_shots({
     203         img_selector: 'img.js-needs-map',
     204     })
     205     map_shots.run();
     206
    195207     var week_chart = owjs.week_chart({
    196208         chart_selector: 'div.js-week-stats svg',
  • ow/templates/profile.pt

    rf713dbc rb3374f6  
    144144              <div class="workout-map" tal:condition="workout.has_gpx">
    145145                <a href="" tal:attributes="href request.resource_url(workout)">
    146                   <img src="" tal:attributes="src workout.map_screenshot(request);
    147                             alt workout.title; title workout.title">
     146                  <tal:has-screenshot tal:condition="workout.map_screenshot is not None">
     147                    <img src="" tal:attributes="src request.static_url(workout.map_screenshot);
     148                              alt workout.title; title workout.title">
     149                  </tal:has-screenshot>
     150                  <tal:has-not-screenshot tal:condition="workout.map_screenshot is None">
     151                    <img src="" tal:attributes="src request.static_url('ow:static/media/img/no_map.png');
     152                              alt workout.title; title workout.title; class 'js-needs-map'">
     153                  </tal:has-not-screenshot>
    148154                </a>
    149155              </div>
     
    187193
    188194    <script type="text/javascript">
     195     var map_shots = owjs.map_shots({
     196         img_selector: 'img.js-needs-map',
     197     })
     198     map_shots.run();
     199
    189200     var y_axis_labels = {
    190201         "distance": "Kilometers",
Note: See TracChangeset for help on using the changeset viewer.