bodhi/model.py | 11 +++++++----
bodhi/templates/show.kid | 1 -
bodhi/util.py | 8 ++++++++
3 files changed, 15 insertions(+), 5 deletions(-)
New commits:
commit 464646878f88dd83acbb6e0ef6434798e950670c
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Aug 10 16:00:25 2010 -0400
Improve how we link up bug numbers and URLs in comments
diff --git a/bodhi/model.py b/bodhi/model.py
index ab58618..bd9f785 100644
--- a/bodhi/model.py
+++ b/bodhi/model.py
@@ -21,6 +21,7 @@ import turbomail
import xmlrpclib
from kid import XML
+from kid.element import encode_entity
from sqlobject import *
from datetime import datetime
@@ -39,7 +40,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.util import link, isint
from bodhi.exceptions import RPMNotFound, InvalidRequest
from bodhi.identity.tables import *
@@ -1086,12 +1087,14 @@ class Comment(SQLObject):
@property
def html_text(self):
- text = self.text
+ text = encode_entity(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))
+ elif token.startswith('#') and isint(token[1:]):
+ text = text.replace(token, link(token, config.get('bz_buglink') +
token[1:]))
+ elif len(token) == 6 and isint(token):
+ text = text.replace(token, link(token, config.get('bz_buglink') +
token))
return XML(text)
def __str__(self):
diff --git a/bodhi/templates/show.kid b/bodhi/templates/show.kid
index cc2e12c..0729ec1 100644
--- a/bodhi/templates/show.kid
+++ b/bodhi/templates/show.kid
@@ -251,7 +251,6 @@ karma = "<img src=\"%s\" align=\"top\"
/> <b>%d</b>" % (tg.url('/static/images/k
<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.html_text">Comment</div>
- <br/><br/>
</div>
</div>
<div py:if="not update.comments">
diff --git a/bodhi/util.py b/bodhi/util.py
index ae70da6..508e3b4 100644
--- a/bodhi/util.py
+++ b/bodhi/util.py
@@ -522,3 +522,11 @@ def url(*args, **kw):
return csrf_url(*args, **kw)
else:
return tg_url(*args, **kw)
+
+
+def isint(num):
+ try:
+ int(num)
+ return True
+ except ValueError:
+ return False
Show replies by date