# HG changeset patch # User Marcin Kuzminski # Date 2012-01-09 03:00:12 # Node ID f26acc1b27e28df588cdffe2b526329b70282bab # Parent dbcfa1f4331614badd57278b9b6275a1ae19c18b added repository name into issue tracker link to support different projects issues tracker mapping diff --git a/development.ini b/development.ini --- a/development.ini +++ b/development.ini @@ -77,9 +77,9 @@ proxypass_auth_enabled = false url_pat = (?:^#|\s#)(\w+) ## server url to the issue, each {id} will be replaced with id -## fetched from the regex +## fetched from the regex and {repo} is replaced with repository name -issue_server = https://myissueserver.com/issue/{id} +issue_server_link = https://myissueserver.com/{repo}/issue/{id} ## prefix to add to link to indicate it's an url ## #314 will be replaced by diff --git a/production.ini b/production.ini --- a/production.ini +++ b/production.ini @@ -77,9 +77,9 @@ proxypass_auth_enabled = false #url_pat = (?:^#|\s#)(\w+) ## server url to the issue, each {id} will be replaced with id -## fetched from the regex +## fetched from the regex and {repo} is replaced with repository name -#issue_server = https://myissueserver.com/issue/{id} +#issue_server_link = https://myissueserver.com/{repo}/issue/{id} ## prefix to add to link to indicate it's an url ## #314 will be replaced by diff --git a/rhodecode/config/deployment.ini_tmpl b/rhodecode/config/deployment.ini_tmpl --- a/rhodecode/config/deployment.ini_tmpl +++ b/rhodecode/config/deployment.ini_tmpl @@ -77,9 +77,9 @@ proxypass_auth_enabled = false #url_pat = (?:^#|\s#)(\w+) ## server url to the issue, each {id} will be replaced with id -## fetched from the regex +## fetched from the regex and {repo} is replaced with repository name -#issue_server = https://myissueserver.com/issue/{id} +#issue_server_link = https://myissueserver.com/{repo}/issue/{id} ## prefix to add to link to indicate it's an url ## #314 will be replaced by diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -739,22 +739,24 @@ def urlify_text(text_): def url_func(match_obj): url_full = match_obj.groups()[0] - return '%(url)s' % ({'url':url_full}) + return '%(url)s' % ({'url': url_full}) return literal(url_pat.sub(url_func, text_)) -def urlify_commit(text_): + +def urlify_commit(text_, repository=None): 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_SERVER_LNK = conf.get('issue_server_link') ISSUE_PREFIX = conf.get('issue_prefix') + def url_func(match_obj): issue_id = match_obj.groups()[0] tmpl = ( @@ -762,13 +764,17 @@ def urlify_commit(text_): '%(issue-prefix)s%(id-repr)s' '' ) + url = ISSUE_SERVER_LNK.replace('{id}', issue_id) + if repository: + url = url.replace('{repo}', repository) + return tmpl % ( { - 'cls':'issue-tracker-link', - 'url':ISSUE_SERVER.replace('{id}',issue_id), - 'id-repr':issue_id, - 'issue-prefix':ISSUE_PREFIX, - 'serv':ISSUE_SERVER, + 'cls': 'issue-tracker-link', + 'url': url, + 'id-repr': issue_id, + 'issue-prefix': ISSUE_PREFIX, + 'serv': ISSUE_SERVER_LNK, } ) return literal(URL_PAT.sub(url_func, text_)) @@ -778,10 +784,12 @@ def urlify_commit(text_): return text_ + def rst(source): return literal('
%s
' % MarkupRenderer.rst(source)) + def rst_w_mentions(source): """ Wrapped rst renderer with @mention highlighting diff --git a/rhodecode/templates/changelog/changelog.html b/rhodecode/templates/changelog/changelog.html --- a/rhodecode/templates/changelog/changelog.html +++ b/rhodecode/templates/changelog/changelog.html @@ -59,7 +59,7 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
${cs.date}
-
${h.urlify_commit(h.wrap_paragraphs(cs.message))}
+
${h.urlify_commit(h.wrap_paragraphs(cs.message),c.repo_name)}
↓ ${_('show more')} ↓
diff --git a/rhodecode/templates/changeset/changeset.html b/rhodecode/templates/changeset/changeset.html --- a/rhodecode/templates/changeset/changeset.html +++ b/rhodecode/templates/changeset/changeset.html @@ -49,7 +49,7 @@ ${h.person(c.changeset.author)}
${h.email_or_none(c.changeset.author)}
-
${h.urlify_commit(h.wrap_paragraphs(c.changeset.message))}
+
${h.urlify_commit(h.wrap_paragraphs(c.changeset.message),c.repo_name)}
diff --git a/rhodecode/templates/changeset/changeset_range.html b/rhodecode/templates/changeset/changeset_range.html --- a/rhodecode/templates/changeset/changeset_range.html +++ b/rhodecode/templates/changeset/changeset_range.html @@ -41,7 +41,7 @@ ${h.link_to('r%s:%s' % (cs.revision,h.short_id(cs.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}
${h.person(cs.author)}
${cs.date} -
${h.urlify_commit(h.wrap_paragraphs(cs.message))}
+
${h.urlify_commit(h.wrap_paragraphs(cs.message),c.repo_name)}
%endfor