Mercurial > kallithea
comparison rhodecode/lib/helpers.py @ 1878:287eff9614fa beta
changelog: make messages be links again, and somewhat co-exist with issue tracker links (those are bold now)
author | Aras Pranckevicius <aras@unity3d.com> |
---|---|
date | Mon, 09 Jan 2012 22:40:10 +0200 |
parents | f26acc1b27e2 |
children | 0614862a20ec |
comparison
equal
deleted
inserted
replaced
1877:395a3196de73 | 1878:287eff9614fa |
---|---|
742 return '<a href="%(url)s">%(url)s</a>' % ({'url': url_full}) | 742 return '<a href="%(url)s">%(url)s</a>' % ({'url': url_full}) |
743 | 743 |
744 return literal(url_pat.sub(url_func, text_)) | 744 return literal(url_pat.sub(url_func, text_)) |
745 | 745 |
746 | 746 |
747 def urlify_commit(text_, repository=None): | 747 def urlify_commit(text_, repository=None, link_=None): |
748 import re | 748 import re |
749 import traceback | 749 import traceback |
750 | |
751 if link_: | |
752 link_ = '<a href="' + link_ + '">' | |
750 | 753 |
751 try: | 754 try: |
752 conf = config['app_conf'] | 755 conf = config['app_conf'] |
753 | 756 |
754 URL_PAT = re.compile(r'%s' % conf.get('url_pat')) | 757 URL_PAT = re.compile(r'%s' % conf.get('url_pat')) |
766 ) | 769 ) |
767 url = ISSUE_SERVER_LNK.replace('{id}', issue_id) | 770 url = ISSUE_SERVER_LNK.replace('{id}', issue_id) |
768 if repository: | 771 if repository: |
769 url = url.replace('{repo}', repository) | 772 url = url.replace('{repo}', repository) |
770 | 773 |
774 if link_: | |
775 tmpl = '</a>' + tmpl + link_ | |
776 | |
771 return tmpl % ( | 777 return tmpl % ( |
772 { | 778 { |
773 'cls': 'issue-tracker-link', | 779 'cls': 'issue-tracker-link', |
774 'url': url, | 780 'url': url, |
775 'id-repr': issue_id, | 781 'id-repr': issue_id, |
776 'issue-prefix': ISSUE_PREFIX, | 782 'issue-prefix': ISSUE_PREFIX, |
777 'serv': ISSUE_SERVER_LNK, | 783 'serv': ISSUE_SERVER_LNK, |
778 } | 784 } |
779 ) | 785 ) |
780 return literal(URL_PAT.sub(url_func, text_)) | 786 newtext = URL_PAT.sub(url_func, text_) |
787 if link_: | |
788 newtext = link_ + newtext + '</a>' | |
789 return literal(newtext) | |
781 except: | 790 except: |
782 log.error(traceback.format_exc()) | 791 log.error(traceback.format_exc()) |
783 pass | 792 pass |
784 | 793 |
794 | |
795 | |
785 return text_ | 796 return text_ |
786 | 797 |
787 | 798 |
788 def rst(source): | 799 def rst(source): |
789 return literal('<div class="rst-block">%s</div>' % | 800 return literal('<div class="rst-block">%s</div>' % |