{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% load leaflet_tags %}

{% block meta %}
{% leaflet_js %}
{% leaflet_css %}
{% endblock %}

{% block scripts %}
{% include "monitorjobs.html" %}
{% endblock %}

{% block title %}{{ workout.name }} {% endblock %}
{% block og_title %}{{ workout.name }} {% endblock %}
{% block description %}{{ workout.name }}
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
{% block og_description %}{{ workout.name }}
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}


{% block og_image %}
{% if graphs %}
{% for graph in graphs %}
<meta property="og:image" content="http://rowsandall.com/{{ graph.filename |spacetohtml }}" />
<meta property="og:image:secure_url" content="https://rowsandall.com/{{ graph.filename |spacetohtml }}" />
<meta property="og:image:width" content="{{ graph.width }}" />
<meta property="og:image:height" content="{{ graph.height }}" />
{% endfor %}
{% else %}
<meta property="og:image" content="http://rowsandall.com/static/img/logo_r.png" />
<meta property="og:image:secure_url" content="https://rowsandall.com/static/img/logo_r.png" />
{% endif %}
{% endblock %}
{% block image_src %}
{% for graph in graphs %}
<link rel="image_src" href="/{{ graph.filename |spacetohtml }}" />
{% endfor %}
{% endblock %}

{% block main %}

<h1>{{ workout.name }}</h1>
<ul class="main-content">
  <li class="grid_2">
    {% if records %}
    {% for record in records %}
    <p>
      This workout was run as a virtual challenge. See challenge result here:
      <a href="/rowers/virtualevent/{{ record.race.id }}/">{{ record.race.name }}</a>
    </p>
    {% endfor %}
    {% endif %}
    {% if recordsindoor %}
    {% for record in recordsindoor %}
    <p>
      This workout was as a virtual challenge. See challenge result here:
      <a href="/rowers/virtualevent/{{ record.race.id }}/">{{ record.race.name }}</a>
    </p>
    {% endfor %}
    {% endif %}
    <p>
      <div class="fb-share-button"
           data-href="https://rowsandall.com/rowers/workout/{{ workout.id|encode }}/"
           data-layout="button" data-size="small" data-mobile-iframe="false">
        <a class="fb-xfbml-parse-ignore" target="_blank"
           href="https://www.facebook.com/sharer/sharer.php?u=https://rowsandall.com/rowers/workout/{{ workout.id|encode }}/">
          Share
        </a>
      </div>
    </p>
    <p>
      <a class="twitter-share-button"
         href="https://twitter.com/intent/tweet"
         data-url="https://rowsandall.com/rowers/workout/{{ workout.id|encode }}/"
         data-text="@rowsandall #rowingdata">Tweet</a>
    </p>
    <table width=100%>
      <tr>
	<th>Rower:</th><td>{{ first_name }} {{ last_name }}</td>
      </tr><tr>
      <tr>
	<th>Name:</th><td>{{ workout.name }}</td>
      </tr><tr>
      <tr>
	<th>Date:</th><td>{{ workout.date }}</td>
      </tr><tr>
	<th>Time:</th><td>{{ workout.starttime }}</td>
      </tr><tr>
	<th>Distance:</th><td>{{ workout.distance }}m</td>
      </tr><tr>
	<th>Duration:</th><td>{{ workout.duration |durationprint:"%H:%M:%S.%f" }}</td>
      </tr><tr>
	<th>Type:</th><td>{{ workout.workouttype }}</td>
      </tr><tr>
	<th>Weight Category:</th><td>{{ workout.weightcategory }}</td>
      </tr>
      {% if user.is_authenticated %}
      <tr>
        <th>Comments</th>
        <td>
          <a href="/rowers/workout/{{ workout.id|encode }}/comment/">Comment ({{ aantalcomments }})</a>
        </td>
      </tr>
      {% endif %}
    </table>
  </li>
  <li class="grid_2">
    <h1>Workout Summary</h1>

    <p>
      <pre>
        {{ summary }}
      </pre>
    </p>
  </li>
  {% if mapdiv %}
  <li class="grid_2">
    <div class="mapdiv">

    {{ mapdiv|safe }}


    {{ mapscript|safe }}
    </div>
  </li>
  {% endif %}
  <li class="grid_2">
    <script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
    <script async="true" type="text/javascript">
      Bokeh.set_log_level("info");
    </script>

    {{ interactiveplot |safe }}

    {{ the_div|safe }}

  </li>
  {% for graph in graphs %}
  <li>
    <a href="/rowers/graph/{{ graph.id }}/">
    <img src="/{{ graph.filename }}"
	 onerror="this.src='/static/img/rowingtimer.gif'"
	 alt="{{ graph.filename }}" width="120" height="100">
    </a>
  </li>
  {% endfor %}
</ul>

{% endblock %}

{% block sidebar %}
{% include 'menu_workout.html' %}
{% endblock %}
