summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-11-17 13:32:42 -0600
committerDan McGee <dan@archlinux.org>2011-11-17 13:32:42 -0600
commitf43a33ed8696d7bcb987d4878c6411c5d16846d6 (patch)
tree2f3553e5190f7d390a108ec20c1ebcd92ea74224
parent3a0e55a1de6fb42aaa0deece68cccba8ebb83cc8 (diff)
Display package URLs unquoted if possible
Example: kbd-ru-keymaps. Before: http://wiki.archlinux.org/index.php/%D0%98%D0%BD%D1%82%D0%B5%D1%80%D0%BD%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%B0%D0%BB%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F After: http://wiki.archlinux.org/index.php/Интернационализация Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/templatetags/package_extras.py13
-rw-r--r--templates/packages/details.html2
2 files changed, 13 insertions, 2 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index 01bf7510..67c7fbbc 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -1,4 +1,4 @@
-from urllib import urlencode, quote as urlquote
+from urllib import urlencode, quote as urlquote, unquote
try:
from urlparse import parse_qs
except ImportError:
@@ -13,6 +13,17 @@ def link_encode(url, query, doseq=False):
data = urlencode(query, doseq).replace('&', '&amp;')
return "%s?%s" % (url, data)
+@register.filter
+def url_unquote(original_url):
+ try:
+ url = original_url
+ if isinstance(url, unicode):
+ url = url.encode('ascii')
+ url = unquote(url).decode('utf-8')
+ return url
+ except UnicodeError:
+ return original_url
+
class BuildQueryStringNode(template.Node):
def __init__(self, sortfield):
self.sortfield = sortfield
diff --git a/templates/packages/details.html b/templates/packages/details.html
index 2998592f..a9908012 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -108,7 +108,7 @@
</tr><tr>
<th>Upstream URL:</th>
<td>{% if pkg.url %}<a href="{{ pkg.url }}"
- title="Visit the website for {{ pkg.pkgname }}">{{ pkg.url }}</a>{% endif %}</td>
+ title="Visit the website for {{ pkg.pkgname }}">{{ pkg.url|url_unquote }}</a>{% endif %}</td>
</tr><tr>
<th>License(s):</th>
<td>{{ pkg.licenses.all|join:", " }}</td>