# HG changeset patch # User Mads Kiilerich # Date 2014-07-04 12:12:07 # Node ID 4a91848040891e276cb336351a14497dd612edc3 # Parent b60e58094fb7c5ad6971de63273cbdf3428e6725 comments: linkify revision hashes and issue tracker references This was hard with RST markup - much easier to do reasonably safely in plain text. diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -1402,9 +1402,10 @@ def _mentions_replace(match_obj): return '@%s' % match_obj.group(1) -def render_w_mentions(source): +def render_w_mentions(source, repo_name=None): """ - Render plain text with @mention highlighting. + Render plain text with revision hashes and issue references urlified + and with @mention highlighting. """ s = source.rstrip() s = safe_unicode(s) @@ -1413,6 +1414,9 @@ def render_w_mentions(source): # this sequence of html-ifications seems to be safe and non-conflicting # if the issues regexp is sane s = _urlify_text(s) + if repo_name is not None: + s = urlify_changesets(s, repo_name) + s = urlify_issues(s, repo_name) s = MENTIONS_REGEX.sub(_mentions_replace, s) return literal('%s' % s) diff --git a/kallithea/model/notification.py b/kallithea/model/notification.py --- a/kallithea/model/notification.py +++ b/kallithea/model/notification.py @@ -59,7 +59,7 @@ class NotificationModel(BaseModel): def create(self, created_by, subject, body, recipients=None, type_=Notification.TYPE_MESSAGE, with_email=True, - email_kwargs=None): + email_kwargs=None, repo_name=None): """ Creates notification of given type @@ -123,7 +123,7 @@ class NotificationModel(BaseModel): ## this is passed into template html_kwargs = { 'subject': subject, - 'body': h.render_w_mentions(body), + 'body': h.render_w_mentions(body, repo_name), 'when': h.fmt_date(notif.created_on), 'user': notif.created_by_user.username, } diff --git a/kallithea/templates/changeset/changeset_file_comment.html b/kallithea/templates/changeset/changeset_file_comment.html --- a/kallithea/templates/changeset/changeset_file_comment.html +++ b/kallithea/templates/changeset/changeset_file_comment.html @@ -40,7 +40,7 @@ %endif %if co.text: - ${h.render_w_mentions(co.text)|n} + ${h.render_w_mentions(co.text, c.repo_name)|n} %endif