Mercurial > kallithea
changeset 1769:025f3333c769 beta
@mention highlighting
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 08 Dec 2011 03:36:13 +0200 |
parents | 5610fd9b6803 |
children | 184557472f5c |
files | rhodecode/lib/helpers.py rhodecode/lib/markup_renderer.py rhodecode/model/notification.py rhodecode/templates/admin/notifications/show_notification.html rhodecode/templates/changeset/changeset_file_comment.html |
diffstat | 5 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py Thu Dec 08 02:25:23 2011 +0200 +++ b/rhodecode/lib/helpers.py Thu Dec 08 03:36:13 2011 +0200 @@ -717,3 +717,12 @@ def rst(source): return literal('<div class="rst-block">%s</div>' % MarkupRenderer.rst(source)) + +def rst_w_mentions(source): + """ + Wrapped rst renderer with @mention highlighting + + :param source: + """ + return literal('<div class="rst-block">%s</div>' % + MarkupRenderer.rst_with_mentions(source))
--- a/rhodecode/lib/markup_renderer.py Thu Dec 08 02:25:23 2011 +0200 +++ b/rhodecode/lib/markup_renderer.py Thu Dec 08 03:36:13 2011 +0200 @@ -127,3 +127,13 @@ log.warning('Install docutils to use this function') return cls.plain(source) + @classmethod + def rst_with_mentions(cls, source): + mention_pat = re.compile(r'(?:^@|\s@)(\w+)') + + def wrapp(match_obj): + uname = match_obj.groups()[0] + return ' **@%(uname)s** ' % {'uname':uname} + mention_hl = mention_pat.sub(wrapp, source).strip() + return cls.rst(mention_hl) +
--- a/rhodecode/model/notification.py Thu Dec 08 02:25:23 2011 +0200 +++ b/rhodecode/model/notification.py Thu Dec 08 03:36:13 2011 +0200 @@ -104,7 +104,7 @@ email_subject = NotificationModel().make_description(notif, False) type_ = type_ email_body = body - kwargs = {'subject':subject, 'body':h.rst(body)} + kwargs = {'subject':subject, 'body':h.rst_w_mentions(body)} kwargs.update(email_kwargs) email_body_html = EmailNotificationModel()\ .get_email_tmpl(type_, **kwargs)
--- a/rhodecode/templates/admin/notifications/show_notification.html Thu Dec 08 02:25:23 2011 +0200 +++ b/rhodecode/templates/admin/notifications/show_notification.html Thu Dec 08 03:36:13 2011 +0200 @@ -39,7 +39,7 @@ <span id="${c.notification.notification_id}" class="delete-notification delete_icon action"></span> </div> </div> - <div>${h.rst(c.notification.body)}</div> + <div>${h.rst_w_mentions(c.notification.body)}</div> </div> </div> </div>
--- a/rhodecode/templates/changeset/changeset_file_comment.html Thu Dec 08 02:25:23 2011 +0200 +++ b/rhodecode/templates/changeset/changeset_file_comment.html Thu Dec 08 03:36:13 2011 +0200 @@ -25,7 +25,7 @@ <span onClick="deleteComment(${co.comment_id})" class="delete-comment ui-btn">${_('Delete')}</span> </div> %endif - ${h.rst(co.text)|n} + ${h.rst_w_mentions(co.text)|n} </div> </div> </%def>