Changeset - 4a9184804089
[Not reviewed]
default
0 3 0
Mads Kiilerich - 11 years ago 2014-07-04 14:12:07
madski@unity3d.com
comments: linkify revision hashes and issue tracker references

This was hard with RST markup - much easier to do reasonably safely in plain text.
3 files changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/helpers.py
Show inline comments
 
@@ -1402,9 +1402,10 @@ def _mentions_replace(match_obj):
 
    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 @@ 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('<code style="white-space:pre-wrap">%s</code>' % s)
 

	
kallithea/model/notification.py
Show inline comments
 
@@ -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,
 
                      }
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -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>
0 comments (0 inline, 0 general)