Mercurial > hg > rlgallery-misc
annotate web/scoring/players/index.cgi @ 55:e421ea2519ec
dgamelaunch: define user/group by name instead of UID/GID.
The user and group might not be created with the UID and GID expected,
so it is better to use names. They can be changed to numeric values
after installation.
author | John "Elwin" Edwards |
---|---|
date | Sun, 11 May 2014 08:32:31 -0700 |
parents | 6138c27d1950 |
children |
rev | line source |
---|---|
30 | 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 | 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) |