annotate web/scoring/players/index.cgi @ 86:5f1b4d3151bb

Add some neglected dgamelaunch initialization commands.
author John "Elwin" Edwards
date Sat, 24 Nov 2018 10:34:26 -0500
parents 6138c27d1950
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
e8f3b7994d88 Port to Python 3.
John "Elwin" Edwards
parents: 10
diff changeset
1 #!/usr/bin/python3
10
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
2
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
3 import os
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
4 import sys
49
6138c27d1950 Escape the player's name when printing it into HTML.
John "Elwin" Edwards
parents: 33
diff changeset
5 import html
33
25843238434a Change the Python module's name back to rlgall.
John "Elwin" Edwards
parents: 30
diff changeset
6 import rlgall
10
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
7
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
8 playerdir = "/var/www/lighttpd/scoring/players/"
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
9 linkstr = '<li><a href="./{0}.html">{0}</a></li>\n'
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
10
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
11 filelist = os.listdir(playerdir)
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
12 namelist = []
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
13
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
14 for filename in filelist:
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
15 if filename.endswith(".html"):
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
16 namelist.append(filename.rsplit(".html", 1)[0])
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
17 namelist.sort()
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
18
30
e8f3b7994d88 Port to Python 3.
John "Elwin" Edwards
parents: 10
diff changeset
19 sys.stdout.write("Content-Type: text/html; charset=utf-8\r\n\r\n")
10
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
20 sys.stdout.write(rlgall.phead.format("Players"))
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
21 sys.stdout.write(rlgall.ptop)
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
22 sys.stdout.write(rlgall.navscore.format("Players"))
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
23 sys.stdout.write(rlgall.pti.format("Players"))
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
24
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
25 if not namelist:
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
26 sys.stdout.write("<p>No one is here.</p>\n")
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
27 else:
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
28 sys.stdout.write("<ul>\n")
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
29 for name in namelist:
49
6138c27d1950 Escape the player's name when printing it into HTML.
John "Elwin" Edwards
parents: 33
diff changeset
30 sys.stdout.write(linkstr.format(html.escape(name)))
10
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
31 sys.stdout.write("</ul>\n")
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
32
17f656035775 Import the web/scoring/ files.
John "Elwin" Edwards <elwin@sdf.org>
parents:
diff changeset
33 sys.stdout.write(rlgall.pend)