Mercurial > hg > rlgallery-misc
annotate web/archive.cgi @ 62:df7acc5653b3
Make the final depth appear in Advanced Rogue 5 tables.
Along the way, "SELECT name FROM table WHERE name = ..." was removed
from any queries where it had been carelessly placed.
| author | John "Elwin" Edwards | 
|---|---|
| date | Fri, 30 Jan 2015 20:24:47 -0500 | 
| parents | 6138c27d1950 | 
| children | 
| rev | line source | 
|---|---|
| 30 | 1 #!/usr/bin/python3 | 
| 0 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 2 | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 3 import cgi | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 4 import os | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 5 import sys | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 6 import time | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 7 import calendar | 
| 2 
8f49df4074d7
Convert web/archive.cgi to use the new SQL timestamps.
 John "Elwin" Edwards <elwin@sdf.org> parents: 
0diff
changeset | 8 from datetime import datetime | 
| 30 | 9 import pytz | 
| 49 
6138c27d1950
Escape the player's name when printing it into HTML.
 John "Elwin" Edwards parents: 
34diff
changeset | 10 import html | 
| 33 
25843238434a
Change the Python module's name back to rlgall.
 John "Elwin" Edwards parents: 
30diff
changeset | 11 import rlgall | 
| 6 
4778ab7de7aa
web/archive.cgi: disable cgitb by default.
 John "Elwin" Edwards <elwin@sdf.org> parents: 
5diff
changeset | 12 #import cgitb | 
| 0 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 13 | 
| 6 
4778ab7de7aa
web/archive.cgi: disable cgitb by default.
 John "Elwin" Edwards <elwin@sdf.org> parents: 
5diff
changeset | 14 #cgitb.enable() | 
| 0 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 15 | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 16 infop = """<p>Looking for ttyrec files? Don't like digging through Web directory listings, converting time zones in your head, or guessing how many files | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 17 the game was spread across? The Archivist can find them all for you.</p> | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 18 """ | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 19 | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 20 ttyrecbase = "/var/dgl/dgldir/ttyrec/" | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 21 | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 22 def input_game(outf, selected=None): | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 23 "Prints the form components for selecting a game." | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 24 selstr = '<option label="{0}" value="{1}" selected="selected">{0}</option>\n' | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 25 unselstr = '<option label="{0}" value="{1}">{0}</option>\n' | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 26 outf.write('<div>Dungeon name: <select name="game">\n') | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 27 for game in rlgall.gamelist: | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 28 # This will cause trouble if someone puts games with identical names | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 29 # into rlgall. | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 30 if selected and selected == game.uname: | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 31 outf.write(selstr.format(game.name, game.uname)) | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 32 else: | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 33 outf.write(unselstr.format(game.name, game.uname)) | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 34 outf.write('</select></div>\n') | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 35 return | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 36 | 
| 
5ba2123d2c20
Put this project under version control, finally.
 John "Elwin" Edwards <elwin@sdf.org> parents: diff
changeset | 37 def input_name(outf, defaultval=None): | 
