From 1bf6358b94d0466cd0ab0e5ef47bd45d770e477e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 5 Nov 2014 22:39:21 -0600 Subject: Always link to torrent and magnet, even if not available We were already doing this on the details page; no need to hide it on the listing page. Signed-off-by: Dan McGee --- templates/releng/release_list.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/releng/release_list.html b/templates/releng/release_list.html index be257f9e..5c8e003a 100644 --- a/templates/releng/release_list.html +++ b/templates/releng/release_list.html @@ -31,9 +31,9 @@

Releases

{{ item.version }} {{ item.kernel_version|default:"" }} {{ item.available|yesno|capfirst }} - {% if item.available %}Torrent{% endif %} - {% if item.available %}Magnet{% endif %} + Torrent + Magnet {% if item.torrent_data %}{{ item.torrent.file_length|filesizeformat }}{% endif %} {% endfor %} -- cgit v1.2.3-54-g00ecf From 935d801615dd320693d4c85359aab9f12bd91b14 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 5 Nov 2014 23:02:24 -0600 Subject: Add icons, more detail to releases pages Signed-off-by: Dan McGee --- sitestatic/download.png | Bin 0 -> 1155 bytes sitestatic/magnet.png | Bin 0 -> 2382 bytes templates/releng/release_detail.html | 15 ++++++++++----- templates/releng/release_list.html | 25 +++++++++++++++++++------ 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 sitestatic/download.png create mode 100644 sitestatic/magnet.png (limited to 'templates') diff --git a/sitestatic/download.png b/sitestatic/download.png new file mode 100644 index 00000000..9ab858c2 Binary files /dev/null and b/sitestatic/download.png differ diff --git a/sitestatic/magnet.png b/sitestatic/magnet.png new file mode 100644 index 00000000..f67e69b9 Binary files /dev/null and b/sitestatic/magnet.png differ diff --git a/templates/releng/release_detail.html b/templates/releng/release_detail.html index 5cd1c432..11155c0c 100644 --- a/templates/releng/release_detail.html +++ b/templates/releng/release_detail.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load static %} {% block title %}Arch Linux - Release: {{ release.version }}{% endblock %} @@ -9,11 +10,15 @@

{{ release.version }}

  • Release Date: {{ release.release_date|date }}
  • {% if release.kernel_version %}
  • Kernel Version: {{ release.kernel_version }}
  • {% endif %} -
  • Available: {{ release.available|yesno }}
  • - {% if release.torrent_data %}
  • Download: Torrent, - Magnet
  • {% endif %} +
  • Available: {{ release.available|yesno|capfirst }}
  • + {% if release.torrent_data %} +
  • + Download via Torrent
  • +
  • + Download via Magnet URI
  • + {% endif %} {% if release.md5_sum %}
  • MD5: {{ release.md5_sum }}
  • {% endif %} {% if release.sha1_sum %}
  • SHA1: {{ release.sha1_sum }}
  • {% endif %}
diff --git a/templates/releng/release_list.html b/templates/releng/release_list.html index 5c8e003a..fa15bcb9 100644 --- a/templates/releng/release_list.html +++ b/templates/releng/release_list.html @@ -12,28 +12,41 @@

Releases

+

This is a list of ISO releases made by the Arch Linux release + engineering team. These are typically done on a monthly cadence, containing + the latest kernel and base packages from the package repositories. Click + the version of each release to read any additional notes or details about + each release.

+

Torrents and magnet URIs are available to download the releases. + Releases listed as not available may still be seeded by peers, but are no + longer registered via the official Arch Linux torrent tracker. We always + recommend running the latest available release.

+ + - - {% for item in release_list %} + - - {% endfor %} @@ -50,7 +63,7 @@

Releases

$(".results").tablesorter({ widgets: ['zebra'], sortList: [[0,1], [1,1]], - headers: { 4: { sorter: false }, 5: { sorter: false } } + headers: { 0: { sorter: false } } }); }); -- cgit v1.2.3-54-g00ecf From 9b5eb6ab383dcd090cdbf88a250ecdfd407c3beb Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 5 Nov 2014 23:03:43 -0600 Subject: Add torrent/magnet icons to download page Signed-off-by: Dan McGee --- templates/public/download.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/templates/public/download.html b/templates/public/download.html index 967d8a6e..cbd7cd73 100644 --- a/templates/public/download.html +++ b/templates/public/download.html @@ -59,9 +59,9 @@

BitTorrent Download (recommended)

{% if release %}{% endif %}

Netboot

-- cgit v1.2.3-54-g00ecf From cd22bfd73b184888df13b194ecdf6e482b36c3fc Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 7 Nov 2014 09:27:56 -0600 Subject: Master signing keys page improvements * Don't show non-packagers * Don't hardcode group names in view code * Reduce number of database queries for all of the cross-signature developer name lookups Signed-off-by: Dan McGee --- main/templatetags/pgp.py | 19 ++++++------------- public/views.py | 37 ++++++++++++++++++++++--------------- templates/public/keys.html | 4 ++-- visualize/static/visualize.js | 5 ++--- 4 files changed, 32 insertions(+), 33 deletions(-) (limited to 'templates') diff --git a/main/templatetags/pgp.py b/main/templatetags/pgp.py index 2417f688..455e8f9c 100644 --- a/main/templatetags/pgp.py +++ b/main/templatetags/pgp.py @@ -44,21 +44,14 @@ def pgp_key_link(key_id, link_text=None): return '%s' % values -@cache_function(1741) -def name_for_key(normalized): - try: - matching_key = DeveloperKey.objects.select_related( - 'owner').get(key=normalized, owner_id__isnull=False) - return matching_key.owner.get_full_name() - except DeveloperKey.DoesNotExist: - return None - - @register.simple_tag -def user_pgp_key_link(key_id): +def user_pgp_key_link(dev_keys, key_id): normalized = key_id[-16:] - name = name_for_key(normalized) - return pgp_key_link(key_id, name) + found = dev_keys.get(normalized, None) + if found: + return pgp_key_link(key_id, found.owner.get_full_name()) + else: + return pgp_key_link(key_id, None) @register.filter(needs_autoescape=True) diff --git a/public/views.py b/public/views.py index 118f067a..c0dae400 100644 --- a/public/views.py +++ b/public/views.py @@ -9,7 +9,7 @@ from django.shortcuts import get_object_or_404, render from django.views.decorators.cache import cache_control, cache_page -from devel.models import MasterKey, PGPSignature, StaffGroup +from devel.models import MasterKey, DeveloperKey, PGPSignature, StaffGroup, UserProfile from main.models import Arch, Repo, Donor from mirrors.models import MirrorUrl from news.models import News @@ -91,7 +91,9 @@ def feeds(request): @cache_control(max_age=307) def keys(request): - users = User.objects.filter(is_active=True).select_related( + profile_ids = UserProfile.allowed_repos.through.objects.values('userprofile_id') + users = User.objects.filter( + is_active=True, userprofile__id__in=profile_ids).select_related( 'userprofile__pgp_key').order_by('first_name', 'last_name') user_key_ids = frozenset(user.userprofile.pgp_key[-16:] for user in users if user.userprofile.pgp_key) @@ -114,34 +116,39 @@ def keys(request): not_expired, revoked__isnull=True).values_list('signer', 'signee')) restrict = Q(signer__in=user_key_ids) & Q(signee__in=user_key_ids) - cross_signatures = PGPSignature.objects.filter(restrict, + cross_signatures = PGPSignature.objects.filter( not_expired, revoked__isnull=True).order_by('created') + # filter in python so we aren't sending a crazy long query to the DB + cross_signatures = [s for s in cross_signatures + if s.signer in user_key_ids and s.signee in user_key_ids] + + developer_keys = DeveloperKey.objects.select_related( + 'owner').filter(owner__isnull=False) + developer_keys = {key.key[-16:]: key for key in developer_keys} context = { 'keys': master_keys, 'active_users': users, 'signatures': signatures, 'cross_signatures': cross_signatures, + 'developer_keys': developer_keys, } return render(request, 'public/keys.html', context) @cache_page(1789) def keys_json(request): - node_list = [] + profile_ids = UserProfile.allowed_repos.through.objects.values('userprofile_id') + users = User.objects.filter( + is_active=True, userprofile__id__in=profile_ids).select_related( + 'userprofile__pgp_key').order_by('first_name', 'last_name') users = User.objects.filter(is_active=True).select_related('userprofile') - node_list.extend({ - 'name': dev.get_full_name(), - 'key': dev.userprofile.pgp_key, - 'group': 'dev' - } for dev in users.filter(groups__name='Developers')) - node_list.extend({ - 'name': tu.get_full_name(), - 'key': tu.userprofile.pgp_key, - 'group': 'tu' - } for tu in users.filter(groups__name='Trusted Users').exclude( - groups__name='Developers')) + node_list = [{ + 'name': user.get_full_name(), + 'key': user.userprofile.pgp_key, + 'group': 'packager' + } for user in users] master_keys = MasterKey.objects.select_related('owner').filter( revoked__isnull=True) diff --git a/templates/public/keys.html b/templates/public/keys.html index 54d52ab8..37d5b232 100644 --- a/templates/public/keys.html +++ b/templates/public/keys.html @@ -123,8 +123,8 @@

Developer Cross-Signatures

{% for sig in cross_signatures %} - - + + diff --git a/visualize/static/visualize.js b/visualize/static/visualize.js index 5004fe6c..5254c26b 100644 --- a/visualize/static/visualize.js +++ b/visualize/static/visualize.js @@ -175,7 +175,7 @@ function developer_keys(chart_id, data_url) { } }); jQuery.map(json.nodes, function(d, i) { - if (d.group === "dev" || d.group === "tu") { + if (d.group === "packager") { d.approved = d.master_sigs >= 3; } else { d.approved = null; @@ -200,8 +200,7 @@ function developer_keys(chart_id, data_url) { return r * 1.6 - 0.75; case "cacert": return r * 1.4 - 0.75; - case "dev": - case "tu": + case "packager": default: return r - 0.75; } -- cgit v1.2.3-54-g00ecf From eb7172cd4d9d7af690b2be06e3f925d3023be71c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 13:43:59 -0600 Subject: Convert some of URL details to Jinja2 Anytime we have a loop with >100 items, the Django template engine begins to be the bottleneck. This one is relatively straightforward to convert, and sets the stage for converting the mirror status page as well. Signed-off-by: Dan McGee --- mirrors/templatetags/jinja2.py | 31 +++++++++++++++++++++++++++ packages/templatetags/jinja2.py | 1 - templates/mirrors/url_details.html | 29 +------------------------ templates/mirrors/url_details_logs.html.jinja | 28 ++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 mirrors/templatetags/jinja2.py create mode 100644 templates/mirrors/url_details_logs.html.jinja (limited to 'templates') diff --git a/mirrors/templatetags/jinja2.py b/mirrors/templatetags/jinja2.py new file mode 100644 index 00000000..5d47fe9b --- /dev/null +++ b/mirrors/templatetags/jinja2.py @@ -0,0 +1,31 @@ +from django_jinja import library +from markupsafe import Markup + + +@library.global_function +def country_flag(country): + if not country: + return '' + html = ' ' % ( + unicode(country.code).lower(), unicode(country.name)) + return Markup(html) + + +@library.filter +def duration(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) + return '%d:%02d' % (hrs, mins) + + +@library.filter +def floatvalue(value, arg=2): + if value is None: + return u'' + return '%.*f' % (arg, value) + +# vim: set ts=4 sw=4 et: diff --git a/packages/templatetags/jinja2.py b/packages/templatetags/jinja2.py index 22f9914b..88b59a96 100644 --- a/packages/templatetags/jinja2.py +++ b/packages/templatetags/jinja2.py @@ -68,5 +68,4 @@ def bug_report(package): } return link_encode(url, data) - # vim: set ts=4 sw=4 et: diff --git a/templates/mirrors/url_details.html b/templates/mirrors/url_details.html index 557a1b79..8b7646b8 100644 --- a/templates/mirrors/url_details.html +++ b/templates/mirrors/url_details.html @@ -1,5 +1,4 @@ {% extends "base.html" %} -{% load cycle from future %} {% load static from staticfiles %} {% load mirror_status %} {% load flags %} @@ -57,34 +56,8 @@

URL Details: {{ url.url }}

{% endif %}
Release Date Version Kernel Version Available?TorrentMagnet Download Size
{% if item.torrent_data %} + Torrent +   + Magnet + {% endif %} {{ item.release_date|date }} {{ item.version }} {{ item.kernel_version|default:"" }} {{ item.available|yesno|capfirst }}TorrentMagnet {% if item.torrent_data %}{{ item.torrent.file_length|filesizeformat }}{% endif %}
{% user_pgp_key_link sig.signer %}{% user_pgp_key_link sig.signee %}{% user_pgp_key_link developer_keys sig.signer %}{% user_pgp_key_link developer_keys sig.signee %} {{ sig.created }} {{ sig.expires|default:"" }}
-

Check Logs

+ {% include "mirrors/url_details_logs.html.jinja" %} - - - - - - - - - - - - - - - {% for log in logs %} - - - - - - - - - {% endfor %} - -
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date:'Y-m-d H:i' }}{% country_flag log.location.country %}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date:'Y-m-d H:i' }}{{ log.delay|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
{% endblock %} diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja new file mode 100644 index 00000000..8f7c5644 --- /dev/null +++ b/templates/mirrors/url_details_logs.html.jinja @@ -0,0 +1,28 @@ +

Check Logs

+ + + + + + + + + + + + + + + + {% for log in logs %} + + + + + + + + + {% endfor %} + +
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date('Y-m-d H:i') }}{{ country_flag(log.location.country) }}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date('Y-m-d H:i') }}{{ log.delay()|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
-- cgit v1.2.3-54-g00ecf From 713ab837ba59c4a7c0b60cb8e8be4b27f4520e52 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 14:00:06 -0600 Subject: Convert mirror status tables to Jinja2 Yay for way improved performance. Local testing showed render times going from 265 ms to 135 ms. Signed-off-by: Dan McGee --- mirrors/templatetags/jinja2.py | 22 ++++++++++++++++++++++ templates/mirrors/error_table.html | 24 ------------------------ templates/mirrors/error_table.html.jinja | 22 ++++++++++++++++++++++ templates/mirrors/mirror_details.html | 2 +- templates/mirrors/status.html | 6 +++--- templates/mirrors/status_table.html | 30 ------------------------------ templates/mirrors/status_table.html.jinja | 28 ++++++++++++++++++++++++++++ 7 files changed, 76 insertions(+), 58 deletions(-) delete mode 100644 templates/mirrors/error_table.html create mode 100644 templates/mirrors/error_table.html.jinja delete mode 100644 templates/mirrors/status_table.html create mode 100644 templates/mirrors/status_table.html.jinja (limited to 'templates') 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 deleted file mode 100644 index cd7265af..00000000 --- a/templates/mirrors/error_table.html +++ /dev/null @@ -1,24 +0,0 @@ -{% load cycle from future %} -{% load flags mirror_status %} - - - - - - - - - - - - - {% for log in error_logs %} - - - - - - - {% endfor %} - -
Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
{{ log.url__url }}{{ log.url__protocol__protocol }}{% 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/error_table.html.jinja b/templates/mirrors/error_table.html.jinja new file mode 100644 index 00000000..52f68135 --- /dev/null +++ b/templates/mirrors/error_table.html.jinja @@ -0,0 +1,22 @@ + + + + + + + + + + + + + {% for log in error_logs %} + + + + + + + {% endfor %} + +
Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
{{ log.url__url }}{{ log.url__protocol__protocol }}{{ 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/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 %} - - - - - - - - - - - - - - - - {% for m_url in urls %} - - - - - - - - - - {% endfor %} - -
Mirror URLProtocolCountryCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)Mirror Score
{{ 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
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 @@ + + + + + + + + + + + + + + + + {% for m_url in urls %} + + + + + + + + + + {% endfor %} + +
Mirror URLProtocolCountryCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)Mirror Score
{{ 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
-- cgit v1.2.3-54-g00ecf From 122273496a24c4608de776978b1b449d9c6cde09 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 14:04:31 -0600 Subject: Make delay a property, not a function And re-indent the URL details log template now that we've broken it out. Signed-off-by: Dan McGee --- mirrors/models.py | 1 + templates/mirrors/url_details_logs.html.jinja | 54 +++++++++++++-------------- 2 files changed, 28 insertions(+), 27 deletions(-) (limited to 'templates') diff --git a/mirrors/models.py b/mirrors/models.py index 820f3328..9743d177 100644 --- a/mirrors/models.py +++ b/mirrors/models.py @@ -165,6 +165,7 @@ class MirrorLog(models.Model): is_success = models.BooleanField(default=True) error = models.TextField(blank=True, default='') + @property def delay(self): if self.last_sync is None: return None diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja index 8f7c5644..09742f76 100644 --- a/templates/mirrors/url_details_logs.html.jinja +++ b/templates/mirrors/url_details_logs.html.jinja @@ -1,28 +1,28 @@ -

Check Logs

+

Check Logs

- - - - - - - - - - - - - - - {% for log in logs %} - - - - - - - - - {% endfor %} - -
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date('Y-m-d H:i') }}{{ country_flag(log.location.country) }}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date('Y-m-d H:i') }}{{ log.delay()|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
+ + + + + + + + + + + + + + + {% for log in logs %} + + + + + + + + + {% endfor %} + +
Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
{{ log.check_time|date('Y-m-d H:i') }}{{ country_flag(log.location.country) }}{{ log.location.country.name }}{{ log.location.source_ip }}{{ log.last_sync|date('Y-m-d H:i') }}{{ log.delay|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
-- cgit v1.2.3-54-g00ecf From 886d2934ec672e0d4533f73e8b38248fdff9a6d5 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 14:12:32 -0600 Subject: Break out available URLs into Jinja2 template Signed-off-by: Dan McGee --- templates/mirrors/mirror_details.html | 38 +----------------------- templates/mirrors/mirror_details_urls.html.jinja | 36 ++++++++++++++++++++++ templates/mirrors/url_details.html | 2 +- templates/mirrors/url_details_logs.html.jinja | 2 -- 4 files changed, 38 insertions(+), 40 deletions(-) create mode 100644 templates/mirrors/mirror_details_urls.html.jinja (limited to 'templates') diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index e4ae55b4..64009380 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -93,43 +93,7 @@

Mirror Details: {{ mirror.name }}

Available URLs

- - - - - - - - - - - - - - - - - - - - {% for m_url in urls %} - - - - - - - - - - - - - - - {% endfor %} - -
Mirror URLProtocolCountryIPv4IPv6Last SyncCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)ScoreDetails
{% if m_url.protocol.is_download %}{{ m_url.url }}{% else %}{{ m_url.url }}{% endif %}{{ m_url.protocol }}{% 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' }}{{ 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
+ {% include "mirrors/mirror_details_urls.html.jinja" %}

Error Log

{% include "mirrors/error_table.html.jinja" %} diff --git a/templates/mirrors/mirror_details_urls.html.jinja b/templates/mirrors/mirror_details_urls.html.jinja new file mode 100644 index 00000000..7ab1548b --- /dev/null +++ b/templates/mirrors/mirror_details_urls.html.jinja @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + {% for m_url in urls %} + + + + + + + + + + + + + + + {% endfor %} + +
Mirror URLProtocolCountryIPv4IPv6Last SyncCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)ScoreDetails
{% if m_url.protocol.is_download %}{{ m_url.url }}{% else %}{{ m_url.url }}{% endif %}{{ m_url.protocol }}{{ 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') }}{{ 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
diff --git a/templates/mirrors/url_details.html b/templates/mirrors/url_details.html index 8b7646b8..b61033cd 100644 --- a/templates/mirrors/url_details.html +++ b/templates/mirrors/url_details.html @@ -56,8 +56,8 @@

URL Details: {{ url.url }}

{% endif %} +

Check Logs

{% include "mirrors/url_details_logs.html.jinja" %} - {% endblock %} diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja index 09742f76..58f179d8 100644 --- a/templates/mirrors/url_details_logs.html.jinja +++ b/templates/mirrors/url_details_logs.html.jinja @@ -1,5 +1,3 @@ -

Check Logs

- -- cgit v1.2.3-54-g00ecf From a3015ba8429a09878ed6c35d7c7c76a882de7dcf Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 15:52:18 -0600 Subject: Override default sitemap.xml template The Django one uses the spaceless tag, which isn't all that useful when we are gzipping the response anyway. Remove it to make generation a tad faster. Signed-off-by: Dan McGee --- templates/sitemaps/sitemap.xml | 9 +++++++++ urls.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 templates/sitemaps/sitemap.xml (limited to 'templates') diff --git a/templates/sitemaps/sitemap.xml b/templates/sitemaps/sitemap.xml new file mode 100644 index 00000000..50a95237 --- /dev/null +++ b/templates/sitemaps/sitemap.xml @@ -0,0 +1,9 @@ + + +{% for url in urlset %} +{{ url.location }} +{% if url.lastmod %}{{ url.lastmod|date:"Y-m-d" }}{% endif %} +{% if url.changefreq %}{{ url.changefreq }}{% endif %} +{% if url.priority %}{{ url.priority }}{% endif %} +{% endfor %} + diff --git a/urls.py b/urls.py index 518e88e7..2d174012 100644 --- a/urls.py +++ b/urls.py @@ -81,7 +81,7 @@ {'sitemaps': our_sitemaps, 'sitemap_url_name': 'sitemaps'}), (r'^sitemap-(?P
.+)\.xml$', cache_page(1831)(sitemap_views.sitemap), - {'sitemaps': our_sitemaps}, 'sitemaps'), + {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml'}, 'sitemaps'), ) # Authentication / Admin -- cgit v1.2.3-54-g00ecf From 4c5b478543184ea395e0e692d3bcf666fb7513ad Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 15:58:26 -0600 Subject: Convert sitemap.xml template to Jinja2 Signed-off-by: Dan McGee --- templates/sitemaps/sitemap.xml | 9 --------- templates/sitemaps/sitemap.xml.jinja | 9 +++++++++ urls.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 templates/sitemaps/sitemap.xml create mode 100644 templates/sitemaps/sitemap.xml.jinja (limited to 'templates') diff --git a/templates/sitemaps/sitemap.xml b/templates/sitemaps/sitemap.xml deleted file mode 100644 index 50a95237..00000000 --- a/templates/sitemaps/sitemap.xml +++ /dev/null @@ -1,9 +0,0 @@ - - -{% for url in urlset %} -{{ url.location }} -{% if url.lastmod %}{{ url.lastmod|date:"Y-m-d" }}{% endif %} -{% if url.changefreq %}{{ url.changefreq }}{% endif %} -{% if url.priority %}{{ url.priority }}{% endif %} -{% endfor %} - diff --git a/templates/sitemaps/sitemap.xml.jinja b/templates/sitemaps/sitemap.xml.jinja new file mode 100644 index 00000000..0808a7de --- /dev/null +++ b/templates/sitemaps/sitemap.xml.jinja @@ -0,0 +1,9 @@ + + +{% for url in urlset %} +{{ url.location }} +{% if url.lastmod %}{{ url.lastmod|date("Y-m-d") }}{% endif %} +{% if url.changefreq %}{{ url.changefreq }}{% endif %} +{% if url.priority %}{{ url.priority }}{% endif %} +{% endfor %} + diff --git a/urls.py b/urls.py index 2d174012..6d896b3c 100644 --- a/urls.py +++ b/urls.py @@ -81,7 +81,7 @@ {'sitemaps': our_sitemaps, 'sitemap_url_name': 'sitemaps'}), (r'^sitemap-(?P
.+)\.xml$', cache_page(1831)(sitemap_views.sitemap), - {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml'}, 'sitemaps'), + {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml.jinja'}, 'sitemaps'), ) # Authentication / Admin -- cgit v1.2.3-54-g00ecf From 96a7614285325b693434f3fd011238000d75926d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 16:31:38 -0600 Subject: Add a news-specific sitemap This follows the spec at https://support.google.com/news/publisher/answer/74288?hl=en#tagdefinitions Signed-off-by: Dan McGee --- sitemaps.py | 7 +++++++ templates/sitemaps/news_sitemap.xml.jinja | 14 ++++++++++++++ urls.py | 9 ++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 templates/sitemaps/news_sitemap.xml.jinja (limited to 'templates') diff --git a/sitemaps.py b/sitemaps.py index eb4e05d9..fb81357e 100644 --- a/sitemaps.py +++ b/sitemaps.py @@ -98,6 +98,13 @@ def changefreq(self, obj): return 'yearly' +class RecentNewsSitemap(NewsSitemap): + def items(self): + now = datetime.utcnow().replace(tzinfo=utc) + cutoff = now - timedelta(days=30) + return super(RecentNewsSitemap, self).items().filter(postdate__gte=cutoff) + + class ReleasesSitemap(Sitemap): changefreq = "monthly" diff --git a/templates/sitemaps/news_sitemap.xml.jinja b/templates/sitemaps/news_sitemap.xml.jinja new file mode 100644 index 00000000..97dd17b5 --- /dev/null +++ b/templates/sitemaps/news_sitemap.xml.jinja @@ -0,0 +1,14 @@ + + +{% for url in urlset %} +{{ url.location }} +{% if url.lastmod %}{{ url.lastmod|date("Y-m-d") }}{% endif %} +{% if url.changefreq %}{{ url.changefreq }}{% endif %} +{% if url.priority %}{{ url.priority }}{% endif %} + + Arch Linux Newsen + {% if url.item.postdate %}{{ url.item.postdate|date("c") }}{% endif %} + {% if url.item.title %}{{ url.item.title }}{% endif %} + +{% endfor %} + diff --git a/urls.py b/urls.py index 6d896b3c..c35baedf 100644 --- a/urls.py +++ b/urls.py @@ -18,6 +18,8 @@ 'releases': sitemaps.ReleasesSitemap, } +news_sitemaps = { 'news': sitemaps.RecentNewsSitemap } + urlpatterns = [] # Public pages @@ -81,7 +83,12 @@ {'sitemaps': our_sitemaps, 'sitemap_url_name': 'sitemaps'}), (r'^sitemap-(?P
.+)\.xml$', cache_page(1831)(sitemap_views.sitemap), - {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml.jinja'}, 'sitemaps'), + {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml.jinja'}, + 'sitemaps'), + (r'^news-sitemap\.xml$', + cache_page(1831)(sitemap_views.sitemap), + {'sitemaps': news_sitemaps, 'template_name': 'sitemaps/news_sitemap.xml.jinja'}, + 'news-sitemap'), ) # Authentication / Admin -- cgit v1.2.3-54-g00ecf From 88a457f1c8ae057278f1a7cadb6c163183484019 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 19:14:32 -0600 Subject: Minor news listing tweaks Signed-off-by: Dan McGee --- news/urls.py | 3 +-- templates/news/list.html | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/news/urls.py b/news/urls.py index 0eec6d86..c13722d4 100644 --- a/news/urls.py +++ b/news/urls.py @@ -5,8 +5,7 @@ urlpatterns = patterns('news.views', - (r'^$', - NewsListView.as_view(), {}, 'news-list'), + (r'^$', NewsListView.as_view(), {}, 'news-list'), (r'^preview/$', 'preview'), # old news URLs, permanent redirect view so we don't break all links diff --git a/templates/news/list.html b/templates/news/list.html index 4acbc7e9..71cd3d02 100644 --- a/templates/news/list.html +++ b/templates/news/list.html @@ -10,7 +10,7 @@ {% block content %}
-

News Archives

+

Arch Linux News Archives

{% if perms.news.add_news %}
    @@ -54,6 +54,5 @@

    News Archives

{% include "news/paginator.html" %} - {% endblock %} -- cgit v1.2.3-54-g00ecf From 327bd4cfc599dbeddd501afd5221a1d2ff7eee08 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 19:15:35 -0600 Subject: Paginate the todolist listing page Signed-off-by: Dan McGee --- sitestatic/archweb.css | 11 +++++++++++ templates/todolists/list.html | 7 ++++++- todolists/urls.py | 6 +++--- todolists/views.py | 13 ++++++++----- 4 files changed, 28 insertions(+), 9 deletions(-) (limited to 'templates') diff --git a/sitestatic/archweb.css b/sitestatic/archweb.css index edabcfb7..cd46e4c0 100644 --- a/sitestatic/archweb.css +++ b/sitestatic/archweb.css @@ -655,6 +655,17 @@ div.news-article .article-info { width: 75%; } +/* todolists: list */ +.todolist-nav { + float: right; + margin-top: -2.2em; +} + + .todolist-nav .prev, + .todolist-nav .next { + margin: 0 1em; + } + /* donate: donor list */ #donor-list ul { width: 100%; diff --git a/templates/todolists/list.html b/templates/todolists/list.html index 7f0368de..983a49f0 100644 --- a/templates/todolists/list.html +++ b/templates/todolists/list.html @@ -16,7 +16,10 @@

Package Todo Lists

Todo lists are used by the developers when a rebuild of a set of packages is needed. This is common when a library has a version bump, during a toolchain rebuild, or a general cleanup of packages in the - repositories. The progress can be tracked here.

+ repositories. The progress can be tracked here, and completed todo lists + can be browsed as well.

+ + {% include "todolists/paginator.html" %} @@ -46,6 +49,8 @@

Package Todo Lists

{% endfor %}
+ + {% include "todolists/paginator.html" %} {% endblock %} diff --git a/todolists/urls.py b/todolists/urls.py index 6617d7dd..ed065f50 100644 --- a/todolists/urls.py +++ b/todolists/urls.py @@ -1,11 +1,11 @@ from django.conf.urls import patterns from django.contrib.auth.decorators import permission_required -from .views import (view_redirect, view, todolist_list, add, edit, flag, - list_pkgbases, DeleteTodolist) +from .views import (view_redirect, view, add, edit, flag, + list_pkgbases, DeleteTodolist, TodolistListView) urlpatterns = patterns('', - (r'^$', todolist_list), + (r'^$', TodolistListView.as_view(), {}, 'todolist-list'), # old todolists URLs, permanent redirect view so we don't break all links (r'^(?P\d+)/$', view_redirect), diff --git a/todolists/views.py b/todolists/views.py index c37c13f5..c781a562 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -7,7 +7,7 @@ redirect, render) from django.db import transaction from django.views.decorators.cache import never_cache -from django.views.generic import DeleteView +from django.views.generic import DeleteView, ListView from django.template import Context, loader from django.utils.timezone import now @@ -91,10 +91,13 @@ def list_pkgbases(request, slug, svn_root): return HttpResponse('\n'.join(pkgbases), content_type='text/plain') -def todolist_list(request): - incomplete_only = request.user.is_anonymous() - lists = get_annotated_todolists(incomplete_only) - return render(request, 'todolists/list.html', {'lists': lists}) +class TodolistListView(ListView): + context_object_name = "lists" + template_name = "todolists/list.html" + paginate_by = 50 + + def get_queryset(self): + return get_annotated_todolists() @never_cache -- cgit v1.2.3-54-g00ecf From e5fc7cd53f6082f2911bc6c8cf8ea4f4ca4addc8 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 8 Nov 2014 19:41:21 -0600 Subject: Add paginator template for todolists Signed-off-by: Dan McGee --- templates/todolists/paginator.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 templates/todolists/paginator.html (limited to 'templates') diff --git a/templates/todolists/paginator.html b/templates/todolists/paginator.html new file mode 100644 index 00000000..3b077419 --- /dev/null +++ b/templates/todolists/paginator.html @@ -0,0 +1,22 @@ +{% if is_paginated %} + +{% endif %} -- cgit v1.2.3-54-g00ecf From 0fc409ef089ed35f545d0f9fdef53f42bbe5be50 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 2 Dec 2014 15:13:24 -0600 Subject: Make dev stats section look better when loading Signed-off-by: Dan McGee --- templates/devel/index.html | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/devel/index.html b/templates/devel/index.html index 147917a0..e9330734 100644 --- a/templates/devel/index.html +++ b/templates/devel/index.html @@ -157,8 +157,11 @@

Developer Reports

{# #dev-dashboard #} -
-

Enable Javascript to get more useful info here.

+
+
+

Developer Stats

+

Enable JavaScript to get more useful info here.

+
{% endblock %} @@ -167,8 +170,12 @@

Developer Reports