Commit 1ec90e26 authored by Julian Rother's avatar Julian Rother
Browse files

Added timestamp formatting filter "time_offset" and increased rss feed compatability

parent f55e474f
...@@ -156,6 +156,10 @@ def human_time(d): ...@@ -156,6 +156,10 @@ def human_time(d):
def rfc3339(d): def rfc3339(d):
return d.strftime('%Y-%m-%dT%H:%M:%S+02:00') return d.strftime('%Y-%m-%dT%H:%M:%S+02:00')
@app.template_filter()
def time_offset(s):
return '%02d:%02d:%02d'%(s//3600, (s//60)%60, s%60)
@app.template_filter() @app.template_filter()
def rfc822(d): def rfc822(d):
return formatdate(mktime(d.timetuple())) return formatdate(mktime(d.timetuple()))
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
{%- if chapters|selectattr('lecture_id','equalto',item.id)|list %} {%- if chapters|selectattr('lecture_id','equalto',item.id)|list %}
<ul> <ul>
{% for chapter in chapters|selectattr('lecture_id','equalto',item.id) %} {% for chapter in chapters|selectattr('lecture_id','equalto',item.id) %}
<li>{{ '%02d:%02d:%02d'|format( chapter.time//3600, (chapter.time//60)%60, chapter.time%60) }}: {{ chapter.text }}</li> <li>{{ chapter.time|time_offset }}: {{ chapter.text }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
...@@ -49,11 +49,11 @@ ...@@ -49,11 +49,11 @@
<dc:creator>{{ item.speaker|e }}</dc:creator> <dc:creator>{{ item.speaker|e }}</dc:creator>
{% endif %} {% endif %}
{% if item.video.duration > 0 %} {% if item.video.duration > 0 %}
<itunes:duration>{{ item.video.duration }}</itunes:duration> <itunes:duration>{{ item.video.duration|time_offset }}</itunes:duration>
{% endif %} {% endif %}
<psc:chapters xmlns:psc="http://podlove.org/simple-chapters" version="1.2"> <psc:chapters xmlns:psc="http://podlove.org/simple-chapters" version="1.2">
{% for chapter in chapters|selectattr('lecture_id','equalto',item.id) %} {% for chapter in chapters|selectattr('lecture_id','equalto',item.id) %}
<psc:chapter start="{{ chapter.time }}" title="{{ chapter.text }}"/> <psc:chapter start="{{ chapter.time|time_offset }}" title="{{ chapter.text }}"/>
{% endfor %} {% endfor %}
</psc:chapters> </psc:chapters>
<enclosure url="{{ url_for('files', filename=item.video.path, _external=True) }}" length="{{ item.video.file_size }}" type="{{ format.mimetype }}"/> <enclosure url="{{ url_for('files', filename=item.video.path, _external=True) }}" length="{{ item.video.file_size }}" type="{{ format.mimetype }}"/>
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
{% for c in chapters|sort(attribute='time') %} {% for c in chapters|sort(attribute='time') %}
<tr> <tr>
<td> <td>
<a class="chapterlink" href="{{url_for('lecture', course=course.handle, id=lecture.id, t=c['time'])}}" data-seek-time="{{c['time']}}">{{ '%02d:%02d:%02d'|format( c['time']//3600, (c['time']//60)%60, c['time']%60) }}</a> <a class="chapterlink" href="{{url_for('lecture', course=course.handle, id=lecture.id, t=c['time'])}}" data-seek-time="{{c['time']}}">{{ c.time|time_offset }}</a>
<br> <br>
{% if ismod() %} {% if ismod() %}
{{ moderator_editor(['chapters',c.id,'time'],c['time'],true) }} {{ moderator_editor(['chapters',c.id,'time'],c['time'],true) }}
......
...@@ -358,7 +358,7 @@ $('#embedcodebtn').popover( ...@@ -358,7 +358,7 @@ $('#embedcodebtn').popover(
{% endmacro %} {% endmacro %}
{% macro vtttime(time) %}{{ '%02d:%02d:%02d.000'|format( time//3600, (time//60)%60, time%60) }}{% endmacro %} {% macro vtttime(time) %}{{ time|time_offset }}.000{% endmacro %}
{% macro stats_viewsperday(id, req, title, type="scatter", param=None, maxtraces=7) %} {% macro stats_viewsperday(id, req, title, type="scatter", param=None, maxtraces=7) %}
<script> <script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment