Changeset - 025f3333c769
[Not reviewed]
beta
0 5 0
Marcin Kuzminski - 14 years ago 2011-12-08 02:36:13
marcin@python-works.com
@mention highlighting
5 files changed with 22 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -714,6 +714,15 @@ def urlify_text(text):
 
    return literal(url_pat.sub(url_func, text))
 

	
 

	
 
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))    
rhodecode/lib/markup_renderer.py
Show inline comments
 
@@ -124,6 +124,16 @@ class MarkupRenderer(object):
 

	
 
            return parts['html_title'] + parts["fragment"]
 
        except ImportError:
 
            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)
 

	
rhodecode/model/notification.py
Show inline comments
 
@@ -101,13 +101,13 @@ class NotificationModel(BaseModel):
 

	
 
        # send email with notification
 
        for rec in recipients_objs:
 
            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)
 
            run_task(tasks.send_email, rec.email, email_subject, email_body,
 
                     email_body_html)
 

	
rhodecode/templates/admin/notifications/show_notification.html
Show inline comments
 
@@ -36,13 +36,13 @@
 
              ${c.notification.description}
 
          </div>
 
          <div class="delete-notifications">
 
            <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>
 
<script type="text/javascript">
 
var url = "${url('notification', notification_id='__NOTIFICATION_ID__')}";
 
var main = "${url('notifications')}";
rhodecode/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -22,13 +22,13 @@
 
  	<div class="text">
 
  		%if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
 
  			<div class="buttons">
 
  				<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>
 
 
 
0 comments (0 inline, 0 general)