From 0b930fd92140858f4ad21e593feb057996af9b95 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 16 Jan 2013 00:36:17 -0600 Subject: Convert all usages of flag icons to new sprite This uses a new template tag to avoid repeating construction of the necessary HTML element all over the place. The site should look exactly as it did before, except now you don't have to download 20+ images to see some pages. Signed-off-by: Dan McGee --- main/templatetags/flags.py | 13 +++++++++++++ templates/devel/clock.html | 5 ++++- templates/mirrors/mirror_details.html | 5 ++++- templates/mirrors/status.html | 5 ++++- templates/mirrors/status_table.html | 3 ++- templates/public/developer_list.html | 3 ++- templates/public/download.html | 6 +++++- templates/public/userlist.html | 3 +++ 8 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 main/templatetags/flags.py diff --git a/main/templatetags/flags.py b/main/templatetags/flags.py new file mode 100644 index 00000000..22f524ca --- /dev/null +++ b/main/templatetags/flags.py @@ -0,0 +1,13 @@ +from django import template + +register = template.Library() + + +@register.simple_tag +def country_flag(country): + if not country: + return '' + return ' ' % ( + country.code.lower(), country.name) + +# vim: set ts=4 sw=4 et: diff --git a/templates/devel/clock.html b/templates/devel/clock.html index 02e42749..83fbb70b 100644 --- a/templates/devel/clock.html +++ b/templates/devel/clock.html @@ -1,9 +1,12 @@ {% extends "base.html" %} {% load static from staticfiles %} +{% load flags %} {% load tz %} {% block title %}Arch Linux - Developer World Clocks{% endblock %} +{% block head %}{% endblock %} + {% block content %}

Developer World Clocks

@@ -45,7 +48,7 @@

Developer World Clocks

{{ dev.username }} {{ dev.userprofile.alias }} {{ dev.last_action }} - {% if dev.userprofile.country %}{{ dev.userprofile.country.name }} {% endif %}{{ dev.userprofile.location }} + {% country_flag dev.userprofile.country %}{{ dev.userprofile.location }} {{ dev.userprofile.time_zone }} {{ utc_now|timezone:dev.userprofile.time_zone|date:"Y-m-d H:i T" }} {{ dev.userprofile.time_zone }} diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index a56123ff..8ea6bbec 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -1,9 +1,12 @@ {% extends "base.html" %} {% load static from staticfiles %} {% load mirror_status %} +{% load flags %} {% block title %}Arch Linux - {{ mirror.name }} - Mirror Details{% endblock %} +{% block head %}{% endblock %} + {% block content %}
@@ -90,7 +93,7 @@

Available URLs

{% if m_url.protocol.is_download %}{{ m_url.url }}{% else %}{{ m_url.url }}{% endif %} {{ m_url.protocol }} - {% if m_url.country %} {% endif %}{{ m_url.country.name }} + {% country_flag m_url.country %}{{ m_url.country.name }} {{ m_url.has_ipv4|yesno|capfirst }} {{ m_url.has_ipv6|yesno|capfirst }} {{ m_url.last_sync|date:'Y-m-d H:i'|default:'unknown' }} diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index ec2ae568..8d32d3fa 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -1,9 +1,12 @@ {% extends "base.html" %} {% load static from staticfiles %} {% load mirror_status %} +{% load flags %} {% block title %}Arch Linux - Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}{% endblock %} +{% block head %}{% endblock %} + {% block content %}

Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}

@@ -88,7 +91,7 @@

Mirror Syncing Error Log

{% spaceless %} {{ log.url__url }} {{ log.url__protocol__protocol }} - {% if log.country %} {% endif %}{{ log.country.name }} + {% country_flag log.country %}{{ log.country.name }} {{ log.error|linebreaksbr }} {{ log.last_occurred|date:'Y-m-d H:i' }} {{ log.error_count }} diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html index c7394de6..2dd7ef49 100644 --- a/templates/mirrors/status_table.html +++ b/templates/mirrors/status_table.html @@ -1,4 +1,5 @@ {% load mirror_status %} +{% load flags %} @@ -17,7 +18,7 @@ {% spaceless %} - + diff --git a/templates/public/developer_list.html b/templates/public/developer_list.html index df4137eb..4401d97b 100644 --- a/templates/public/developer_list.html +++ b/templates/public/developer_list.html @@ -1,3 +1,4 @@ +{% load flags %} {% load pgp %}
@@ -56,7 +57,7 @@

{{ dev.get_full_name }}{% if prof.latin_name %} ({{ prof.latin_name}}){% end

- + diff --git a/templates/public/download.html b/templates/public/download.html index 0c96fcef..7de49778 100644 --- a/templates/public/download.html +++ b/templates/public/download.html @@ -2,8 +2,12 @@ {% load cache %} {% load url from future %} {% load static from staticfiles %} +{% load flags %} {% block title %}Arch Linux - Downloads{% endblock %} + +{% block head %}{% endblock %} + {% block navbarclass %}anb-download{% endblock %} {% block content %} @@ -83,7 +87,7 @@

Checksums

{% regroup mirror_urls by country as grouped_urls %} {% for country in grouped_urls %} - {% if country.grouper %}
{{ country.grouper.name }}
+ {% if country.grouper %}
{% country_flag country.grouper %}{{ country.grouper.name }}
{% else %}
Worldwide
{% endif %}
    {% for mirror_url in country.list %} diff --git a/templates/public/userlist.html b/templates/public/userlist.html index 0077f611..35104317 100644 --- a/templates/public/userlist.html +++ b/templates/public/userlist.html @@ -1,8 +1,11 @@ {% extends "base.html" %} +{% load static from staticfiles %} {% load cache %} {% block title %}Arch Linux - {{ user_type }}{% endblock %} +{% block head %}{% endblock %} + {% block content %} {% cache 600 dev-tu-profiles user_type %}
    -- cgit v1.2.3-54-g00ecf
{{ m_url.url }} {{ m_url.protocol }}{% if m_url.country %} {% endif %}{{ m_url.country.name }}{% 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|floatformat:2 }}{% if prof.yob %}{{ prof.yob }}{% endif %}
Location:{% if dev.userprofile.country %}{{ dev.userprofile.country.name }} {% endif %}{{ prof.location }}{% country_flag dev.userprofile.country %}{{ prof.location }}
Languages: {{ prof.languages }}