Changeset - b60e58094fb7
[Not reviewed]
default
0 7 0
Mads Kiilerich - 10 years ago 2016-01-20 01:47:11
madski@unity3d.com
comments: change comment formatting to plain text instead of rst

There might be value in enabling rich markup (especially if it is markdown
instead of rst) ... or it might be a waste of time. We might revisit that
later.

But either way: Changing to plain text makes it more feasible to do markup of
hashes and issues - for now that is more important than rtf.
7 files changed with 12 insertions and 27 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changeset.py
Show inline comments
 
@@ -409,13 +409,13 @@ class ChangesetController(BaseRepoContro
 
                                   'repository.admin')
 
    def preview_comment(self):
 
        if not request.environ.get('HTTP_X_PARTIAL_XHR'):
 
            raise HTTPBadRequest()
 
        text = request.POST.get('text')
 
        if text:
 
            return h.rst_w_mentions(text)
 
            return h.render_w_mentions(text)
 
        return ''
 

	
 
    @LoginRequired()
 
    @NotAnonymous()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
kallithea/lib/helpers.py
Show inline comments
 
@@ -1395,13 +1395,13 @@ def rst_w_mentions(source):
 
    :param source:
 
    """
 
    return literal('<div class="rst-block">%s</div>' %
 
                   MarkupRenderer.rst_with_mentions(source))
 

	
 

	
 
def mentions_replace(match_obj):
 
def _mentions_replace(match_obj):
 
    return '<b>@%s</b>' % match_obj.group(1)
 

	
 

	
 
def render_w_mentions(source):
 
    """
 
    Render plain text with @mention highlighting.
 
@@ -1410,13 +1410,13 @@ def render_w_mentions(source):
 
    s = safe_unicode(s)
 
    s = '\n'.join(s.splitlines())
 
    s = html_escape(s)
 
    # this sequence of html-ifications seems to be safe and non-conflicting
 
    # if the issues regexp is sane
 
    s = _urlify_text(s)
 
    s = MENTIONS_REGEX.sub(mentions_replace, s)
 
    s = MENTIONS_REGEX.sub(_mentions_replace, s)
 
    return literal('<code style="white-space:pre-wrap">%s</code>' % s)
 

	
 

	
 
def short_ref(ref_type, ref_name):
 
    if ref_type == 'rev':
 
        return short_id(ref_name)
kallithea/model/notification.py
Show inline comments
 
@@ -120,13 +120,13 @@ class NotificationModel(BaseModel):
 

	
 
        # send email with notification to all other participants
 
        for rec in rec_objs:
 
            ## this is passed into template
 
            html_kwargs = {
 
                      'subject': subject,
 
                      'body': h.rst_w_mentions(body),
 
                      'body': h.render_w_mentions(body),
 
                      'when': h.fmt_date(notif.created_on),
 
                      'user': notif.created_by_user.username,
 
                      }
 

	
 
            txt_kwargs = {
 
                      'subject': subject,
kallithea/public/css/style.css
Show inline comments
 
@@ -4128,15 +4128,13 @@ div.rst-block pre {
 
    float: left;
 
    padding: 4px 4px 0px 4px;
 
}
 

	
 
.comments .comment .text {
 
    background-color: #FAFAFA;
 
}
 
.comment .text div.rst-block p {
 
    margin: 0.5em 0px !important;
 
    margin: 6px;
 
}
 

	
 
.comments-number {
 
    margin: 5px;
 
    padding: 0px 0px 10px 0px;
 
    font-weight: bold;
 
@@ -4291,19 +4289,12 @@ form.comment-inline-form {
 

	
 
/** comment inline **/
 
.inline-comments {
 
    padding: 0 20px;
 
}
 

	
 
.inline-comments div.rst-block {
 
    clear: both;
 
    overflow: hidden;
 
    margin: 0;
 
    padding: 0 20px 0px;
 
}
 

	
 
.inline-comments .comment .comment-wrapp {
 
    max-width: 978px;
 
    border: 1px solid #ddd;
 
    border-radius: 4px;
 
    margin: 3px 3px 5px 5px;
 
    background-color: #FAFAFA;
 
@@ -4335,12 +4326,13 @@ form.comment-inline-form {
 
    float: left;
 
    padding: 3px;
 
}
 

	
 
.inline-comments .comment .text {
 
    background-color: #FAFAFA;
 
    margin: 6px;
 
}
 

	
 
.inline-comments .comments-number {
 
    padding: 0px 0px 10px 0px;
 
    font-weight: bold;
 
    color: #666;
kallithea/templates/admin/notifications/show_notification.html
Show inline comments
 
@@ -34,13 +34,13 @@
 
            <span id="${c.notification.notification_id}" class="delete-notification action"><i class="icon-minus-circled" id="yui-gen24"></i></span>
 
          </div>
 
        </div>
 
        <div class="notification-body">
 
        <div class="notification-subject">${h.literal(c.notification.subject)}</div>
 
        %if c.notification.body:
 
            ${h.rst_w_mentions(c.notification.body)}
 
            ${h.render_w_mentions(c.notification.body)}
 
        %endif
 
        </div>
 
      </div>
 
    </div>
 
</div>
 
<script type="text/javascript">
kallithea/templates/changeset/changeset_file_comment.html
Show inline comments
 
@@ -29,21 +29,21 @@
 
          %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or co.author.user_id == c.authuser.user_id:
 
            <div onClick="confirm('${_("Delete comment?")}') && deleteComment(${co.comment_id})" class="buttons delete-comment btn btn-mini">${_('Delete')}</div>
 
          %endif
 
      </div>
 
      <div class="text">
 
        %if co.status_change:
 
           <div class="rst-block automatic-comment">
 
           <div class="automatic-comment">
 
             <p>
 
               <span title="${_('Changeset status')}" class="changeset-status-lbl">${_("Status change")}: ${co.status_change[0].status_lbl}</span>
 
               <span class="changeset-status-ico"><i class="icon-circle changeset-status-${co.status_change[0].status}"></i></span>
 
             </p>
 
           </div>
 
        %endif
 
        %if co.text:
 
          ${h.rst_w_mentions(co.text)|n}
 
          ${h.render_w_mentions(co.text)|n}
 
        %endif
 
      </div>
 
    </div>
 
  </div>
 
</%def>
 

	
 
@@ -54,18 +54,13 @@
 
<div id='comment-inline-form-template' style="display:none">
 
  <div class="ac">
 
  %if c.authuser.username != 'default':
 
    ${h.form('#', class_='inline-form')}
 
      <div id="edit-container_{1}" class="clearfix">
 
        <div class="comment-help">${_('Commenting on line {1}.')}
 
          ${(_('Comments parsed using %s syntax with %s support.') % (
 
                 ('<a href="%s">RST</a>' % h.url('rst_help')),
 
                   ('<span style="color:#577632" class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to notify another user'))
 
               )
 
            )|n
 
           }
 
          <span style="color:#577632" class="tooltip">${_('Comments are in plain text. Use @username inside this text to notify another user.')|n}</span>
 
        </div>
 
        <div class="mentions-container" id="mentions_container_{1}"></div>
 
        <textarea id="text_{1}" name="text" class="comment-block-ta yui-ac-input"></textarea>
 
      </div>
 
      <div id="preview-container_{1}" class="clearfix" style="display:none">
 
        <div class="comment-help">
 
@@ -142,15 +137,13 @@
 
<div class="comments">
 
    %if c.authuser.username != 'default':
 
    <div class="comment-form ac">
 
      ${h.form(post_url, id="main_form")}
 
        <div id="edit-container" class="clearfix">
 
            <div class="comment-help">
 
                ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')),
 
                  '<span style="color:#577632" class="tooltip" title="%s">@mention</span>' %
 
                  _('Use @username inside this text to notify another user.')))|n}
 
              <span style="color:#577632" class="tooltip">${_('Comments are in plain text. Use @username inside this text to send notification to another local user.')|n}</span>
 
            </div>
 
            <div class="mentions-container" id="mentions_container"></div>
 
            ${h.textarea('text', class_="comment-block-ta")}
 
            %if change_status:
 
              <div id="status_block_container" class="status-block">
 
                %if is_pr:
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -40,13 +40,13 @@ ${self.repo_context_bar('showpullrequest
 
            <div style="margin: 5px">
 
              <a class="btn btn-small" onclick="$('.pr-do-edit').show();$('.pr-not-edit').hide()">${_("Edit")}</a>
 
            </div>
 
            %endif
 
          </div>
 
          <div class="input">
 
            <div style="white-space:pre-wrap; line-height: 14px">${h.urlify_commit(c.pull_request.description, c.pull_request.org_repo.repo_name)}</div>
 
            <code style="white-space:pre-wrap; line-height: 14px">${h.urlify_commit(c.pull_request.description, c.pull_request.org_repo.repo_name)}</code>
 
          </div>
 
        </div>
 

	
 
        %if editable:
 
        <div class="pr-do-edit" style="display:none">
 
          <div class="field">
0 comments (0 inline, 0 general)