summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8917c21)
raw | patch | inline | side by side (parent: 8917c21)
| author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
| Tue, 21 Jan 2003 22:34:18 +0000 (22:34 +0000) | ||
| committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
| Tue, 21 Jan 2003 22:34:18 +0000 (22:34 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1471 57a73879-2fb5-44c3-a270-3262357dd7e2
| CHANGES.txt | patch | blob | history | |
| roundup/cgi/templating.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index e9e5c5e5d7493b113171588f111388b7e79fd121..ab0835c0ce58bd5f1706dff2b2d3a7a60f4e9388 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
are given with the most recent entry first.
2003-??-?? 0.6.0
-- better hyperlinking in web message texts
+- better hyperlinking in web message texts (handle ambiguous cases)
- support setting of properties on message and file through web and
email interface (thanks John Rouillard)
- allow additional control over the roundupdb email sending (explicit
index bf2552eac27a515f5445567007d35a96df478fa7..3b846337b242561574aa1b944ed9edabe3ef78b9 100644 (file)
return cmp(self._value, other)
class StringHTMLProperty(HTMLProperty):
- url_re = re.compile(r'\w{3,6}://\S+')
- email_re = re.compile(r'[\w\.]+@[\w\.\-]+')
- designator_re = re.compile(r'([a-z_]+)(\d+)')
- def _url_repl(self, match):
- s = match.group(0)
- return '<a href="%s">%s</a>'%(s, s)
- def _email_repl(self, match):
- s = match.group(0)
- return '<a href="mailto:%s">%s</a>'%(s, s)
- def _designator_repl(self, match):
- s = match.group(0)
- s1 = match.group(1)
- s2 = match.group(2)
- try:
- # make sure s1 is a valid tracker classname
- self._db.getclass(s1)
- return '<a href="%s">%s %s</a>'%(s, s1, s2)
- except KeyError:
- return '%s%s'%(s1, s2)
+ hyper_re = re.compile(r'((?P<url>\w{3,6}://\S+)|'
+ r'(?P<email>[\w\.]+@[\w\.\-]+)|'
+ r'(?P<item>(?P<class>[a-z_]+)(?P<id>\d+)))')
+ def _hyper_repl(self, match):
+ if match.group('url'):
+ s = match.group('url')
+ return '<a href="%s">%s</a>'%(s, s)
+ elif match.group('email'):
+ s = match.group('email')
+ return '<a href="mailto:%s">%s</a>'%(s, s)
+ else:
+ s = match.group('item')
+ s1 = match.group('class')
+ s2 = match.group('id')
+ try:
+ # make sure s1 is a valid tracker classname
+ self._db.getclass(s1)
+ return '<a href="%s">%s %s</a>'%(s, s1, s2)
+ except KeyError:
+ return '%s%s'%(s1, s2)
def plain(self, escape=0, hyperlink=0):
''' Render a "plain" representation of the property
if hyperlink:
if not escape:
s = cgi.escape(s)
- s = self.url_re.sub(self._url_repl, s)
- s = self.email_re.sub(self._email_repl, s)
- s = self.designator_re.sub(self._designator_repl, s)
+ s = self.hyper_re.sub(self._hyper_repl, s)
return s
def stext(self, escape=0):