diff options
author | Jelle van der Waa <jelle@archlinux.org> | 2019-03-17 18:08:39 +0100 |
---|---|---|
committer | Jelle van der Waa <jelle@archlinux.org> | 2019-03-17 18:08:39 +0100 |
commit | 05f324c76c675857ea1cd8225c55075408beff33 (patch) | |
tree | c0dd4c67f124926871edeb52a9e4f623cd14de23 | |
parent | f829a33ea72429382ba11a856fe6b6c8955002eb (diff) |
templates: Add tag for d3js
Create a simple tag for outputting the d3js <script> html so updating
will be easier and the version has be changed in one file.
Signed-off-by: Jelle van der Waa <jelle@archlinux.org>
-rw-r--r-- | main/templatetags/cdn.py | 7 | ||||
-rw-r--r-- | templates/mirrors/mirror_details.html | 3 | ||||
-rw-r--r-- | templates/public/keys.html | 3 | ||||
-rw-r--r-- | templates/visualize/index.html | 3 |
4 files changed, 10 insertions, 6 deletions
diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py index c0ce83d8..23c13314 100644 --- a/main/templatetags/cdn.py +++ b/main/templatetags/cdn.py @@ -21,4 +21,11 @@ def jquery_tablesorter(): link = staticfiles_storage.url(filename) return format_html('<script type="text/javascript" src="%s"></script>' % link) +@register.simple_tag +def d3js(): + version = '3.0.6' + filename = 'd3-%s.min.js' % version + link = staticfiles_storage.url(filename) + return format_html('<script type="text/javascript" src="%s"></script>' % link) + # vim: set ts=4 sw=4 et: diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 89345664..dd19e80d 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -111,8 +111,7 @@ {% endblock %} {% block script_block %} -{% load cdn %}{% jquery %}{% jquery_tablesorter %} -<script type="text/javascript" src="{% static "d3-3.0.6.min.js" %}"></script> +{% load cdn %}{% jquery %}{% jquery_tablesorter %}{% d3js %} <script type="text/javascript" src="{% static "archweb.js" %}"></script> <script type="text/javascript" src="{% static "mirror_status.js" %}"></script> <script type="text/javascript" nonce={{ CSP_NONCE }}> diff --git a/templates/public/keys.html b/templates/public/keys.html index 978abaab..39fe6efb 100644 --- a/templates/public/keys.html +++ b/templates/public/keys.html @@ -135,8 +135,7 @@ {% endblock %} {% block script_block %} -{% load cdn %}{% jquery %}{% jquery_tablesorter %} -<script type="text/javascript" src="{% static "d3-3.0.6.min.js" %}"></script> +{% load cdn %}{% jquery %}{% jquery_tablesorter %}{% d3js %} <script type="text/javascript" src="{% static "archweb.js" %}"></script> <script type="text/javascript" src="{% static "visualize.js" %}"></script> <script type="text/javascript" nonce={{ CSP_NONCE }}> diff --git a/templates/visualize/index.html b/templates/visualize/index.html index 5b992ea4..47a6b3f4 100644 --- a/templates/visualize/index.html +++ b/templates/visualize/index.html @@ -26,8 +26,7 @@ {% endblock %} {% block script_block %} -{% load cdn %}{% jquery %} -<script type="text/javascript" src="{% static "d3-3.0.6.min.js" %}"></script> +{% load cdn %}{% jquery %}{% d3js %} <script type="text/javascript" src="{% static "archweb.js" %}"></script> <script type="text/javascript" src="{% static "visualize.js" %}"></script> <script type="text/javascript" nonce={{ CSP_NONCE }}> |