##// END OF EJS Templates
@mention highlighting
marcink -
r1769:025f3333 beta
parent child Browse files
Show More
@@ -717,3 +717,12 b' def urlify_text(text):'
717 717 def rst(source):
718 718 return literal('<div class="rst-block">%s</div>' %
719 719 MarkupRenderer.rst(source))
720
721 def rst_w_mentions(source):
722 """
723 Wrapped rst renderer with @mention highlighting
724
725 :param source:
726 """
727 return literal('<div class="rst-block">%s</div>' %
728 MarkupRenderer.rst_with_mentions(source))
@@ -127,3 +127,13 b' class MarkupRenderer(object):'
127 127 log.warning('Install docutils to use this function')
128 128 return cls.plain(source)
129 129
130 @classmethod
131 def rst_with_mentions(cls, source):
132 mention_pat = re.compile(r'(?:^@|\s@)(\w+)')
133
134 def wrapp(match_obj):
135 uname = match_obj.groups()[0]
136 return ' **@%(uname)s** ' % {'uname':uname}
137 mention_hl = mention_pat.sub(wrapp, source).strip()
138 return cls.rst(mention_hl)
139
@@ -104,7 +104,7 b' class NotificationModel(BaseModel):'
104 104 email_subject = NotificationModel().make_description(notif, False)
105 105 type_ = type_
106 106 email_body = body
107 kwargs = {'subject':subject, 'body':h.rst(body)}
107 kwargs = {'subject':subject, 'body':h.rst_w_mentions(body)}
108 108 kwargs.update(email_kwargs)
109 109 email_body_html = EmailNotificationModel()\
110 110 .get_email_tmpl(type_, **kwargs)
@@ -39,7 +39,7 b''
39 39 <span id="${c.notification.notification_id}" class="delete-notification delete_icon action"></span>
40 40 </div>
41 41 </div>
42 <div>${h.rst(c.notification.body)}</div>
42 <div>${h.rst_w_mentions(c.notification.body)}</div>
43 43 </div>
44 44 </div>
45 45 </div>
@@ -25,7 +25,7 b''
25 25 <span onClick="deleteComment(${co.comment_id})" class="delete-comment ui-btn">${_('Delete')}</span>
26 26 </div>
27 27 %endif
28 ${h.rst(co.text)|n}
28 ${h.rst_w_mentions(co.text)|n}
29 29 </div>
30 30 </div>
31 31 </%def>
General Comments 0
You need to be logged in to leave comments. Login now