diff --git a/Makefile b/Makefile index d644fd8..e6dd21d 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,10 @@ target: $(PYC) $(INSTALL) -d $(PYCDIR)/ctf $(INSTALL) $(PYC) $(PYCDIR)/ctf + $(INSTALL) -d $(DESTDIR)/usr/lib/python2.6/site-packages/ctf + $(INSTALL) ctf/__init__.py $(DESTDIR)/usr/lib/python2.6/site-packages/ctf + $(INSTALL) ctf/config.py $(DESTDIR)/usr/lib/python2.6/site-packages/ctf + $(INSTALL) -d $(DESTDIR)/usr/sbin $(INSTALL) ctfd.py $(DESTDIR)/usr/sbin $(INSTALL) new-contest $(DESTDIR)/usr/sbin diff --git a/ctf.css b/ctf.css index 433b9c6..0d6ed28 100644 --- a/ctf.css +++ b/ctf.css @@ -7,7 +7,7 @@ html { body { font-family: sans-serif; color: #fff; - margin: 50px 0 0 100px; + margin: 50px 0 0 110px; padding: 10px; max-width: 700px; } @@ -33,7 +33,7 @@ h1:first-child:before { /*** left side bar ***/ #navigation { - position: fixed; + position: absolute; background: #222; opacity: 0.9; top: 80px; @@ -41,6 +41,11 @@ h1:first-child:before { padding: 0; } +#navigation h3 { + font-size: 100%; + border-bottom: 2px solid #444; +} + #navigation ul { list-style: none; padding: 0; @@ -113,6 +118,27 @@ p { color: #f4f4f4; } +hr { + border: 1px solid #444; +} + +dt { + white-space: pre; + background-color: #333; + padding: 5px; + border: 2px solid green; + border-bottom: none; + font-weight: bold; +} + +dd { + border: 2px solid green; + margin: 0px; + padding: 5px; + background-color: #282828; +} + + /**** special cases ****/ .wide { diff --git a/ctf/config.py b/ctf/config.py index 4bdfe25..e39eacc 100755 --- a/ctf/config.py +++ b/ctf/config.py @@ -77,7 +77,7 @@ def datafile(filename): def url(path): return base_url + path -def start_html(title, hdr='', cls=''): +def start_html(title, hdr='', cls='', links=[], links_title=None): ret = [] if os.environ.get('GATEWAY_INTERFACE'): ret.append('Content-type: text/html') @@ -98,16 +98,24 @@ def start_html(title, hdr='', cls=''): - ''' % {'title': title, 'css': css, 'hdr': hdr, 'base': base_url, 'class': cls}) + if links: + if links_title: + ret.append('

%s

' % links_title) + else: + ret.append('
') + for url, name in links: + ret.append('
  • %s
  • ' % (url, name)) + ret.append(' ') return '\n'.join(ret) def end_html(): diff --git a/tanks/lib/Program.py b/tanks/lib/Program.py index ad30b1d..2063d1f 100644 --- a/tanks/lib/Program.py +++ b/tanks/lib/Program.py @@ -7,7 +7,7 @@ skills at designing those wits to survive.

    Programming Your Tank

    Your tanks are programmed using the Super Useful Command and Kontrol language, -the very best in laser tank AI languages. It includes amazing feature such +the very best in laser tank AI languages. It includes amazing features such as comments (Started by a #, ended at EOL), logic, versatility, and semi-colons (all lines must end in one). As with all new military systems it utilizes only integers; we must never rest in our diff --git a/tanks/lib/docs.py b/tanks/lib/docs.py index 1724d52..0318250 100644 --- a/tanks/lib/docs.py +++ b/tanks/lib/docs.py @@ -4,9 +4,8 @@ def mkDocTable(objects): objects.sort(lambda o1, o2: cmp(o1.__doc__, o2.__doc__)) for object in objects: - print '' if object.__doc__ is None: - print '
    %s
    Bad object' % \ + print '
    %s
    Bad object
    ' % \ xml.sax.saxutils.escape(str(object)) continue text = object.__doc__ @@ -23,5 +22,5 @@ def mkDocTable(objects): body = '\n'.join(body) print '
    %s
    %s
    ' % (head, body) #print '
    %sIntentionally blank
    %s' % (head, body) - print '
    ' + diff --git a/tanks/www/ctf.css b/tanks/www/ctf.css deleted file mode 100644 index cf21d76..0000000 --- a/tanks/www/ctf.css +++ /dev/null @@ -1,104 +0,0 @@ -/**** document ****/ - -html { - background: #222 url(grunge.png) repeat-x; -} - -body { - font-family: sans-serif; - color: #eee; - margin: 50px 0 0 100px; - padding: 10px; - max-width: 700px; -} - -/**** heading ****/ - -h1:first-child { - text-transform: lowercase; - font-size: 1.6em; -/* background-color: #222; */ -/* opacity: 0.9; */ - padding: 3px; - color: #2a2; - margin: 0 0 1em 70px; -} - -h1:first-child:before { - color: #fff; - letter-spacing: -0.1em; - content: "Capture The Flag: "; -} - -/**** body ****/ - -a img { - border: 0px; -} - -a { - text-decoration: none; - color: #2a2; - font-weight: bold; -} - -a:hover { - color: #fff; - background: #2a2; - font-weight: bold; -} - - -h1, h2, h3 { - color: #999; - letter-spacing: -0.05em; -} - -code, pre, .readme, div.errors { - color: #fff; - background-color: #555; - margin: 1em; -} - -th, td { - vertical-align: top; -} - -.scoreboard td { - height: 400px; -} - -p { - line-height: 1.4em; - margin-bottom: 20px; - color: #f4f4f4; -} - -dt { - white-space: pre; -} - -dt div.tab { - background-color: #333; - display: inline-block; - padding: 5px; - border: 3px solid green; - border-bottom: none; - font-weight: bold; -} - -dd { - border: 3px solid green; - margin: 0px; - padding: 5px; - background-color: #282828; -} - -fieldset * { - margin: 3px; -} - -table.results td, th{ - padding : 3px; - font-weight : bold; -} diff --git a/tanks/www/docs.cgi b/tanks/www/docs.cgi index 26306e3..6a6b514 100755 --- a/tanks/www/docs.cgi +++ b/tanks/www/docs.cgi @@ -1,10 +1,9 @@ #!/usr/bin/python -print """Content-Type: text/html\n\n""" -print """\n\n""" import cgitb; cgitb.enable() import os import sys +from ctf import config try: from tanks import Program, setup, conditions, actions, docs @@ -15,10 +14,13 @@ except: sys.path.append(os.path.join('/', *path)) import Program, setup, conditions, actions, docs -print open('head.html').read() % "Documentation" -print '' -print '

    Pflanzarr Documentation

    ' -print open('links.html').read() +print(config.start_html('Tanks Documentation', + links_title='Tanks', + links=[('docs.cgi', 'Docs'), + ('results.cgi', 'Results'), + ('submit.html', 'Submit'), + ('errors.cgi', 'My Errors')])) + print Program.__doc__ print '

    Setup Actions:

    ' @@ -34,4 +36,4 @@ print '

    Actions:

    ' print 'These actions are not for cowards. Remember, if actions contradict, your tank will simply do the last thing it was told in a turn. If ordered to hop on a plane to hell it will gladly do so. If order to make tea shortly afterwards, it will serve it politely and with cookies instead.

    ' docs.mkDocTable(actions.actions.values()) -print '' +print(config.end_html()) diff --git a/tanks/www/errors.cgi b/tanks/www/errors.cgi index 821082a..5f6adf5 100755 --- a/tanks/www/errors.cgi +++ b/tanks/www/errors.cgi @@ -1,7 +1,5 @@ #!/usr/bin/python3 -print("""Content-Type: text/html\n\n""") -print("""\n\n""") import cgi import cgitb; cgitb.enable() import sys @@ -20,15 +18,18 @@ except: path = '/home/pflarr/repos/gctf/' sys.path.append(path) from ctf import teams +from ctf import config teams.build_teams() -head = open('head.html').read() % "Error Report" -print(head) -print('

    Your Errors

    ') -print(open('links.html').read()) +print(config.start_html('Tanks Errors', + links_title='Tanks', + links=[('docs.cgi', 'Docs'), + ('results.cgi', 'Results'), + ('submit.html', 'Submit'), + ('errors.cgi', 'My Errors')])) def done(): - print('') + print(config.end_html()) sys.exit(0) fields = cgi.FieldStorage() diff --git a/tanks/www/grunge.png b/tanks/www/grunge.png deleted file mode 100644 index 2b98730..0000000 Binary files a/tanks/www/grunge.png and /dev/null differ diff --git a/tanks/www/head.html b/tanks/www/head.html deleted file mode 100644 index f2b66ea..0000000 --- a/tanks/www/head.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - %s - diff --git a/tanks/www/links.html b/tanks/www/links.html deleted file mode 100644 index 1615bf7..0000000 --- a/tanks/www/links.html +++ /dev/null @@ -1,4 +0,0 @@ -Documentation | -Results | -Submit | -My Errors diff --git a/tanks/www/results.cgi b/tanks/www/results.cgi index 3055cf7..0edbf7c 100755 --- a/tanks/www/results.cgi +++ b/tanks/www/results.cgi @@ -2,16 +2,16 @@ import cgitb; cgitb.enable() import os +from ctf import config import Config -print """Content-Type: text/html\n\n""" -print """\n\n""" -head = open('head.html').read() % "Pflanzarr Results" -print head -print "

    Results

    " -print open('links.html').read() - +print(config.start_html('Tanks Results', + links_title='Tanks', + links=[('docs.cgi', 'Docs'), + ('results.cgi', 'Results'), + ('submit.html', 'Submit'), + ('errors.cgi', 'My Errors')])) try: winner = open(os.path.join(Config.DATA_PATH, 'winner')).read() except: @@ -52,4 +52,4 @@ for num in gameNums: print 'v' % num, print 'r' % num -print '' +print(config.end_html()) diff --git a/tanks/www/submit.cgi b/tanks/www/submit.cgi index 5dad944..ded20f7 100755 --- a/tanks/www/submit.cgi +++ b/tanks/www/submit.cgi @@ -1,7 +1,5 @@ #!/usr/bin/python3 -print("Content-Type: text/html\n\n") -print("""\n\n""") import cgi import cgitb; cgitb.enable() import os @@ -20,15 +18,18 @@ except: path = '/home/pflarr/repos/gctf/' sys.path.append(path) from ctf import teams +from ctf import config teams.build_teams() -head = open('head.html').read() % "Submission Results" -print(head) -print("

    Results

    ") -print(open('links.html').read()) +print(config.start_html('Tanks Submission', + links_title='Tanks', + links=[('docs.cgi', 'Docs'), + ('results.cgi', 'Results'), + ('submit.html', 'Submit'), + ('errors.cgi', 'My Errors')])) def done(): - print('') + print(config.end_html()) sys.exit(0) fields = cgi.FieldStorage() @@ -36,23 +37,23 @@ team = fields.getfirst('team', '').strip() passwd = fields.getfirst('passwd', '').strip() code = fields.getfirst('code', '') if not team: - print('

    No team specified'); done() + print('

    No team specified

    '); done() elif not passwd: - print('

    No password given'); done() + print('

    No password given

    '); done() elif not code: - print('

    No program given.'); done() + print('

    No program given.

    '); done() if team not in teams.teams: - print('

    Team is not registered.'); done() + print('

    Team is not registered.

    '); done() if passwd != teams.teams[team][0]: - print('

    Invalid password.'); done() + print('

    Invalid password.

    '); done() path = os.path.join(Config.DATA_PATH, 'ai/players', quote(team) ) file = open(path, 'w') file.write(code) file.close() -print("

    Submission Successful") +print("

    Submission successful.

    ") done() diff --git a/tanks/www/submit.html b/tanks/www/submit.html index f538d5d..d5528a1 100644 --- a/tanks/www/submit.html +++ b/tanks/www/submit.html @@ -1,16 +1,33 @@ - - - ' - Program Submission" - + + + + + Tanks Submission + + + + +

    Tanks Submission

    + + - -

    Program Submission

    -

    - Documentation | - Results | - Submit | - My Errors

    Your program: