Mercurial > p > roundup > code
diff roundup/htmltemplate.py @ 673:604c84696461
link() htmltemplate function now has a "showid" option for links & multilinks.
When true, it only displays the linked node id as the anchor text. The
link value is displayed as a tooltip using the title anchor attribute.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 02 Apr 2002 01:40:59 +0000 |
| parents | d92e06a3a56e |
| children | bc46480e2a2b |
line wrap: on
line diff
--- a/roundup/htmltemplate.py Fri Mar 29 19:41:48 2002 +0000 +++ b/roundup/htmltemplate.py Tue Apr 02 01:40:59 2002 +0000 @@ -15,13 +15,13 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.84 2002-03-29 19:41:48 rochecompaan Exp $ +# $Id: htmltemplate.py,v 1.85 2002-04-02 01:40:58 richard Exp $ __doc__ = """ Template engine. """ -import os, re, StringIO, urllib, cgi, errno, types +import os, re, StringIO, urllib, cgi, errno, types, urllib import hyperdb, date from i18n import _ @@ -331,7 +331,7 @@ return _('[Menu: not a link]') #XXX deviates from spec - def do_link(self, property=None, is_download=0): + def do_link(self, property=None, is_download=0, showid=0): '''For a Link or Multilink property, display the names of the linked nodes, hyperlinked to the item views on those nodes. For other properties, link to this node with the property as the @@ -355,11 +355,17 @@ linkcl = self.db.classes[linkname] k = linkcl.labelprop() linkvalue = cgi.escape(linkcl.get(value, k)) + if showid: + label = value + title = ' title="%s"'%linkvalue + # note ... this should be urllib.quote(linkcl.get(value, k)) + else: + label = linkvalue if is_download: - return '<a href="%s%s/%s">%s</a>'%(linkname, value, - linkvalue, linkvalue) + return '<a href="%s%s/%s"%s>%s</a>'%(linkname, value, + linkvalue, title, label) else: - return '<a href="%s%s">%s</a>'%(linkname, value, linkvalue) + return '<a href="%s%s"%s>%s</a>'%(linkname, value, title, label) if isinstance(propclass, hyperdb.Multilink): linkname = propclass.classname linkcl = self.db.classes[linkname] @@ -367,12 +373,18 @@ l = [] for value in value: linkvalue = cgi.escape(linkcl.get(value, k)) + if showid: + label = value + title = ' title="%s"'%linkvalue + # note ... this should be urllib.quote(linkcl.get(value, k)) + else: + label = linkvalue if is_download: - l.append('<a href="%s%s/%s">%s</a>'%(linkname, value, - linkvalue, linkvalue)) + l.append('<a href="%s%s/%s"%s>%s</a>'%(linkname, value, + linkvalue, title, label)) else: - l.append('<a href="%s%s">%s</a>'%(linkname, value, - linkvalue)) + l.append('<a href="%s%s"%s>%s</a>'%(linkname, value, + title, label)) return ', '.join(l) if is_download: return '<a href="%s%s/%s">%s</a>'%(self.classname, self.nodeid, @@ -1114,6 +1126,10 @@ # # $Log: not supported by cvs2svn $ +# Revision 1.84 2002/03/29 19:41:48 rochecompaan +# . Fixed display of mutlilink properties when using the template +# functions, menu and plain. +# # Revision 1.83 2002/02/27 04:14:31 richard # Ran it through pychecker, made fixes #
