changeset 5663:4a9184804089

comments: linkify revision hashes and issue tracker references This was hard with RST markup - much easier to do reasonably safely in plain text.
author Mads Kiilerich <madski@unity3d.com>
date Fri, 04 Jul 2014 14:12:07 +0200
parents b60e58094fb7
children 872d05f3d7cc
files kallithea/lib/helpers.py kallithea/model/notification.py kallithea/templates/changeset/changeset_file_comment.html
diffstat 3 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/helpers.py	Wed Jan 20 01:47:11 2016 +0100
+++ b/kallithea/lib/helpers.py	Fri Jul 04 14:12:07 2014 +0200
@@ -1402,9 +1402,10 @@
     return '<b>@%s</b>' % 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 @@
     # 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('<code style="white-space:pre-wrap">%s</code>' % s)
 
--- a/kallithea/model/notification.py	Wed Jan 20 01:47:11 2016 +0100
+++ b/kallithea/model/notification.py	Fri Jul 04 14:12:07 2014 +0200
@@ -59,7 +59,7 @@
 
     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 @@
             ## 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,
                       }
--- a/kallithea/templates/changeset/changeset_file_comment.html	Wed Jan 20 01:47:11 2016 +0100
+++ b/kallithea/templates/changeset/changeset_file_comment.html	Fri Jul 04 14:12:07 2014 +0200
@@ -40,7 +40,7 @@
            </div>
         %endif
         %if co.text:
-          ${h.render_w_mentions(co.text)|n}
+          ${h.render_w_mentions(co.text, c.repo_name)|n}
         %endif
       </div>
     </div>