Mercurial > public > src > rhodecode
changeset 1953:f26acc1b27e2 beta
added repository name into issue tracker link to support different projects issues tracker mapping
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 09 Jan 2012 04:00:12 +0200 |
parents | dbcfa1f43316 |
children | 682057a38cd3 |
files | development.ini production.ini rhodecode/config/deployment.ini_tmpl rhodecode/lib/helpers.py rhodecode/templates/changelog/changelog.html rhodecode/templates/changeset/changeset.html rhodecode/templates/changeset/changeset_range.html |
diffstat | 7 files changed, 28 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/development.ini Mon Jan 09 03:51:05 2012 +0200 +++ b/development.ini Mon Jan 09 04:00:12 2012 +0200 @@ -77,9 +77,9 @@ 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 <issue_prefix><id>
--- a/production.ini Mon Jan 09 03:51:05 2012 +0200 +++ b/production.ini Mon Jan 09 04:00:12 2012 +0200 @@ -77,9 +77,9 @@ #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 <issue_prefix><id>
--- a/rhodecode/config/deployment.ini_tmpl Mon Jan 09 03:51:05 2012 +0200 +++ b/rhodecode/config/deployment.ini_tmpl Mon Jan 09 04:00:12 2012 +0200 @@ -77,9 +77,9 @@ #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 <issue_prefix><id>
--- a/rhodecode/lib/helpers.py Mon Jan 09 03:51:05 2012 +0200 +++ b/rhodecode/lib/helpers.py Mon Jan 09 04:00:12 2012 +0200 @@ -739,22 +739,24 @@ def url_func(match_obj): url_full = match_obj.groups()[0] - return '<a href="%(url)s">%(url)s</a>' % ({'url':url_full}) + return '<a href="%(url)s">%(url)s</a>' % ({'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 @@ '%(issue-prefix)s%(id-repr)s' '</a>' ) + 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 @@ return 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
--- a/rhodecode/templates/changelog/changelog.html Mon Jan 09 03:51:05 2012 +0200 +++ b/rhodecode/templates/changelog/changelog.html Mon Jan 09 04:00:12 2012 +0200 @@ -59,7 +59,7 @@ <div class="date">${cs.date}</div> </div> <div class="mid"> - <div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message))}</div> + <div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message),c.repo_name)}</div> <div class="expand ${'tablerow%s' % (cnt%2)}">↓ ${_('show more')} ↓</div> </div> <div class="right">
--- a/rhodecode/templates/changeset/changeset.html Mon Jan 09 03:51:05 2012 +0200 +++ b/rhodecode/templates/changeset/changeset.html Mon Jan 09 04:00:12 2012 +0200 @@ -49,7 +49,7 @@ <span>${h.person(c.changeset.author)}</span><br/> <span><a href="mailto:${h.email_or_none(c.changeset.author)}">${h.email_or_none(c.changeset.author)}</a></span><br/> </div> - <div class="message">${h.urlify_commit(h.wrap_paragraphs(c.changeset.message))}</div> + <div class="message">${h.urlify_commit(h.wrap_paragraphs(c.changeset.message),c.repo_name)}</div> </div> <div class="right"> <div class="changes">
--- a/rhodecode/templates/changeset/changeset_range.html Mon Jan 09 03:51:05 2012 +0200 +++ b/rhodecode/templates/changeset/changeset_range.html Mon Jan 09 04:00:12 2012 +0200 @@ -41,7 +41,7 @@ <td>${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))}</td> <td><div class="author">${h.person(cs.author)}</div></td> <td><span class="tooltip" title="${h.age(cs.date)}">${cs.date}</span></td> - <td><div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message))}</div></td> + <td><div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message),c.repo_name)}</div></td> </tr> %endfor </table>