Gentoo Archives: gentoo-commits

From: Slava Bacherikov <slava@××××××××××××××.ua>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/templatetags/, ...
Date: Mon, 30 Jul 2012 13:00:00
Message-Id: 1343653137.1563cf9940f432bf754b61cdd279991919d7f6d8.bacher09@gentoo
1 commit: 1563cf9940f432bf754b61cdd279991919d7f6d8
2 Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
3 AuthorDate: Mon Jul 30 12:58:57 2012 +0000
4 Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
5 CommitDate: Mon Jul 30 12:58:57 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=1563cf99
7
8 Add changelog to package view
9
10 ---
11 gpackages/apps/packages/templatetags/packages.py | 5 +++++
12 .../generic_metadata/changelog_highlight.py | 9 +++++++++
13 gpackages/templates/package.html | 5 +++++
14 3 files changed, 19 insertions(+), 0 deletions(-)
15
16 diff --git a/gpackages/apps/packages/templatetags/packages.py b/gpackages/apps/packages/templatetags/packages.py
17 index da277d9..764f5ab 100644
18 --- a/gpackages/apps/packages/templatetags/packages.py
19 +++ b/gpackages/apps/packages/templatetags/packages.py
20 @@ -1,6 +1,7 @@
21 from django.utils.safestring import mark_safe
22 from django import template
23 from django.core.cache import cache
24 +from package_info.generic_metadata.changelog_highlight import changelog_highlight
25
26 register = template.Library()
27
28 @@ -39,6 +40,10 @@ def text_sincode(text):
29 text_l = map(lambda x: '&#%s;' % ord(x), text)
30 return mark_safe(''.join(text_l))
31
32 +@××××××××.filter('changelog_highlight')
33 +def changelog_highlight_filter(text):
34 + return mark_safe(changelog_highlight(text))
35 +
36 register.filter('obfuscate', text_sincode)
37
38 def recent_ebuilds_cache_key(num = 10):
39
40 diff --git a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
41 index 61ea5e1..b3d996e 100644
42 --- a/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
43 +++ b/gpackages/libs/package_info/generic_metadata/changelog_highlight.py
44 @@ -9,6 +9,8 @@ import re
45 DATE_RE = r'\d\d? [A-Z][a-z]{2} \d{4}'
46 EMAIL_RE = r'[\w\.\-\+]+@(?:[\w\-]+\.)+\w+'
47 LINK_RE = r'https?:\/\/(?:[\w\-]+\.)+\w+(:?\/[\w\/\.\-\_\+\&\%]+)?'
48 +BUG_NUM_RE = r'(\d+)'
49 +bugnum_re = re.compile(BUG_NUM_RE)
50
51 ARCHES = [ u'alpha', u'amd64', u'amd64-fbsd', u'amd64-linux', u'arm',
52 u'arm-linux', u'hppa', u'hppa-hpux', u'ia64', u'ia64-hpux',
53 @@ -153,6 +155,13 @@ class ChangelogHtmlFormater(HtmlFormatter):
54 def token_decorate(self, token, value):
55 if token == Link:
56 value = '<a href="{0}" rel="nofollow">{0}</a>'.format(value)
57 + elif token == Bug:
58 + num_m = bugnum_re.search(value)
59 + bugs_url_template = "https://bugs.gentoo.org/{0}"
60 + if num_m is not None:
61 + num = num_m.group()
62 + link = bugs_url_template.format(num)
63 + value = '<a href="{1}" class="defcolor">{0}</a>'.format(value, link)
64 return value
65
66 class ChangelogStyle(Style):
67
68 diff --git a/gpackages/templates/package.html b/gpackages/templates/package.html
69 index 9023001..fcc03e3 100644
70 --- a/gpackages/templates/package.html
71 +++ b/gpackages/templates/package.html
72 @@ -1,5 +1,10 @@
73 {% extends "base.html" %}
74 +{% load packages %}
75
76 {% block content %}
77 {% include 'package_object.html' %}
78 + <div class="changelog">
79 + <h4>Changelog</h4>
80 + {{ package.changelog|changelog_highlight }}
81 + </div>
82 {% endblock content %}