diff --git a/mirrors/templatetags/jinja2.py b/mirrors/templatetags/jinja2.py
index 5d47fe9b..04e50238 100644
--- a/mirrors/templatetags/jinja2.py
+++ b/mirrors/templatetags/jinja2.py
@@ -1,3 +1,4 @@
+from datetime import timedelta
from django_jinja import library
from markupsafe import Markup
@@ -22,10 +23,31 @@ def duration(value):
return '%d:%02d' % (hrs, mins)
+@library.filter
+def hours(value):
+ if not value and type(value) != timedelta:
+ return u''
+ # does not take microseconds into account
+ total_secs = value.seconds + value.days * 24 * 3600
+ mins = total_secs // 60
+ hrs, mins = divmod(mins, 60)
+ if hrs == 1:
+ return '%d hour' % hrs
+ return '%d hours' % hrs
+
+
@library.filter
def floatvalue(value, arg=2):
if value is None:
return u''
return '%.*f' % (arg, value)
+
+@library.filter
+def percentage(value, arg=1):
+ if not value and type(value) != float:
+ return u''
+ new_val = value * 100.0
+ return '%.*f%%' % (arg, new_val)
+
# vim: set ts=4 sw=4 et:
diff --git a/templates/mirrors/error_table.html b/templates/mirrors/error_table.html.jinja
similarity index 67%
rename from templates/mirrors/error_table.html
rename to templates/mirrors/error_table.html.jinja
index cd7265af..52f68135 100644
--- a/templates/mirrors/error_table.html
+++ b/templates/mirrors/error_table.html.jinja
@@ -1,5 +1,3 @@
-{% load cycle from future %}
-{% load flags mirror_status %}
@@ -12,12 +10,12 @@
- {% for log in error_logs %}
+ {% for log in error_logs %}
{{ log.url__url }} |
{{ log.url__protocol__protocol }} |
- {% country_flag log.country %}{{ log.country.name }} |
+ {{ country_flag(log.country) }}{{ log.country.name }} |
{{ log.error|linebreaksbr }} |
- {{ log.last_occurred|date:'Y-m-d H:i' }} |
+ {{ log.last_occurred|date('Y-m-d H:i') }} |
{{ log.error_count }} |
{% endfor %}
diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html
index 2ff41828..e4ae55b4 100644
--- a/templates/mirrors/mirror_details.html
+++ b/templates/mirrors/mirror_details.html
@@ -132,7 +132,7 @@ Available URLs
Error Log
- {% include "mirrors/error_table.html" %}
+ {% include "mirrors/error_table.html.jinja" %}
diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html
index 24408be7..530e3ff5 100644
--- a/templates/mirrors/status.html
+++ b/templates/mirrors/status.html
@@ -60,18 +60,18 @@
Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}
Out of Sync Mirrors
{% with urls=bad_urls table_id='outofsync_mirrors' %}
- {% include "mirrors/status_table.html" %}
+ {% include "mirrors/status_table.html.jinja" %}
{% endwith %}
Successfully Syncing Mirrors
{% with urls=good_urls table_id='successful_mirrors' %}
- {% include "mirrors/status_table.html" %}
+ {% include "mirrors/status_table.html.jinja" %}
{% endwith %}
Mirror Syncing Error Log
- {% include "mirrors/error_table.html" %}
+ {% include "mirrors/error_table.html.jinja" %}
{% endblock %}
diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html
deleted file mode 100644
index 83538303..00000000
--- a/templates/mirrors/status_table.html
+++ /dev/null
@@ -1,30 +0,0 @@
-{% load cycle from future %}
-{% load flags mirror_status %}
-
-
-
- Mirror URL |
- Protocol |
- Country |
- Completion % |
- μ Delay (hh:mm) |
- μ Duration (s) |
- σ Duration (s) |
- Mirror Score |
- |
-
-
-
- {% for m_url in urls %}
- {{ m_url.url }} |
- {{ m_url.protocol }} |
- {% country_flag m_url.country %}{{ m_url.country.name }} |
- {{ m_url.completion_pct|percentage:1 }} |
- {{ m_url.delay|duration|default:'unknown' }} |
- {{ m_url.duration_avg|floatvalue:2 }} |
- {{ m_url.duration_stddev|floatvalue:2 }} |
- {{ m_url.score|floatvalue:1|default:'∞' }} |
- details |
-
{% endfor %}
-
-
diff --git a/templates/mirrors/status_table.html.jinja b/templates/mirrors/status_table.html.jinja
new file mode 100644
index 00000000..598a1af0
--- /dev/null
+++ b/templates/mirrors/status_table.html.jinja
@@ -0,0 +1,28 @@
+
+
+
+ Mirror URL |
+ Protocol |
+ Country |
+ Completion % |
+ μ Delay (hh:mm) |
+ μ Duration (s) |
+ σ Duration (s) |
+ Mirror Score |
+ |
+
+
+
+ {% for m_url in urls %}
+ {{ m_url.url }} |
+ {{ m_url.protocol }} |
+ {{ country_flag(m_url.country) }}{{ m_url.country.name }} |
+ {{ m_url.completion_pct|percentage(1) }} |
+ {{ m_url.delay|duration|default('unknown') }} |
+ {{ m_url.duration_avg|floatvalue(2) }} |
+ {{ m_url.duration_stddev|floatvalue(2) }} |
+ {{ m_url.score|floatvalue(1)|default('∞') }} |
+ details |
+
{% endfor %}
+
+