1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
from urllib.parse import urlencode, quote as urlquote, unquote
from django import template
from main.templatetags import pgp
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
query = {k: str(v).encode('utf-8') for k, v in query.items()}
data = urlencode(query)
return "%s?%s" % (url, data)
@register.inclusion_tag('packages/details_link.html')
def details_link(pkg):
return {'pkg': pkg}
@register.simple_tag
def scm_link(package, operation):
parts = (package.repo.svn_root, operation, package.pkgbase)
linkbase = ("https://github.com/archlinux/svntogit-%s/%s/master/%s/trunk")
return linkbase % tuple(urlquote(part.encode('utf-8')) for part in parts)
@register.simple_tag
def bugs_list(package):
url = "https://bugs.archlinux.org/"
data = {
'project': package.repo.bugs_project,
'string': package.pkgname,
}
return link_encode(url, data)
@register.simple_tag
def bug_report(package):
url = "https://bugs.archlinux.org/newtask"
data = {
'project': package.repo.bugs_project,
'product_category': package.repo.bugs_category,
'item_summary': '[%s] PLEASE ENTER SUMMARY' % package.pkgname,
}
return link_encode(url, data)
@register.simple_tag
def wiki_link(package):
url = "https://wiki.archlinux.org/index.php/Special:Search"
data = {
'search': package.pkgname,
}
return link_encode(url, data)
@register.simple_tag
def sec_link(package):
url = "https://security.archlinux.org/package/{}"
return url.format(package.pkgname)
@register.simple_tag
def pgp_key_link(key_id, link_text=None):
return pgp.pgp_key_link(key_id, link_text)
@register.filter
def url_unquote(original_url):
return unquote(original_url)
# vim: set ts=4 sw=4 et:
|