From 12bf4c1b1e7df2d934b9dfde8629137dedeea99f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 18 Feb 2012 19:17:00 -0600 Subject: Add a smart protocol filter to mirrorlist generator This will only list FTP mirrors for a given country if there are no HTTP mirrors available, since FTP must die. Signed-off-by: Dan McGee --- templates/mirrors/mirrorlist_generate.html | 1 + 1 file changed, 1 insertion(+) (limited to 'templates/mirrors') diff --git a/templates/mirrors/mirrorlist_generate.html b/templates/mirrors/mirrorlist_generate.html index e6f5e28c..34bda63d 100644 --- a/templates/mirrors/mirrorlist_generate.html +++ b/templates/mirrors/mirrorlist_generate.html @@ -23,6 +23,7 @@

Mirrorlist with all available mirrors

  • All mirrors
  • All mirrors, FTP only
  • All mirrors, HTTP only
  • +
  • All mirrors, Smart protocols: this link only includes FTP mirrors if an HTTP mirror is not available in a given country.
  • Customized by country mirrorlist

    -- cgit v1.2.3-54-g00ecf From 3b0b9012353d5ffda564998cab58f986770361be Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 13 May 2012 20:14:16 -0500 Subject: Use linebreaksbr filter on log error message text If we get a multi-line message in, we should show line breaks at the appropriate places. Signed-off-by: Dan McGee --- templates/mirrors/status.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates/mirrors') diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 8ee1d46e..34896c07 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -89,7 +89,7 @@

    Mirror Syncing Error Log

    {{ log.url__url }} {{ log.url__protocol__protocol }} {% if log.country %} {% endif %}{{ log.country.name }} - {{ log.error }} + {{ log.error|linebreaksbr }} {{ log.last_occurred|date:'Y-m-d H:i' }} {{ log.error_count }} -- cgit v1.2.3-54-g00ecf From 2f7d770b261b3428bcff366ba6ff4fa631dd980a Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 13 May 2012 20:15:00 -0500 Subject: Add rsync support to mirrorcheck and other small improvements The main changes in this patch implement rsync:// protocol checking support by calling the rsync binary, requested in FS#29878. We track and log much of the same things as we already do for FTP and HTTP URLs- check time, last sync, total check duration, etc. Also added in this patch is a configurable timeout value which defaults to the previous hardcoded value of 10 seconds; this can be passed as an option to the mirrorcheck command. Signed-off-by: Dan McGee --- mirrors/management/commands/mirrorcheck.py | 130 ++++++++++++++++++++--------- templates/mirrors/status.html | 4 +- 2 files changed, 91 insertions(+), 43 deletions(-) (limited to 'templates/mirrors') diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py index c1269226..ae89d5e0 100644 --- a/mirrors/management/commands/mirrorcheck.py +++ b/mirrors/management/commands/mirrorcheck.py @@ -9,22 +9,26 @@ Usage: ./manage.py mirrorcheck """ -from django.core.management.base import NoArgsCommand -from django.db import transaction - from collections import deque from datetime import datetime import logging +import os +from optparse import make_option +from pytz import utc import re import socket +import subprocess import sys import time +import tempfile from threading import Thread import types -from pytz import utc from Queue import Queue, Empty import urllib2 +from django.core.management.base import NoArgsCommand +from django.db import transaction + from main.utils import utc_now from mirrors.models import MirrorUrl, MirrorLog @@ -37,10 +41,15 @@ class Command(NoArgsCommand): + option_list = NoArgsCommand.option_list + ( + make_option('-t', '--timeout', dest='timeout', default='10', + help='Timeout value for connecting to URL'), + ) help = "Runs a check on all known mirror URLs to determine their up-to-date status." def handle_noargs(self, **options): v = int(options.get('verbosity', 0)) + timeout = int(options.get('timeout', 10)) if v == 0: logger.level = logging.ERROR elif v == 1: @@ -48,10 +57,29 @@ def handle_noargs(self, **options): elif v == 2: logger.level = logging.DEBUG - return check_current_mirrors() + urls = MirrorUrl.objects.select_related('protocol').filter( + mirror__active=True, mirror__public=True) + + pool = MirrorCheckPool(urls, timeout) + pool.run() + return 0 -def check_mirror_url(mirror_url): +def parse_lastsync(log, data): + '''lastsync file should be an epoch value created by us.''' + try: + parsed_time = datetime.utcfromtimestamp(int(data)) + log.last_sync = parsed_time.replace(tzinfo=utc) + except ValueError: + # it is bad news to try logging the lastsync value; + # sometimes we get a crazy-encoded web page. + # if we couldn't parse a time, this is a failure. + log.last_sync = None + log.error = "Could not parse time from lastsync" + log.is_success = False + + +def check_mirror_url(mirror_url, timeout): url = mirror_url.url + 'lastsync' logger.info("checking URL %s", url) log = MirrorLog(url=mirror_url, check_time=utc_now()) @@ -59,28 +87,14 @@ def check_mirror_url(mirror_url): req = urllib2.Request(url, None, headers) try: start = time.time() - result = urllib2.urlopen(req, timeout=10) + result = urllib2.urlopen(req, timeout=timeout) data = result.read() result.close() end = time.time() - # lastsync should be an epoch value created by us - parsed_time = None - try: - parsed_time = datetime.utcfromtimestamp(int(data)) - parsed_time = parsed_time.replace(tzinfo=utc) - except ValueError: - # it is bad news to try logging the lastsync value; - # sometimes we get a crazy-encoded web page. - pass - - log.last_sync = parsed_time - # if we couldn't parse a time, this is a failure - if parsed_time is None: - log.error = "Could not parse time from lastsync" - log.is_success = False + parse_lastsync(log, data) log.duration = end - start logger.debug("success: %s, %.2f", url, log.duration) - except urllib2.HTTPError, e: + except urllib2.HTTPError as e: if e.code == 404: # we have a duration, just not a success end = time.time() @@ -88,7 +102,7 @@ def check_mirror_url(mirror_url): log.is_success = False log.error = str(e) logger.debug("failed: %s, %s", url, log.error) - except urllib2.URLError, e: + except urllib2.URLError as e: log.is_success = False log.error = e.reason if isinstance(e.reason, types.StringTypes) and \ @@ -101,20 +115,64 @@ def check_mirror_url(mirror_url): elif isinstance(e.reason, socket.error): log.error = e.reason.args[1] logger.debug("failed: %s, %s", url, log.error) - except socket.timeout, e: + except socket.timeout as e: log.is_success = False log.error = "Connection timed out." logger.debug("failed: %s, %s", url, log.error) + except socket.error as e: + log.is_success = False + log.error = str(e) + logger.debug("failed: %s, %s", url, log.error) + + return log + + +def check_rsync_url(mirror_url, timeout): + url = mirror_url.url + 'lastsync' + logger.info("checking URL %s", url) + log = MirrorLog(url=mirror_url, check_time=utc_now()) + + tempdir = tempfile.mkdtemp() + lastsync_path = os.path.join(tempdir, 'lastsync') + rsync_cmd = ["rsync", "--quiet", "--contimeout=%d" % timeout, + "--timeout=%d" % timeout, url, lastsync_path] + try: + with open(os.devnull, 'w') as devnull: + proc = subprocess.Popen(rsync_cmd, stdout=devnull, + stderr=subprocess.PIPE) + start = time.time() + _, errdata = proc.communicate() + end = time.time() + log.duration = end - start + if proc.returncode != 0: + logger.debug("error: %s, %s", url, errdata) + log.is_success = False + log.error = errdata.strip() + # look at rsync error code- if we had a command error or timed out, + # don't record a duration as it is misleading + if proc.returncode in (1, 30, 35): + log.duration = None + else: + logger.debug("success: %s, %.2f", url, log.duration) + with open(lastsync_path, 'r') as lastsync: + parse_lastsync(log, lastsync.read()) + finally: + if os.path.exists(lastsync_path): + os.unlink(lastsync_path) + os.rmdir(tempdir) return log -def mirror_url_worker(work, output): +def mirror_url_worker(work, output, timeout): while True: try: - item = work.get(block=False) + url = work.get(block=False) try: - log = check_mirror_url(item) + if url.protocol.protocol == 'rsync': + log = check_rsync_url(url, timeout) + else: + log = check_mirror_url(url, timeout) output.append(log) finally: work.task_done() @@ -123,7 +181,7 @@ def mirror_url_worker(work, output): class MirrorCheckPool(object): - def __init__(self, urls, num_threads=10): + def __init__(self, urls, timeout=10, num_threads=10): self.tasks = Queue() self.logs = deque() for i in list(urls): @@ -131,7 +189,7 @@ def __init__(self, urls, num_threads=10): self.threads = [] for i in range(num_threads): thread = Thread(target=mirror_url_worker, - args=(self.tasks, self.logs)) + args=(self.tasks, self.logs, timeout)) thread.daemon = True self.threads.append(thread) @@ -142,18 +200,8 @@ def run(self): thread.start() logger.debug("joining on all threads") self.tasks.join() - logger.debug("processing log entries") + logger.debug("processing %d log entries", len(self.logs)) MirrorLog.objects.bulk_create(self.logs) logger.debug("log entries saved") - -def check_current_mirrors(): - urls = MirrorUrl.objects.filter( - protocol__is_download=True, - mirror__active=True, mirror__public=True) - - pool = MirrorCheckPool(urls) - pool.run() - return 0 - # vim: set ts=4 sw=4 et: diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 34896c07..2c350f56 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -16,8 +16,8 @@

    Mirror Status

    has synced recently. This page contains several pieces of information about each mirror.

      -
    • Mirror URL: Mirrors are checked on a per-URL basis. If - both FTP and HTTP access are provided, both will be listed here.
    • +
    • Mirror URL: Mirrors are checked on a per-URL basis. All + available URLs and protocols for each known mirror are listed.
    • Completion %: The number of mirror checks that have successfully connected and disconnected from the given URL. If this is below 100%, the mirror may be unreliable.
    • -- cgit v1.2.3-54-g00ecf From ae1c526ffbe908322f0dd8d8805360b81ab22b0f Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 13 May 2012 20:35:50 -0500 Subject: Add ability to restrict status report to single tier This should make it easier to catch errors in our Tier 1 mirrors. Signed-off-by: Dan McGee --- mirrors/urls.py | 1 + mirrors/utils.py | 2 +- mirrors/views.py | 19 ++++++++++++++++--- templates/mirrors/status.html | 4 ++-- 4 files changed, 20 insertions(+), 6 deletions(-) (limited to 'templates/mirrors') diff --git a/mirrors/urls.py b/mirrors/urls.py index f002e9d6..bb4eb969 100644 --- a/mirrors/urls.py +++ b/mirrors/urls.py @@ -4,6 +4,7 @@ (r'^$', 'mirrors', {}, 'mirror-list'), (r'^status/$', 'status', {}, 'mirror-status'), (r'^status/json/$', 'status_json', {}, 'mirror-status-json'), + (r'^status/tier/(?P\d+)/$', 'status', {}, 'mirror-status-tier'), (r'^(?P[\.\-\w]+)/$', 'mirror_details'), ) diff --git a/mirrors/utils.py b/mirrors/utils.py index 54de567e..2014411d 100644 --- a/mirrors/utils.py +++ b/mirrors/utils.py @@ -88,7 +88,7 @@ def get_mirror_errors(cutoff=default_cutoff): is_success=False, check_time__gte=cutoff_time, url__mirror__active=True, url__mirror__public=True).values( 'url__url', 'url__country', 'url__protocol__protocol', - 'url__mirror__country', 'error').annotate( + 'url__mirror__country', 'url__mirror__tier', 'error').annotate( error_count=Count('error'), last_occurred=Max('check_time') ).order_by('-last_occurred', '-error_count') errors = list(errors) diff --git a/mirrors/views.py b/mirrors/views.py index b0be6238..8f092be7 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -13,7 +13,7 @@ from django.views.generic.simple import direct_to_template from django_countries.countries import COUNTRIES -from .models import Mirror, MirrorUrl, MirrorProtocol +from .models import Mirror, MirrorUrl, MirrorProtocol, TIER_CHOICES from .utils import get_mirror_statuses, get_mirror_errors COUNTRY_LOOKUP = dict(COUNTRIES) @@ -184,7 +184,11 @@ def mirror_details(request, name): {'mirror': mirror, 'urls': all_urls}) -def status(request): +def status(request, tier=None): + if tier is not None: + tier = int(tier) + if tier not in [t[0] for t in TIER_CHOICES]: + raise Http404 bad_timedelta = timedelta(days=3) status_info = get_mirror_statuses() @@ -192,17 +196,26 @@ def status(request): good_urls = [] bad_urls = [] for url in urls: + # screen by tier if we were asked to + if tier is not None and url.mirror.tier != tier: + continue # split them into good and bad lists based on delay if not url.delay or url.delay > bad_timedelta: bad_urls.append(url) else: good_urls.append(url) + error_logs = get_mirror_errors() + if tier is not None: + error_logs = [log for log in error_logs + if log['url__mirror__tier'] == tier] + context = status_info.copy() context.update({ 'good_urls': sorted(good_urls, key=attrgetter('score')), 'bad_urls': sorted(bad_urls, key=lambda u: u.delay or timedelta.max), - 'error_logs': get_mirror_errors(), + 'error_logs': error_logs, + 'tier': tier, }) return direct_to_template(request, 'mirrors/status.html', context) diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 2c350f56..472e9501 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -2,11 +2,11 @@ {% load static from staticfiles %} {% load mirror_status %} -{% block title %}Arch Linux - Mirror Status{% endblock %} +{% block title %}Arch Linux - Mirror Status{% if tier != None %} - Tier {{ tier }}{% endif %}{% endblock %} {% block content %}
      -

      Mirror Status

      +

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

      This page reports the status of all known, public, and active Arch Linux mirrors. All data on this page reflects the status of the mirrors within the last {{ cutoff|hours }}. All listed times are UTC. The check script runs -- cgit v1.2.3-54-g00ecf From 8383a071608329c7683f7a710030ce945bd20b4d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 8 Jul 2012 23:30:48 -0500 Subject: Add a new jquery_tablesorter CDN template tag And use it everywhere we were including the file before. This should make updating the version a heck of a lot easier. Signed-off-by: Dan McGee --- main/templatetags/cdn.py | 7 +++++++ templates/devel/clock.html | 3 +-- templates/devel/index.html | 3 +-- templates/devel/packages.html | 3 +-- templates/mirrors/mirror_details.html | 3 +-- templates/mirrors/mirrors.html | 3 +-- templates/mirrors/status.html | 3 +-- templates/packages/differences.html | 3 +-- templates/packages/groups.html | 3 +-- templates/packages/packages_list.html | 3 +-- templates/packages/signoffs.html | 3 +-- templates/packages/stale_relations.html | 3 +-- templates/public/keys.html | 3 +-- templates/releng/iso_overview.html | 3 +-- templates/releng/result_list.html | 3 +-- templates/todolists/list.html | 3 +-- templates/todolists/public_list.html | 3 +-- templates/todolists/view.html | 3 +-- 18 files changed, 24 insertions(+), 34 deletions(-) (limited to 'templates/mirrors') diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py index ab5d881a..54299823 100644 --- a/main/templatetags/cdn.py +++ b/main/templatetags/cdn.py @@ -17,4 +17,11 @@ def jquery(): link = staticfiles_storage.url(filename) return '' % link + +@register.simple_tag +def jquery_tablesorter(): + filename = 'jquery.tablesorter.min.js' + link = staticfiles_storage.url(filename) + return '' % link + # vim: set ts=4 sw=4 et: diff --git a/templates/devel/clock.html b/templates/devel/clock.html index 6a3f0a69..9ebea06c 100644 --- a/templates/devel/clock.html +++ b/templates/devel/clock.html @@ -52,8 +52,7 @@

      Developer World Clocks

      -{% load cdn %}{% jquery %} - +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} +{% load cdn %}{% jquery %}{% jquery_tablesorter %} + {% endblock %} -- cgit v1.2.3-54-g00ecf From 92837c93acc66056391dd0b98515b89f8fc49691 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 12 Nov 2012 21:37:08 -0600 Subject: Prefetch the available protocols on the mirror overview page Otherwise we are doing one query per mirror, which at this point is over 100 separate queries. Signed-off-by: Dan McGee --- mirrors/models.py | 5 ----- mirrors/views.py | 8 ++++++++ templates/mirrors/mirrors.html | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'templates/mirrors') diff --git a/mirrors/models.py b/mirrors/models.py index 384668b8..0179d5bf 100644 --- a/mirrors/models.py +++ b/mirrors/models.py @@ -33,11 +33,6 @@ class Meta: def __unicode__(self): return self.name - def supported_protocols(self): - protocols = MirrorProtocol.objects.filter( - urls__mirror=self).order_by('protocol').distinct() - return sorted(protocols) - def downstream(self): return Mirror.objects.filter(upstream=self).order_by('name') diff --git a/mirrors/views.py b/mirrors/views.py index 5e374b4d..2e1e83b6 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -159,8 +159,16 @@ def find_mirrors_simple(request, protocol): def mirrors(request): mirror_list = Mirror.objects.select_related().order_by('tier', 'country') + protos = MirrorUrl.objects.values_list( + 'mirror_id', 'protocol__protocol').order_by( + 'mirror__id', 'protocol__protocol') if not request.user.is_authenticated(): mirror_list = mirror_list.filter(public=True, active=True) + protos = protos.filter(mirror__public=True, mirror__active=True) + protos = dict((k, list(v)) for k, v in groupby(protos, key=itemgetter(0))) + for mirror in mirror_list: + items = protos.get(mirror.id, []) + mirror.protocols = [item[1] for item in items] return render(request, 'mirrors/mirrors.html', {'mirror_list': mirror_list}) diff --git a/templates/mirrors/mirrors.html b/templates/mirrors/mirrors.html index 0950520d..c83d0d43 100644 --- a/templates/mirrors/mirrors.html +++ b/templates/mirrors/mirrors.html @@ -29,7 +29,7 @@

      Mirror Overview

      {{ mirror.get_tier_display }} {% if mirror.country %} {% endif %}{{ mirror.country.name }} {{ mirror.isos|yesno|capfirst }} - {{ mirror.supported_protocols|join:", " }} + {{ mirror.protocols|join:", " }} {% if user.is_authenticated %} {{ mirror.public|yesno|capfirst }} {{ mirror.active|yesno|capfirst }} -- cgit v1.2.3-54-g00ecf From 59f5b6ed5524300cc0373ad934b251e220c66da9 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 13 Nov 2012 09:51:11 -0600 Subject: Mirror details style and JS cleanup Signed-off-by: Dan McGee --- sitestatic/archweb.css | 9 +++++++++ templates/mirrors/mirror_details.html | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'templates/mirrors') diff --git a/sitestatic/archweb.css b/sitestatic/archweb.css index cef41399..52aec59f 100644 --- a/sitestatic/archweb.css +++ b/sitestatic/archweb.css @@ -314,6 +314,15 @@ table.pretty2 { border: 1px dotted #bbb; } +table.compact { + width: auto; +} + + table.compact td { + padding: 0.25em 0 0.25em 1.5em; + } + + /* definition lists */ dl { clear: both; diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 32ef8a7a..884187b9 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -5,12 +5,11 @@ {% block title %}Arch Linux - {{ mirror.name }} - Mirror Details{% endblock %} {% block content %} - -
      +

      Mirror Details: {{ mirror.name }}

      - +
      @@ -118,6 +117,8 @@

      Mirror Status Chart

      $("#available_urls:has(tbody tr)").tablesorter( {widgets: ['zebra'], sortList: [[0,0]], headers: { 6: { sorter: 'mostlydigit' }, 7: { sorter: 'mostlydigit' }, 8: { sorter: 'mostlydigit' } } }); +}); +$(document).ready(function() { mirror_status("#visualize-mirror", "./json/"); }); -- cgit v1.2.3-54-g00ecf From 2b9519996a47fd1d978ccac36246f0245ad668fb Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 27 Dec 2012 16:43:01 -0600 Subject: Update D3 to 3.0.0 Signed-off-by: Dan McGee --- templates/mirrors/mirror_details.html | 2 +- templates/public/keys.html | 2 +- templates/visualize/index.html | 2 +- visualize/static/d3-3.0.0.js | 7809 +++++++++++++++++++++++++++ visualize/static/d3-3.0.0.min.js | 4 + visualize/static/d3.v2.js | 9406 --------------------------------- visualize/static/d3.v2.min.js | 4 - 7 files changed, 7816 insertions(+), 9413 deletions(-) create mode 100644 visualize/static/d3-3.0.0.js create mode 100644 visualize/static/d3-3.0.0.min.js delete mode 100644 visualize/static/d3.v2.js delete mode 100644 visualize/static/d3.v2.min.js (limited to 'templates/mirrors') diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 884187b9..132557cd 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -109,7 +109,7 @@

      Mirror Status Chart

      {% load cdn %}{% jquery %}{% jquery_tablesorter %} - + + + {% endblock %} diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html index 1961d222..c7394de6 100644 --- a/templates/mirrors/status_table.html +++ b/templates/mirrors/status_table.html @@ -17,7 +17,7 @@ {% spaceless %}
      - + diff --git a/templates/public/download.html b/templates/public/download.html index 3005ffb3..0c96fcef 100644 --- a/templates/public/download.html +++ b/templates/public/download.html @@ -81,7 +81,7 @@

      Checksums

      {% cache 600 download-mirrors %}
      - {% regroup mirror_urls by real_country as grouped_urls %} + {% regroup mirror_urls by country as grouped_urls %} {% for country in grouped_urls %} {% if country.grouper %}
      {{ country.grouper.name }}
      {% else %}
      Worldwide
      {% endif %} -- cgit v1.2.3-54-g00ecf 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 (limited to 'templates/mirrors') 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

      - + 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

      - + 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 %}
      - + 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 %}
      Name: {{ mirror.name }}
      {{ m_url.url }} {{ m_url.protocol }}{% if m_url.real_country %} {% endif %}{{ m_url.real_country.name }}{% if m_url.country %} {% endif %}{{ m_url.country.name }} {{ m_url.completion_pct|percentage:1 }} {{ m_url.delay|duration|default:'unknown' }} {{ m_url.duration_avg|floatformat:2 }}{{ 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 }}
      {% 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' }}
      {{ 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 }}
      @@ -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 From 82947873d65d06d4d938402b57e9244629f97228 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 8 Feb 2013 21:19:17 -0600 Subject: Upgrade D3 to 3.0.6 Signed-off-by: Dan McGee --- templates/mirrors/mirror_details.html | 2 +- templates/public/keys.html | 2 +- templates/visualize/index.html | 2 +- visualize/static/d3-3.0.0.js | 7809 --------------------------------- visualize/static/d3-3.0.0.min.js | 4 - visualize/static/d3-3.0.6.js | 7790 ++++++++++++++++++++++++++++++++ visualize/static/d3-3.0.6.min.js | 4 + 7 files changed, 7797 insertions(+), 7816 deletions(-) delete mode 100644 visualize/static/d3-3.0.0.js delete mode 100644 visualize/static/d3-3.0.0.min.js create mode 100644 visualize/static/d3-3.0.6.js create mode 100644 visualize/static/d3-3.0.6.min.js (limited to 'templates/mirrors') diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 8ea6bbec..02d68a3a 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -112,7 +112,7 @@

        Mirror Status Chart

        {% load cdn %}{% jquery %}{% jquery_tablesorter %} - + + +
      {{ 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 }}