Skip to content

Commit e8fcc8a

Browse files
author
Justus Pendleton
committed
Allow template for tracker index page
[SF#058020] requested the ability to have a user-specified template page for the tracker index that is generated when roundup-server is handling multiple trackers. This adds a "-i" option that allows them to specify a template.
1 parent 529852c commit e8fcc8a

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

doc/admin_guide.txt

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

5-
:Version: $Revision: 1.23 $
5+
:Version: $Revision: 1.24 $
66

77
.. contents::
88

@@ -82,6 +82,7 @@ The basic configuration file layout is as follows (take from the
8282
;log_ip = yes
8383
;pidfile =
8484
;logfile =
85+
;template =
8586

8687
[trackers]
8788
; Add one of these per tracker being served
@@ -109,6 +110,10 @@ are as follows:
109110
written to this file. It must be specified if **pidfile** is specified.
110111
If per-tracker logging is specified, then very little will be written to
111112
this file.
113+
**template**
114+
Specifies a template used for displaying the tracker index when
115+
multiple trackers are being used. The variable "trackers" is available
116+
to the template and is a dict of all configured trackers.
112117
**trackers** section
113118
Each line denotes a mapping from a URL component to a tracker home.
114119
Make sure the name part doesn't include any url-unsafe characters like

doc/roundup-server.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Daemonize, and write the server's PID to the nominated file.
2121
Sets a filename to log to (instead of stdout). This is required if the -d
2222
option is used.
2323
.TP
24+
\fB-i\fP \fIfile\fP
25+
Sets a filename to use as a template for generating the tracker index page.
26+
The variable "trackers" is available to the template and is a dict of all
27+
configured trackers.
28+
.TP
2429
\fB-h\fP
2530
print help
2631
.TP

doc/roundup-server.ini.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
; This is a sample configuration file for roundup-server. See the
22
; admin_guide for information about its contents.
3-
[server]
3+
[main]
44
port = 8080
55
;hostname =
66
;user =
77
;group =
88
;log_ip = yes
99
;pidfile =
1010
;logfile =
11+
;template =
1112

1213

1314
; Add one of these per tracker being served
14-
[tracker_url_component]
15+
[trackers]
1516
home = /path/to/tracker
1617

roundup/scripts/roundup_server.py

Lines changed: 23 additions & 9 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.88 2007-04-23 19:35:41 forsberg Exp $
20+
$Id: roundup_server.py,v 1.89 2007-09-02 16:05:36 jpend Exp $
2121
"""
2222
__docformat__ = 'restructuredtext'
2323

@@ -30,6 +30,7 @@
3030

3131
# Roundup modules of use here
3232
from roundup.cgi import cgitb, client
33+
from roundup.cgi.PageTemplates.PageTemplate import PageTemplate
3334
import roundup.instance
3435
from roundup.i18n import _
3536

@@ -152,17 +153,26 @@ def index(self):
152153
self.end_headers()
153154
else:
154155
self.send_response(200)
156+
155157
self.send_header('Content-Type', 'text/html')
156158
self.end_headers()
157159
w = self.wfile.write
158-
w(_('<html><head><title>Roundup trackers index</title></head>\n'
159-
'<body><h1>Roundup trackers index</h1><ol>\n'))
160-
keys.sort()
161-
for tracker in keys:
162-
w('<li><a href="%(tracker_url)s/index">%(tracker_name)s</a>\n'%{
163-
'tracker_url': urllib.quote(tracker),
164-
'tracker_name': cgi.escape(tracker)})
165-
w('</ol></body></html>')
160+
161+
if self.CONFIG and self.CONFIG['TEMPLATE']:
162+
template = open(self.CONFIG['TEMPLATE']).read()
163+
pt = PageTemplate()
164+
pt.write(template)
165+
extra = { 'trackers': self.TRACKERS }
166+
w(pt.pt_render(extra_context=extra))
167+
else:
168+
w(_('<html><head><title>Roundup trackers index</title></head>\n'
169+
'<body><h1>Roundup trackers index</h1><ol>\n'))
170+
keys.sort()
171+
for tracker in keys:
172+
w('<li><a href="%(tracker_url)s/index">%(tracker_name)s</a>\n'%{
173+
'tracker_url': urllib.quote(tracker),
174+
'tracker_name': cgi.escape(tracker)})
175+
w('</ol></body></html>')
166176

167177
def inner_run_cgi(self):
168178
''' This is the inner part of the CGI handling
@@ -394,6 +404,8 @@ class ServerConfig(configuration.Config):
394404
(configuration.Option, "multiprocess", DEFAULT_MULTIPROCESS,
395405
"Set processing of each request in separate subprocess.\n"
396406
"Allowed values: %s." % ", ".join(MULTIPROCESS_TYPES)),
407+
(configuration.NullableFilePathOption, "template", "",
408+
"Tracker index template. If unset, built-in will be used."),
397409
)),
398410
("trackers", (), "Roundup trackers to serve.\n"
399411
"Each option in this section defines single Roundup tracker.\n"
@@ -414,6 +426,7 @@ class ServerConfig(configuration.Config):
414426
"nodaemon": "D",
415427
"log_hostnames": "N",
416428
"multiprocess": "t:",
429+
"template": "i:",
417430
}
418431

419432
def __init__(self, config_file=None):
@@ -595,6 +608,7 @@ def usage(message=''):
595608
-p <port> set the port to listen on (default: %(port)s)
596609
-l <fname> log to the file indicated by fname instead of stderr/stdout
597610
-N log client machine names instead of IP addresses (much slower)
611+
-i set tracker index template
598612
-t <mode> multiprocess mode (default: %(mp_def)s).
599613
Allowed values: %(mp_types)s.
600614
%(os_part)s

0 commit comments

Comments
 (0)