bodhi/config/app.cfg | 2 ++ bodhi/model.py | 12 ++++++++++++ bodhi/templates/show.kid | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-)
New commits: commit fb2a815fdfe44721d3547f3360a5adfc91586ea8 Author: Luke Macken lmacken@redhat.com Date: Tue Aug 10 15:30:23 2010 -0400
Link up bugzilla numbers and URLs in bodhi comments
diff --git a/bodhi/config/app.cfg b/bodhi/config/app.cfg index e4f9e7a..7498ac0 100644 --- a/bodhi/config/app.cfg +++ b/bodhi/config/app.cfg @@ -138,6 +138,8 @@ bz_cookie = None # Bodhi will avoid touching bugs that are not against the following products bz_products = 'Fedora,Fedora EPEL'
+bz_buglink = 'https://bugzilla.redhat.com/show_bug.cgi?id=' + ## ## Packages that should suggest a reboot ## diff --git a/bodhi/model.py b/bodhi/model.py index 65f8ec3..ab58618 100644 --- a/bodhi/model.py +++ b/bodhi/model.py @@ -20,6 +20,7 @@ import bugzilla import turbomail import xmlrpclib
+from kid import XML from sqlobject import * from datetime import datetime
@@ -38,6 +39,7 @@ except ImportError: from bodhi import buildsys, mail from bodhi.util import get_nvr, rpm_fileheader, header, get_age, get_age_in_days from bodhi.util import Singleton, authorized_user, flash_log, build_evr, url +from bodhi.util import link from bodhi.exceptions import RPMNotFound, InvalidRequest from bodhi.identity.tables import *
@@ -1082,6 +1084,16 @@ class Comment(SQLObject): text = UnicodeCol() anonymous = BoolCol(default=False)
+ @property + def html_text(self): + text = self.text + for token in text.split(): + if token.startswith('http://'): + text = text.replace(token, link(token, token)) + for bug in re.findall(r'bug #*(\d+)', text, re.I): + text = text.replace(bug, link(bug, config.get('bz_buglink') + bug)) + return XML(text) + def __str__(self): karma = '0' if self.karma != 0: diff --git a/bodhi/templates/show.kid b/bodhi/templates/show.kid index 2470e92..cc2e12c 100644 --- a/bodhi/templates/show.kid +++ b/bodhi/templates/show.kid @@ -250,7 +250,8 @@ karma = "<img src="%s" align="top" /> <b>%d</b>" % (tg.url('/static/images/k <div py:if="not comment.anonymous"> <b><a href="${tg.url('/user/%s' % comment.author.split(' (')[0])}">${comment.author}</a></b> - ${comment.timestamp}<br/> </div> - <div class="comment-text" py:replace="comment.text">Comment</div> + <div class="comment-text" py:replace="comment.html_text">Comment</div> + <br/><br/> </div> </div> <div py:if="not update.comments">