diff roundup/cgi/templating.py @ 6564:21c7c2041a4b

issue2551181 - allow issueXXX#fragment to generate a link with fragment There is another ticket to add id's to elements displaying messages in issue.item.html. This change allows a fast way to link to such an element in a long issue with many messages once that other issue is committed and merged into a tracker template.
author John Rouillard <rouilj@ieee.org>
date Wed, 15 Dec 2021 23:52:25 -0500
parents 58bd05fbf350
children 91ab3e0ffcd0
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Tue Dec 14 08:55:55 2021 -0500
+++ b/roundup/cgi/templating.py	Wed Dec 15 23:52:25 2021 -0500
@@ -1612,7 +1612,7 @@
          (/[\w\-$.+!*(),;:@&=?/~\\#%]*)?   # path etc.
         )|
         (?P<email>[-+=%/\w\.]+@[\w\.\-]+)|
-        (?P<item>(?P<class>[A-Za-z_]+)(\s*)(?P<id>\d+))
+        (?P<item>(?P<class>[A-Za-z_]+)(\s*)(?P<id>\d+)(?P<fragment>\#[^][\#%^{}"<>\s]+)?)
     )''', re.X | re.I)
     protocol_re = re.compile('^(ht|f)tp(s?)://', re.I)
 
@@ -1630,7 +1630,7 @@
             return self._hyper_repl_email(match, '<a href="mailto:%s">%s</a>')
         elif len(match.group('id')) < 10:
             return self._hyper_repl_item(match,
-                '<a href="%(cls)s%(id)s">%(item)s</a>')
+                '<a href="%(cls)s%(id)s%(fragment)s">%(item)s</a>')
         else:
             # just return the matched text
             return match.group(0)
@@ -1664,6 +1664,9 @@
         item = match.group('item')
         cls = match.group('class').lower()
         id = match.group('id')
+        fragment = match.group('fragment')
+        if fragment is None:
+            fragment=""
         try:
             # make sure cls is a valid tracker classname
             cl = self._db.getclass(cls)

Roundup Issue Tracker: http://roundup-tracker.org/