Changeset - ef3114b01c7c
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 14 years ago 2012-02-24 19:53:11
marcin@python-works.com
fixed issues when urlify commit created empty links when link_ param was empty
1 file changed with 12 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -818,24 +818,33 @@ def urlify_changesets(text_, repository)
 
         'pref': pref,
 
         'cls': 'revision-link',
 
         'url': url('changeset_home', repo_name=repository, revision=rev),
 
         'rev': rev,
 
        }
 

	
 
    newtext = URL_PAT.sub(url_func, text_)
 

	
 
    return newtext
 

	
 

	
 
def urlify_commit(text_, repository=None, link_=None):
 
    """
 
    Parses given text message and makes proper links.
 
    issues are linked to given issue-server, and rest is a changeset link
 
    if link_ is given, in other case it's a plain text
 

	
 
    :param text_:
 
    :param repository:
 
    :param link_: changeset link
 
    """
 
    import re
 
    import traceback
 

	
 
    # urlify changesets
 
    text_ = urlify_changesets(text_, repository)
 

	
 
    def linkify_others(t, l):
 
        urls = re.compile(r'(\<a.*?\<\/a\>)',)
 
        links = []
 
        for e in urls.split(t):
 
            if not urls.match(e):
 
                links.append('<a class="message-link" href="%s">%s</a>' % (l, e))
 
@@ -869,26 +878,27 @@ def urlify_commit(text_, repository=None
 

	
 
                return tmpl % {
 
                     'pref': pref,
 
                     'cls': 'issue-tracker-link',
 
                     'url': url,
 
                     'id-repr': issue_id,
 
                     'issue-prefix': ISSUE_PREFIX,
 
                     'serv': ISSUE_SERVER_LNK,
 
                }
 

	
 
            newtext = URL_PAT.sub(url_func, text_)
 

	
 
            # wrap not links into final link => link_
 
            newtext = linkify_others(newtext, link_)
 
            if link_:
 
                # wrap not links into final link => link_
 
                newtext = linkify_others(newtext, link_)
 

	
 
            return literal(newtext)
 
    except:
 
        log.error(traceback.format_exc())
 
        pass
 

	
 
    return text_
 

	
 

	
 
def rst(source):
 
    return literal('<div class="rst-block">%s</div>' %
 
                   MarkupRenderer.rst(source))
0 comments (0 inline, 0 general)