diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py
--- a/rhodecode/lib/helpers.py
+++ b/rhodecode/lib/helpers.py
@@ -8,6 +8,7 @@ import hashlib
import StringIO
import urllib
import math
+import logging
from datetime import datetime
from pygments.formatters.html import HtmlFormatter
@@ -41,6 +42,8 @@ from rhodecode.lib.utils import repo_nam
from rhodecode.lib import str2bool, safe_unicode, safe_str, get_changeset_safe
from rhodecode.lib.markup_renderer import MarkupRenderer
+log = logging.getLogger(__name__)
+
def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
"""
@@ -728,7 +731,7 @@ def fancy_file_stats(stats):
return literal('
%s%s
' % (width, d_a, d_d))
-def urlify_text(text):
+def urlify_text(text_):
import re
url_pat = re.compile(r'''(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]'''
@@ -738,8 +741,42 @@ def urlify_text(text):
url_full = match_obj.groups()[0]
return '%(url)s' % ({'url':url_full})
- return literal(url_pat.sub(url_func, text))
+ return literal(url_pat.sub(url_func, text_))
+def urlify_commit(text_):
+ import re
+ import traceback
+
+ try:
+ conf = config['app_conf']
+
+ URL_PAT = re.compile(r'%s' % conf.get('url_pat'))
+
+ if URL_PAT:
+ ISSUE_SERVER = conf.get('issue_server')
+ ISSUE_PREFIX = conf.get('issue_prefix')
+ def url_func(match_obj):
+ issue_id = match_obj.groups()[0]
+ tmpl = (
+ ''
+ ' %(issue-prefix)s%(id-repr)s'
+ ''
+ )
+ return tmpl % (
+ {
+ 'cls':'issue-tracker-link',
+ 'url':ISSUE_SERVER.replace('{id}',issue_id),
+ 'id-repr':issue_id,
+ 'issue-prefix':ISSUE_PREFIX,
+ 'serv':ISSUE_SERVER,
+ }
+ )
+ return literal(URL_PAT.sub(url_func, text_))
+ except:
+ log.error(traceback.format_exc())
+ pass
+
+ return text_
def rst(source):
return literal('%s
' %