Skip to content

Commit ddcf0f1

Browse files
author
Richard Jones
committed
Web interface tweaks.
- added a favicon - added url_quote and html_quote methods to the utils object - added isset method to HTMLProperty - added "download_url" method to generate a correctly quoted URL for file download links [SF#927745]
1 parent 8dfecd5 commit ddcf0f1

File tree

7 files changed

+84
-15
lines changed

7 files changed

+84
-15
lines changed

CHANGES.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ are given with the most recent entry first.
33

44
2004-??-?? 0.7.0
55
Feature:
6-
- added a favicon (with crappy white background)
6+
- added a favicon
7+
- added url_quote and html_quote methods to the utils object
8+
- added isset method to HTMLProperty
79

810
Fixed:
911
- CSV export was busted (as was any action returning a result)
@@ -12,6 +14,8 @@ Fixed:
1214
- MySQL and Postgresql use BOOL/BOOLEAN for Boolean types
1315
- OTK generation was busted (thanks Stuart D. Gathman)
1416
- export and import now include journals (incompatible with export < 0.7)
17+
- added "download_url" method to generate a correctly quoted URL for file
18+
download links (sf bug 927745)
1519

1620

1721
2004-03-27 0.7.0b2

doc/customizing.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.131 $
5+
:Version: $Revision: 1.132 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1602,6 +1602,8 @@ hasPermission specific to the "user" class - determine whether the
16021602
is_edit_ok is the user allowed to Edit the current item?
16031603
is_view_ok is the user allowed to View the current item?
16041604
is_retired is the item retired?
1605+
download_url generates a url-quoted link for download of FileClass
1606+
item contents (ie. file<id>/<name>)
16051607
=============== ========================================================
16061608

16071609
Note that if you have a property of the same name as one of the above
@@ -1713,6 +1715,7 @@ menu only on Link and Multilink properties - render a form select
17131715
list for this property
17141716
reverse only on Multilink properties - produce a list of the linked
17151717
items in reverse order
1718+
isset returns True if the property has been set to a value
17161719
=========== ================================================================
17171720

17181721
All of the above functions perform checks for permissions required to
@@ -1862,6 +1865,8 @@ as described below.
18621865
Method Description
18631866
=============== ========================================================
18641867
Batch return a batch object using the supplied list
1868+
url_quote quote some text as safe for a URL (ie. space, %, ...)
1869+
html_quote quote some text as safe in HTML (ie. <, >, ...)
18651870
=============== ========================================================
18661871

18671872
You may add additional utility methods by writing them in your tracker

doc/roundup-favicon.ico

0 Bytes
Binary file not shown.

doc/whatsnew-0.7.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,27 @@ The stylesheet includes printer settings now too, so printed pages
217217
don't include the sidebar.
218218

219219

220+
Quoting of URLs and HTML
221+
------------------------
222+
223+
Templates that wish to offer file downloads may now use a new
224+
``download_url`` method:
225+
226+
<tr tal:repeat="file context/files">
227+
<td>
228+
<a tal:attributes="href file/download_url"
229+
tal:content="file/name">dld link</a>
230+
</td>
231+
...
232+
233+
The ``download_url`` method looks up the file's "id" and "name" and
234+
generates a correctly-quoted URL.
235+
236+
Additionally, users wishing to URL- or HTML- quote text in their templates
237+
may use the new ``utils.url_quote(url)`` and ``utils.html_quote(html)``
238+
methods.
239+
240+
220241
Email Interface
221242
===============
222243

roundup/cgi/templating.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
"""Implements the API used in the HTML templating for the web interface.
22
"""
3+
4+
todo = '''
5+
- Most methods should have a "default" arg to supply a value
6+
when none appears in the hyperdb or request.
7+
- Multilink property additions: change_note and new_upload
8+
- Add class.find() too
9+
- NumberHTMLProperty should support numeric operations
10+
- HTMLProperty should have an isset() method
11+
'''
12+
313
__docformat__ = 'restructuredtext'
414

515
from __future__ import nested_scopes
@@ -900,6 +910,15 @@ def renderQueryForm(self):
900910
# use our fabricated request
901911
return pt.render(self._client, req.classname, req)
902912

913+
def download_url(self):
914+
''' Assume that this item is a FileClass and that it has a name
915+
and content. Construct a URL for the download of the content.
916+
'''
917+
name = self._klass.get(self._nodeid, 'name')
918+
url = '%s%s/%s'%(self._classname, self._nodeid, name)
919+
return urllib.quote(url)
920+
921+
903922
class HTMLUserPermission:
904923

905924
def is_edit_ok(self):
@@ -995,6 +1014,10 @@ def __cmp__(self, other):
9951014
return cmp(self._value, other._value)
9961015
return cmp(self._value, other)
9971016

1017+
def isset(self):
1018+
'''Is my _value None?'''
1019+
return self._value is None
1020+
9981021
def is_edit_ok(self):
9991022
''' Is the user allowed to Edit the current class?
10001023
'''
@@ -1527,6 +1550,10 @@ def __contains__(self, value):
15271550
'''
15281551
return str(value) in self._value
15291552

1553+
def isset(self):
1554+
'''Is my _value []?'''
1555+
return self._value == []
1556+
15301557
def reverse(self):
15311558
''' return the list in reverse order
15321559
'''
@@ -2084,3 +2111,11 @@ def Batch(self, sequence, size, start, end=0, orphan=0, overlap=0):
20842111
return Batch(self.client, sequence, size, start, end, orphan,
20852112
overlap)
20862113

2114+
def url_quote(self, url):
2115+
'''URL-quote the supplied text.'''
2116+
return urllib.quote(url)
2117+
2118+
def html_quote(self, html):
2119+
'''HTML-quote the supplied text.'''
2120+
return cgi.escape(url)
2121+

roundup/scripts/roundup_server.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
"""Command-line script that runs a server over roundup.cgi.client.
1919
20-
$Id: roundup_server.py,v 1.40 2004-04-02 06:38:42 richard Exp $
20+
$Id: roundup_server.py,v 1.41 2004-04-05 00:51:45 richard Exp $
2121
"""
2222
__docformat__ = 'restructuredtext'
2323

@@ -32,6 +32,11 @@
3232
import roundup.instance
3333
from roundup.i18n import _
3434

35+
try:
36+
import signal
37+
except:
38+
signal = None
39+
3540
#
3641
## Configuration
3742
#
@@ -60,17 +65,16 @@
6065

6166
import zlib, base64
6267
favico = zlib.decompress(base64.decodestring('''
63-
eJztkTlM2lEcgD9aoEqL0FqFIhahKFIsPbWtLcUeWuxBCxZb6kLi0oE4GDcHj0Tj6mDiYDQmJg4m
64-
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6fZ39/n+3tbdbW1pAkiYWFBWZmZtjb2yMejzM8PEwgEMDn85HNZonFYqjV
73+
asLhMMvLy2QyGfR6PaOjowwODmKxWDg+PkalUhEKhSgUCiwtLWE2m9nZ2UGhULCxscHp6SmpVIpo
74+
NMrs7CwHBwdotVoSiQRXXPG/IzY7RHtt922xjFRb01H1XhKfPBNbi/7my7rrLXJ88eppvxwEfV3f
75+
NY3Y6exofVdsV3+2wnPFDdPjB83n7xuVpcFvygPbGwxF31LZIKrQDfR2Xvh7lmrX654L/7bvlnng
76+
bn3Zuj8M9Hepux6VfZtW1yA6K7cfGqVu8TL325u+fHTb71QKbk+7TZQ+lTc6RcnpqW8qmVQBoj/g
77+
23eo0sr/NIGvB37K+lOWXMvJ+uWFeKGU/03Cb7n3D4M3wxI=
7478
'''.strip()))
7579

7680
class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):

templates/classic/html/issue.item.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<tr><th>File name</th><th>Uploaded</th><th>Type</th><th>Edit</th></tr>
104104
<tr tal:repeat="file context/files">
105105
<td>
106-
<a tal:attributes="href string:file${file/id}/${file/name}"
106+
<a tal:attributes="href file/download_url"
107107
tal:content="file/name">dld link</a>
108108
</td>
109109
<td>

0 commit comments

Comments
 (0)