From 01b3f489151dde7f11d42ee7832561715b1a3db9 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 15 Dec 2002 23:55:34 +0000 Subject: [PATCH] hyperlinking of special message text git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1411 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + TODO.txt | 1 - roundup/cgi/client.py | 3 +- roundup/cgi/templating.py | 36 +++++++++++++++++++++-- roundup/templates/classic/html/issue.item | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a949424..28cc97e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,7 @@ are given with the most recent entry first. 2003-01-?? 0.5.4 - key the templates cache off full path, not filename - implemented whole-database locking +- hyperlinking of special text (url, email, item designator) in messages 2002-12-11 0.5.3 diff --git a/TODO.txt b/TODO.txt index d21f0cf..556029e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -59,7 +59,6 @@ pending web clicking on a group header should filter for that type of pending web re-enable auth basic http auth pending web allow multilink selections to select a "none" element to allow people with broken browsers to select nothing? -pending web automagically link designators pending web add checkbox-based removal/addition for multilink entries (eg "add me"/"remove me" for nosy list) pending web search "refinement" - pre-fill the search page with the diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index e338d7a..856bad8 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.62 2002-12-11 01:46:46 richard Exp $ +# $Id: client.py,v 1.63 2002-12-15 23:55:33 richard Exp $ __doc__ = """ 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+$')): else: propname = key - # does the property exist? if not properties.has_key(propname): if mlaction != 'set': diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index f87cdb6..b65dec5 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -734,14 +734,44 @@ class HTMLProperty: return cmp(self._value, other) class StringHTMLProperty(HTMLProperty): - def plain(self, escape=0): + 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 '%s'%(s, s) + def _email_repl(self, match): + s = match.group(0) + return '%s'%(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 '%s %s'%(s, s1, s2) + except KeyError: + return '%s%s'%(s1, s2) + + def plain(self, escape=0, hyperlink=1): ''' Render a "plain" representation of the property + + "escape" turns on/off HTML quoting + "hyperlink" turns on/off in-text hyperlinking of URLs, email + addresses and designators ''' if self._value is None: return '' if escape: - return cgi.escape(str(self._value)) - return str(self._value) + s = cgi.escape(str(self._value)) + else: + s = self._value + if hyperlink: + 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) + return s def stext(self, escape=0): ''' Render the value of the property as StructuredText. diff --git a/roundup/templates/classic/html/issue.item b/roundup/templates/classic/html/issue.item index dcba3e0..abe2ce7 100644 --- a/roundup/templates/classic/html/issue.item +++ b/roundup/templates/classic/html/issue.item @@ -140,7 +140,7 @@ python:db.user.classhelp('username,realname,address,phone')" />
-
content
+
content
-- 2.30.2