Skip to content

Commit b048332

Browse files
author
Richard Jones
committed
hyperlinking of special message text
1 parent 2b8022e commit b048332

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ are given with the most recent entry first.
44
2003-01-?? 0.5.4
55
- key the templates cache off full path, not filename
66
- implemented whole-database locking
7+
- hyperlinking of special text (url, email, item designator) in messages
78

89

910
2002-12-11 0.5.3

TODO.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pending web clicking on a group header should filter for that type of
5959
pending web re-enable auth basic http auth
6060
pending web allow multilink selections to select a "none" element to allow
6161
people with broken browsers to select nothing?
62-
pending web automagically link designators
6362
pending web add checkbox-based removal/addition for multilink entries
6463
(eg "add me"/"remove me" for nosy list)
6564
pending web search "refinement" - pre-fill the search page with the

roundup/cgi/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.62 2002-12-11 01:46:46 richard Exp $
1+
# $Id: client.py,v 1.63 2002-12-15 23:55:33 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -1186,7 +1186,6 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
11861186
else:
11871187
propname = key
11881188

1189-
11901189
# does the property exist?
11911190
if not properties.has_key(propname):
11921191
if mlaction != 'set':

roundup/cgi/templating.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,14 +734,44 @@ def __cmp__(self, other):
734734
return cmp(self._value, other)
735735

736736
class StringHTMLProperty(HTMLProperty):
737-
def plain(self, escape=0):
737+
url_re = re.compile(r'\w{3,6}://\S+')
738+
email_re = re.compile(r'\w+@[\w\.\-]+')
739+
designator_re = re.compile(r'([a-z_]+)([\d+])')
740+
def _url_repl(self, match):
741+
s = match.group(0)
742+
return '<a href="%s">%s</a>'%(s, s)
743+
def _email_repl(self, match):
744+
s = match.group(0)
745+
return '<a href="mailto:%s">%s</a>'%(s, s)
746+
def _designator_repl(self, match):
747+
s = match.group(0)
748+
s1 = match.group(1)
749+
s2 = match.group(2)
750+
try:
751+
# make sure s1 is a valid tracker classname
752+
self._db.getclass(s1)
753+
return '<a href="%s">%s %s</a>'%(s, s1, s2)
754+
except KeyError:
755+
return '%s%s'%(s1, s2)
756+
757+
def plain(self, escape=0, hyperlink=1):
738758
''' Render a "plain" representation of the property
759+
760+
"escape" turns on/off HTML quoting
761+
"hyperlink" turns on/off in-text hyperlinking of URLs, email
762+
addresses and designators
739763
'''
740764
if self._value is None:
741765
return ''
742766
if escape:
743-
return cgi.escape(str(self._value))
744-
return str(self._value)
767+
s = cgi.escape(str(self._value))
768+
else:
769+
s = self._value
770+
if hyperlink:
771+
s = self.url_re.sub(self._url_repl, s)
772+
s = self.email_re.sub(self._email_repl, s)
773+
s = self.designator_re.sub(self._designator_repl, s)
774+
return s
745775

746776
def stext(self, escape=0):
747777
''' Render the value of the property as StructuredText.

roundup/templates/classic/html/issue.item

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ python:db.user.classhelp('username,realname,address,phone')" /><br>
140140
</tr>
141141
<tr>
142142
<td colspan="4" class="content">
143-
<pre tal:content="msg/content">content</pre>
143+
<pre tal:content="structure msg/content">content</pre>
144144
</td>
145145
</tr>
146146
</tal:block>

0 commit comments

Comments
 (0)