Display what points your team has already made

This commit is contained in:
Neale Pickett 2009-10-07 15:16:15 -06:00
parent ca86e03fd3
commit 742d1a0c35
4 changed files with 49 additions and 31 deletions

View File

@ -77,3 +77,7 @@ p {
margin-bottom: 20px; margin-bottom: 20px;
color: #f4f4f4; color: #f4f4f4;
} }
.solved {
text-decoration: line-through;
}

View File

@ -66,3 +66,23 @@ def datafile(filename):
def url(path): def url(path):
return base_url + path return base_url + path
def start_html(title):
if os.environ.get('GATEWAY_INTERFACE'):
print('Content-type: text/html')
print()
print('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>%s</title>
<link rel="stylesheet" href="%s" type="text/css" />
</head>
<body>
<h1>%s</h1>
''' % (title, css, title))
def end_html():
print('</body></html>')

View File

@ -27,7 +27,7 @@ cat_re = re.compile(r'^[a-z]+$')
points_re = re.compile(r'^[0-9]+$') points_re = re.compile(r'^[0-9]+$')
def dbg(*vals): def dbg(*vals):
print('<--: \nContent-type: text/html\n\n--><pre>') print('<!--: \nContent-type: text/html\n\n--><pre>')
print(*vals) print(*vals)
print('</pre>') print('</pre>')
@ -59,8 +59,6 @@ passwd = f.getfirst('w', passwd)
key = f.getfirst('k') key = f.getfirst('k')
def start_html(title): def start_html(title):
if os.environ.get('GATEWAY_INTERFACE'):
print('Content-type: text/html')
if team or passwd: if team or passwd:
c = http.cookies.SimpleCookie() c = http.cookies.SimpleCookie()
if team: if team:
@ -68,23 +66,9 @@ def start_html(title):
if passwd: if passwd:
c['passwd'] = passwd c['passwd'] = passwd
print(c) print(c)
print() config.start_html(title)
print('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>%s</title>
<link rel="stylesheet" href="%s" type="text/css" />
</head>
<body>
<h1>%s</h1>
''' % (title, config.css, title))
def end_html():
print('</body></html>')
end_html = config.end_html
def safe_join(*args): def safe_join(*args):
safe = list(args[:1]) safe = list(args[:1])
@ -125,7 +109,17 @@ def show_puzzles(cat, cat_dir):
if puzzles: if puzzles:
print('<ul>') print('<ul>')
for p in puzzles: for p in puzzles:
print('<li><a href="%s/%s/%d">%d</a></li>' % (base_url, cat, p, p)) cls = ''
try:
if p in points_by_team[(team, cat)]:
cls = 'solved'
except KeyError:
pass
print('<li><a href="%(base)s/%(cat)s/%(points)d" class="%(class)s">%(points)d</a></li>' %
{'base': base_url,
'cat': cat,
'points': p,
'class': cls})
if p > opened: if p > opened:
break break
print('</ul>') print('</ul>')

View File

@ -33,7 +33,7 @@ def main():
pw = f.getfirst('pw') pw = f.getfirst('pw')
confirm_pw = f.getfirst('confirm_pw') confirm_pw = f.getfirst('confirm_pw')
html = string.Template(head('Team Registration') + html = string.Template(config.start_html('Team Registration') +
(''' ('''
<p> <p>
Pick a short team name: you'll be typing it a lot. Pick a short team name: you'll be typing it a lot.
@ -58,7 +58,7 @@ def main():
<input type="submit" value="Register" /> <input type="submit" value="Register" />
</fieldset> </fieldset>
</form>''' % config.url('register.cgi')) + </form>''' % config.url('register.cgi')) +
foot()) config.end_html())
if not (team and pw and confirm_pw): # If we're starting from the beginning? if not (team and pw and confirm_pw): # If we're starting from the beginning?
html = html.substitute(team_error='', html = html.substitute(team_error='',
@ -71,9 +71,9 @@ def main():
pw_match_error='Passwords do not match') pw_match_error='Passwords do not match')
else: else:
teams.add(team, pw) teams.add(team, pw)
html = (head('Team registered') + html = (config.start_html('Team registered') +
('<p>Congratulations, <samp>%s</samp> is now registered. Go <a href="%s">back to the front page</a> and start playing!</p>' % (team, config.url(''))) + ('<p>Congratulations, <samp>%s</samp> is now registered. Go <a href="%s">back to the front page</a> and start playing!</p>' % (team, config.url(''))) +
foot()) config.end_html())
print(html) print(html)