summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/templatetags/package_extras.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index 9daecd96..1aedf677 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -9,6 +9,7 @@ from django.utils.html import escape
register = template.Library()
+
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
@@ -16,6 +17,7 @@ def link_encode(url, query):
data = urlencode(query).replace('&', '&')
return "%s?%s" % (url, data)
+
@register.filter
def url_unquote(original_url):
try:
@@ -27,6 +29,7 @@ def url_unquote(original_url):
except UnicodeError:
return original_url
+
class BuildQueryStringNode(template.Node):
def __init__(self, sortfield):
self.sortfield = sortfield
@@ -34,7 +37,7 @@ class BuildQueryStringNode(template.Node):
def render(self, context):
qs = parse_qs(context['current_query'])
- if qs.has_key('sort') and self.sortfield in qs['sort']:
+ if 'sort' in qs and self.sortfield in qs['sort']:
if self.sortfield.startswith('-'):
qs['sort'] = [self.sortfield[1:]]
else:
@@ -43,6 +46,7 @@ class BuildQueryStringNode(template.Node):
qs['sort'] = [self.sortfield]
return urlencode(qs, True).replace('&', '&')
+
@register.tag(name='buildsortqs')
def do_buildsortqs(parser, token):
try:
@@ -55,15 +59,18 @@ def do_buildsortqs(parser, token):
"%r tag's argument should be in quotes" % tagname)
return BuildQueryStringNode(sortfield[1:-1])
+
@register.simple_tag
def pkg_details_link(pkg):
link = '<a href="%s" title="View package details for %s">%s</a>'
return link % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname)
+
@register.simple_tag
def multi_pkg_details(pkgs):
return ', '.join([pkg_details_link(pkg) for pkg in pkgs])
+
@register.simple_tag
def maintainer_link(user):
if user:
@@ -76,6 +83,7 @@ def maintainer_link(user):
)
return ''
+
@register.simple_tag
def packager_link(user):
if user:
@@ -97,6 +105,7 @@ def scm_link(package, operation):
"h=packages/%s")
return linkbase % tuple(urlquote(part) for part in parts)
+
@register.simple_tag
def get_wiki_link(package):
url = "https://wiki.archlinux.org/index.php/Special:Search"
@@ -105,6 +114,7 @@ def get_wiki_link(package):
}
return link_encode(url, data)
+
@register.simple_tag
def bugs_list(package):
url = "https://bugs.archlinux.org/"
@@ -115,6 +125,7 @@ def bugs_list(package):
}
return link_encode(url, data)
+
@register.simple_tag
def bug_report(package):
url = "https://bugs.archlinux.org/newtask"