# # Patch for ViewVC to allow the magic identifiers in ViewVC interface. # --- viewvc-ss-1224/lib/viewcvs.py +++ viewvc/lib/viewcvs.py @@ -938,10 +938,38 @@ # addresses. Note that the regexps assume the text is already HTML-encoded. _re_rewrite_url = re.compile('((http|https|ftp|file|svn|svn\+ssh)(://[-a-zA-Z0-9%.~:_/]+)((\?|\&)([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*(#([-a-zA-Z0-9%.~:_]+)?)?)') _re_rewrite_email = re.compile('([-a-zA-Z0-9_.\+]+)@(([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})') +_re_buglink = re.compile('(BugID:)\s?(\d+)', re.M) +_re_vcslink = re.compile('(VCS:)\s?([0-9A-Za-z_/\-.]*)', re.M) +_re_wikilink = re.compile('(Wiki:)\s?([A-Za-z_\-:]*)', re.M) + +def bug_linkify(m): + url = """%s""" + ref = m.group(1) + bug = m.group(2) + text = ref + " " + url % (bug, bug) + return text + +def vcs_linkify(m): + url = """%s""" + ref = m.group(1) + vcs = m.group(2) + text = ref + " " + url % (vcs, vcs) + return text + +def wiki_linkify(m): + url = """%s""" + ref = m.group(1) + wiki = m.group(2) + text = ref + " " + url % (wiki, wiki) + return text + def htmlify(html): html = cgi.escape(html) html = re.sub(_re_rewrite_url, r'\1', html) html = re.sub(_re_rewrite_email, r'\1@\2', html) + html = re.sub(_re_buglink, bug_linkify, html) + html = re.sub(_re_vcslink, vcs_linkify, html) + html = re.sub(_re_wikilink, wiki_linkify, html) return html def format_log(log, cfg):