From fff9cf9c5537d9f758a9e30fcb18df800c70f051 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 18 Oct 2014 15:17:56 -0500 Subject: Convert bulk of package details page to Jinja2 We wrap the whole thing in a Django template so we don't have to convert our base template to Jinja2 (or have one for each templating engine). This also simplifies the static stuff so we can just keep using the Django tags. Signed-off-by: Dan McGee --- packages/templatetags/package_extras.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'packages') diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py index 2784546d..f6d6ee73 100644 --- a/packages/templatetags/package_extras.py +++ b/packages/templatetags/package_extras.py @@ -6,6 +6,9 @@ from django import template from django.utils.html import escape +from django_jinja import library + +from main.templatetags import pgp register = template.Library() @@ -14,11 +17,11 @@ def link_encode(url, query): # massage the data into all utf-8 encoded strings first, so urlencode # doesn't barf at the data we pass it query = {k: unicode(v).encode('utf-8') for k, v in query.items()} - data = urlencode(query).replace('&', '&') + data = urlencode(query) return "%s?%s" % (url, data) -@register.filter +@library.filter def url_unquote(original_url): try: url = original_url @@ -79,7 +82,7 @@ def pkg_details_link(pkg, link_title=None, honor_flagged=False): return link % (pkg.get_absolute_url(), pkg.pkgname, link_content) -@register.simple_tag +@library.global_function def maintainer_link(user): if user: # TODO don't hardcode @@ -92,7 +95,7 @@ def maintainer_link(user): return '' -@register.simple_tag +@library.global_function def packager_link(user): if user: # TODO don't hardcode @@ -105,7 +108,12 @@ def packager_link(user): return '' -@register.simple_tag +@library.global_function +def pgp_key_link(key_id, link_text=None): + return pgp.pgp_key_link(key_id, link_text) + + +@library.global_function def scm_link(package, operation): parts = (package.repo.svn_root, operation, package.pkgbase) linkbase = ( @@ -114,8 +122,8 @@ def scm_link(package, operation): return linkbase % tuple(urlquote(part.encode('utf-8')) for part in parts) -@register.simple_tag -def get_wiki_link(package): +@library.global_function +def wiki_link(package): url = "https://wiki.archlinux.org/index.php/Special:Search" data = { 'search': package.pkgname, @@ -123,7 +131,7 @@ def get_wiki_link(package): return link_encode(url, data) -@register.simple_tag +@library.global_function def bugs_list(package): url = "https://bugs.archlinux.org/" data = { @@ -134,7 +142,7 @@ def bugs_list(package): return link_encode(url, data) -@register.simple_tag +@library.global_function def bug_report(package): url = "https://bugs.archlinux.org/newtask" data = { -- cgit v1.2.3-54-g00ecf