From 742d1a0c35897a0eeed36d327db12daee303f7d2 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 7 Oct 2009 15:16:15 -0600 Subject: [PATCH] Display what points your team has already made --- ctf.css | 4 ++++ ctf/config.py | 20 ++++++++++++++++++++ ctf/puzzler.py | 48 +++++++++++++++++++++--------------------------- ctf/register.py | 8 ++++---- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/ctf.css b/ctf.css index b9aa22b..4131ef8 100644 --- a/ctf.css +++ b/ctf.css @@ -77,3 +77,7 @@ p { margin-bottom: 20px; color: #f4f4f4; } + +.solved { + text-decoration: line-through; +} \ No newline at end of file diff --git a/ctf/config.py b/ctf/config.py index 034eb71..56ab872 100755 --- a/ctf/config.py +++ b/ctf/config.py @@ -66,3 +66,23 @@ def datafile(filename): def url(path): return base_url + path + +def start_html(title): + if os.environ.get('GATEWAY_INTERFACE'): + print('Content-type: text/html') + print() + print(''' + + + + %s + + + +

%s

+''' % (title, css, title)) + +def end_html(): + print('') diff --git a/ctf/puzzler.py b/ctf/puzzler.py index 48e487e..e6d44a6 100755 --- a/ctf/puzzler.py +++ b/ctf/puzzler.py @@ -27,7 +27,7 @@ cat_re = re.compile(r'^[a-z]+$') points_re = re.compile(r'^[0-9]+$') def dbg(*vals): - print('<--: \nContent-type: text/html\n\n-->
')
+    print('
')
     print(*vals)
     print('
') @@ -59,32 +59,16 @@ passwd = f.getfirst('w', passwd) key = f.getfirst('k') def start_html(title): - if os.environ.get('GATEWAY_INTERFACE'): - print('Content-type: text/html') - if team or passwd: - c = http.cookies.SimpleCookie() - if team: - c['team'] = team - if passwd: - c['passwd'] = passwd - print(c) - print() - print(''' - - - - %s - - - -

%s

-''' % (title, config.css, title)) - -def end_html(): - print('') + if team or passwd: + c = http.cookies.SimpleCookie() + if team: + c['team'] = team + if passwd: + c['passwd'] = passwd + print(c) + config.start_html(title) +end_html = config.end_html def safe_join(*args): safe = list(args[:1]) @@ -125,7 +109,17 @@ def show_puzzles(cat, cat_dir): if puzzles: print('') diff --git a/ctf/register.py b/ctf/register.py index b41a7f2..95e8e92 100755 --- a/ctf/register.py +++ b/ctf/register.py @@ -33,7 +33,7 @@ def main(): pw = f.getfirst('pw') confirm_pw = f.getfirst('confirm_pw') - html = string.Template(head('Team Registration') + + html = string.Template(config.start_html('Team Registration') + ('''

Pick a short team name: you'll be typing it a lot. @@ -58,7 +58,7 @@ def main(): ''' % config.url('register.cgi')) + - foot()) + config.end_html()) if not (team and pw and confirm_pw): # If we're starting from the beginning? html = html.substitute(team_error='', @@ -71,9 +71,9 @@ def main(): pw_match_error='Passwords do not match') else: teams.add(team, pw) - html = (head('Team registered') + + html = (config.start_html('Team registered') + ('

Congratulations, %s is now registered. Go back to the front page and start playing!

' % (team, config.url(''))) + - foot()) + config.end_html()) print(html)