allow custom "last" value in url, eg to view all patches on one page
Sun Mar 28 16:40:18 UTC 2010 Simon Michael <simon@joyful.com>
* allow custom "last" value in url, eg to view all patches on one page
diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi
--- old-darcsweb/darcsweb.cgi 2013-07-18 20:21:52.000000000 +0000
+++ new-darcsweb/darcsweb.cgi 2013-07-18 20:21:52.000000000 +0000
@@ -23,6 +23,8 @@
iso_datetime = '%Y-%m-%dT%H:%M:%SZ'
+PATCHES_PER_PAGE = 50
+
# In order to be able to store the config file in /etc/darcsweb, it has to be
# added to sys.path. It's mainly used by distributions, which place the
# default configuration there. Add it second place, so it goes after '.' but
@@ -1144,7 +1146,7 @@
print '<div %s>' % cl + escape(l) + '</div>'
-def print_shortlog(last = 50, topi = 0, fname = None):
+def print_shortlog(last = PATCHES_PER_PAGE, topi = 0, fname = None):
ps = get_last_patches(last, topi, fname)
if fname:
@@ -1218,7 +1220,7 @@
print "</table>"
-def print_log(last = 50, topi = 0):
+def print_log(last = PATCHES_PER_PAGE, topi = 0):
ps = get_last_patches(last, topi)
if topi != 0:
@@ -1983,22 +1985,22 @@
sys.stdout.write(l.text)
-def do_shortlog(topi):
+def do_shortlog(topi, last=PATCHES_PER_PAGE):
print_header()
print_navbar()
- print_shortlog(topi = topi)
+ print_shortlog(topi = topi, last = last)
print_footer()
-def do_filehistory(topi, f):
+def do_filehistory(topi, f, last=PATCHES_PER_PAGE):
print_header()
print_navbar(f = fname)
- print_shortlog(topi = topi, fname = fname)
+ print_shortlog(topi = topi, fname = fname, last = last)
print_footer()
-def do_log(topi):
+def do_log(topi, last=PATCHES_PER_PAGE):
print_header()
print_navbar()
- print_log(topi = topi)
+ print_log(topi = topi, last = last)
print_footer()
def do_atom():
@@ -2532,7 +2534,7 @@
url_request = os.environ['QUERY_STRING']
# create a string representation of the request, ignoring all the
# unused parameters to avoid DoS
- params = ['r', 'a', 'f', 'h', 'topi']
+ params = ['r', 'a', 'f', 'h', 'topi', 'last']
params = [ x for x in form.keys() if x in params ]
url_request = [ (x, form[x].value) for x in params ]
url_request.sort()
@@ -2637,7 +2639,11 @@
topi = int(filter_num(form["topi"].value))
else:
topi = 0
- do_shortlog(topi)
+ if form.has_key("last"):
+ last = int(filter_num(form["last"].value))
+ else:
+ last = PATCHES_PER_PAGE
+ do_shortlog(topi=topi,last=last)
elif action == "filehistory":
if form.has_key("topi"):
@@ -2645,14 +2651,22 @@
else:
topi = 0
fname = filter_file(form["f"].value)
- do_filehistory(topi, fname)
+ if form.has_key("last"):
+ last = int(filter_num(form["last"].value))
+ else:
+ last = PATCHES_PER_PAGE
+ do_filehistory(topi, fname, last=last)
elif action == "log":
if form.has_key("topi"):
topi = int(filter_num(form["topi"].value))
else:
topi = 0
- do_log(topi)
+ if form.has_key("last"):
+ last = int(filter_num(form["last"].value))
+ else:
+ last = PATCHES_PER_PAGE
+ do_log(topi, last=last)
elif action == 'headblob':
fname = filter_file(form["f"].value)