diff options
author | Vincent Sanders <vince@kyllikki.org> | 2021-02-13 18:55:03 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2021-02-13 18:55:03 +0000 |
commit | e271bc41b3a8820d57b4d1fec95495a194d30849 (patch) | |
tree | b6a2cb1b5dc78e0afc028e8937e7a5964f085029 | |
parent | 0ed395f733752fb58a77c7cc20922dedba2944f2 (diff) | |
download | netsurf-test-e271bc41b3a8820d57b4d1fec95495a194d30849.tar.gz netsurf-test-e271bc41b3a8820d57b4d1fec95495a194d30849.tar.bz2 |
add start and reversed parameters to ordered list generator cgi
-rwxr-xr-x | cgi-bin/ordered-list.cgi | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/cgi-bin/ordered-list.cgi b/cgi-bin/ordered-list.cgi index 6548699..838e81d 100755 --- a/cgi-bin/ordered-list.cgi +++ b/cgi-bin/ordered-list.cgi @@ -25,15 +25,25 @@ def main(): liststyle = 'decimal' listcount = 1000 + liststart = 1 + listreverse = 0 + # get cgi parameters if 'liststyle' in params and re.match('^[A-Za-z0-9-]+$', params['liststyle'].value): liststyle = params['liststyle'].value if 'listcount' in params and re.match('^[0-9]+$', params['listcount'].value): listcount = int(params['listcount'].value) - if listcount > 10000: - listcount = 10000 + if 'liststart' in params and re.match('^[0-9-]+$', params['liststart'].value): + liststart = int(params['liststart'].value) + + if 'listreverse' in params and re.match('^[0-1]+$', params['listreverse'].value): + listreverse = int(params['listreverse'].value) + + # ensure count is reasonable + if listcount > 100000: + listcount = 100000 print('Content-Type: text/html') print('') @@ -47,8 +57,13 @@ def main(): print('</head>') print('<body>') print('<h1>ordered list marker test with',liststyle,'style</h1>') - print('<ol class="a">') - for num in range(1, listcount): + print('<ol class="a"', end='') + if liststart != 1: + print(' start="{}"'.format(liststart), end='') + if listreverse != 0: + print(' reversed', end='') + print('>') + for num in range(liststart, (liststart + listcount)): print('<li>',num,'</li>', sep="") print('</ol>') |