Skip to content

Commit 0862913

Browse files
author
Richard Jones
committed
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.
1 parent c7c4563 commit 0862913

File tree

6 files changed

+90
-21
lines changed

6 files changed

+90
-21
lines changed

CHANGES.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4-
2002-03-?? - 0.4.1
4+
0.4.2
5+
Feature:
6+
. link() htmltemplate function now has a "showid" option for links and
7+
multilinks. When true, it only displays the linked node id as the anchor
8+
text. The link value is displayed as a tooltip using the title anchor
9+
attribute.
10+
To use in eg. the superseder field, have something like this:
11+
<td>
12+
<display call="field('superseder', showid=1)">
13+
<display call="classhelp('issue', 'id,title', label='list', width=500)">
14+
<property name="superseder">
15+
<br>View: <display call="link('superseder', showid=1)">
16+
</property>
17+
</td>
18+
19+
2002-03-25 - 0.4.1
520
Feature:
621
. use blobfiles in back_anydbm which is used in back_bsddb.
722
change test_db as dirlist does not work for subdirectories.

doc/customizing.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ highly customized.
321321
| |text. |
322322
| |Options: |
323323
| |property (property name) - the property to use in the second case. |
324+
| |showid - use the linked node id as the link text (linked node |
325+
| | "value" will be set as a tooltip) |
324326
+---------+-------------------------------------------------------------------+
325327
|count |For a Multilink property, display a count of the number of links in|
326328
| |the list. |
@@ -515,6 +517,21 @@ As shown in the example, the editor template can also request the display of a
515517
"note" field, which is a text area for entering a note to go along with a
516518
change.
517519

520+
The <property> tag used in the index may also be used here - it checks to see
521+
if the nominated Multilink property has any entries. This can be used to
522+
eliminate sections of the editor section if the property has no entries::
523+
524+
<td class="form-text">
525+
<display call="field('superseder', size=40, showid=1)">
526+
<display call="classhelp('issue', 'id,title', label='list', width=500)">
527+
<property name="superseder">
528+
<br>View: <display call="link('superseder', showid=1)">
529+
</property>
530+
</td>
531+
532+
The "View: " part with the links will only display if the superseder property
533+
has values.
534+
518535
When a change is submitted, the system automatically generates a message
519536
describing the changed properties.
520537

@@ -543,7 +560,7 @@ message nodes, and selecting a message takes you to its content.
543560

544561
The <property> tag used in the index may also be used here - it checks to see
545562
if the nominated Multilink property has any entries. This can be used to
546-
eliminate sections of the spool section if the property has no entries.::
563+
eliminate sections of the spool section if the property has no entries::
547564

548565
<property name="files">
549566
<tr class="strong-header">

roundup/htmltemplate.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: htmltemplate.py,v 1.84 2002-03-29 19:41:48 rochecompaan Exp $
18+
# $Id: htmltemplate.py,v 1.85 2002-04-02 01:40:58 richard Exp $
1919

2020
__doc__ = """
2121
Template engine.
2222
"""
2323

24-
import os, re, StringIO, urllib, cgi, errno, types
24+
import os, re, StringIO, urllib, cgi, errno, types, urllib
2525

2626
import hyperdb, date
2727
from i18n import _
@@ -331,7 +331,7 @@ def do_menu(self, property, size=None, height=None, showid=0):
331331
return _('[Menu: not a link]')
332332

333333
#XXX deviates from spec
334-
def do_link(self, property=None, is_download=0):
334+
def do_link(self, property=None, is_download=0, showid=0):
335335
'''For a Link or Multilink property, display the names of the linked
336336
nodes, hyperlinked to the item views on those nodes.
337337
For other properties, link to this node with the property as the
@@ -355,24 +355,36 @@ def do_link(self, property=None, is_download=0):
355355
linkcl = self.db.classes[linkname]
356356
k = linkcl.labelprop()
357357
linkvalue = cgi.escape(linkcl.get(value, k))
358+
if showid:
359+
label = value
360+
title = ' title="%s"'%linkvalue
361+
# note ... this should be urllib.quote(linkcl.get(value, k))
362+
else:
363+
label = linkvalue
358364
if is_download:
359-
return '<a href="%s%s/%s">%s</a>'%(linkname, value,
360-
linkvalue, linkvalue)
365+
return '<a href="%s%s/%s"%s>%s</a>'%(linkname, value,
366+
linkvalue, title, label)
361367
else:
362-
return '<a href="%s%s">%s</a>'%(linkname, value, linkvalue)
368+
return '<a href="%s%s"%s>%s</a>'%(linkname, value, title, label)
363369
if isinstance(propclass, hyperdb.Multilink):
364370
linkname = propclass.classname
365371
linkcl = self.db.classes[linkname]
366372
k = linkcl.labelprop()
367373
l = []
368374
for value in value:
369375
linkvalue = cgi.escape(linkcl.get(value, k))
376+
if showid:
377+
label = value
378+
title = ' title="%s"'%linkvalue
379+
# note ... this should be urllib.quote(linkcl.get(value, k))
380+
else:
381+
label = linkvalue
370382
if is_download:
371-
l.append('<a href="%s%s/%s">%s</a>'%(linkname, value,
372-
linkvalue, linkvalue))
383+
l.append('<a href="%s%s/%s"%s>%s</a>'%(linkname, value,
384+
linkvalue, title, label))
373385
else:
374-
l.append('<a href="%s%s">%s</a>'%(linkname, value,
375-
linkvalue))
386+
l.append('<a href="%s%s"%s>%s</a>'%(linkname, value,
387+
title, label))
376388
return ', '.join(l)
377389
if is_download:
378390
return '<a href="%s%s/%s">%s</a>'%(self.classname, self.nodeid,
@@ -1114,6 +1126,10 @@ def render(self, form):
11141126

11151127
#
11161128
# $Log: not supported by cvs2svn $
1129+
# Revision 1.84 2002/03/29 19:41:48 rochecompaan
1130+
# . Fixed display of mutlilink properties when using the template
1131+
# functions, menu and plain.
1132+
#
11171133
# Revision 1.83 2002/02/27 04:14:31 richard
11181134
# Ran it through pychecker, made fixes
11191135
#

roundup/templates/classic/html/issue.item

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323

2424
<tr bgcolor="ffffea">
2525
<td width=1% nowrap align=right><span class="form-label">Superseder</span></td>
26-
<td class="form-text"><display call="field('superseder', size=40, showid=1)">
27-
<display call="classhelp('issue', 'id,title', label='list', width=500)"></td>
26+
<td class="form-text">
27+
<display call="field('superseder', size=40, showid=1)">
28+
<display call="classhelp('issue', 'id,title', label='list', width=500)">
29+
<property name="superseder">
30+
<br>View: <display call="link('superseder', showid=1)">
31+
</property>
32+
</td>
2833
<td width=1% nowrap align=right><span class="form-label">Nosy List</span></td>
2934
<td class="form-text"><display call="field('nosy')">
3035
<display call="classhelp('user', 'username,realname,address,phone', label='list', width=500)"></td>

roundup/templates/extended/html/issue.item

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: issue.item,v 1.10 2002-02-22 00:06:58 richard Exp $-->
1+
<!-- $Id: issue.item,v 1.11 2002-04-02 01:40:59 richard Exp $-->
22
<table border=0 cellspacing=0 cellpadding=2>
33

44
<tr class="strong-header">
@@ -51,11 +51,21 @@
5151

5252
<tr bgcolor="ffffea">
5353
<td width=1% nowrap align=right><span class="form-label">Superseder</span></td>
54-
<td class="form-text"><display call="field('superseder', size=40, showid=1)">
55-
<display call="classhelp('issue', 'id,title', label='list', width=500)"></td>
54+
<td class="form-text">
55+
<display call="field('superseder', size=40, showid=1)">
56+
<display call="classhelp('issue', 'id,title', label='list', width=500)">
57+
<property name="superseder">
58+
<br>View: <display call="link('superseder', showid=1)">
59+
</property>
60+
</td>
5661
<td width=1% nowrap align=right><span class="form-label">Support call</span></td>
57-
<td class="form-text"><display call="field('supportcall', size=40, showid=1)">
58-
<display call="classhelp('support', 'id,title', label='list', width=500)"></td>
62+
<td class="form-text">
63+
<display call="field('supportcall', size=40, showid=1)">
64+
<display call="classhelp('support', 'id,title', label='list', width=500)">
65+
<property name="supportcall">
66+
<br>View: <display call="link('supportcall', showid=1)">
67+
</property>
68+
</td>
5969
</tr>
6070

6171
<tr bgcolor="ffffea">

roundup/templates/extended/html/support.item

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: support.item,v 1.4 2002-01-22 00:21:32 richard Exp $-->
1+
<!-- $Id: support.item,v 1.5 2002-04-02 01:40:59 richard Exp $-->
22
<table border=0 cellspacing=0 cellpadding=2>
33

44
<tr class="strong-header">
@@ -49,7 +49,13 @@
4949

5050
<tr bgcolor="ffffea">
5151
<td width=1% nowrap align=right><span class="form-label">Superseder</span></td>
52-
<td class="form-text"><display call="field('superseder', size=40, showid=1)"></td>
52+
<td class="form-text">
53+
<display call="field('superseder', size=40, showid=1)">
54+
<display call="classhelp('issue', 'id,title', label='list', width=500)">
55+
<property name="superseder">
56+
<br>View: <display call="link('superseder', showid=1)">
57+
</property>
58+
</td>
5359
<td width=1% nowrap align=right><span class="form-label">Nosy List</span></td>
5460
<td class="form-text"><display call="field('nosy')"></td>
5561
</tr>

0 commit comments

Comments
 (0)