]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
New 404 page. Hooray, no more boring ones!
authorAnt Zucaro <azucaro@gmail.com>
Thu, 25 Jul 2013 00:45:28 +0000 (20:45 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 25 Jul 2013 00:45:28 +0000 (20:45 -0400)
xonstat/__init__.py
xonstat/templates/404.mako [new file with mode: 0644]
xonstat/views/__init__.py
xonstat/views/exceptions.py [new file with mode: 0644]

index 728426d36ee1aa88b75ec3af864717d5ec8786db..7cdbe29535bc6f86d170429a7179ab263cb45d9c 100644 (file)
@@ -1,6 +1,7 @@
 import sqlahelper
 from pyramid_beaker import set_cache_regions_from_settings
 from pyramid.config import Configurator
+from pyramid.httpexceptions import HTTPNotFound
 from pyramid.renderers import JSONP
 from sqlalchemy import engine_from_config
 from xonstat.models import initialize_db
@@ -21,9 +22,13 @@ def main(global_config, **settings):
 
     config = Configurator(settings=settings)
 
+    config.add_renderer('jsonp', JSONP(param_name='callback'))
+
+    # for static assets
     config.add_static_view('static', 'xonstat:static')
 
-    config.add_renderer('jsonp', JSONP(param_name='callback'))
+    # for 404s
+    config.add_view(notfound, context=HTTPNotFound, renderer="404.mako")
 
     # ROOT ROUTE
     config.add_route("main_index", "/")
diff --git a/xonstat/templates/404.mako b/xonstat/templates/404.mako
new file mode 100644 (file)
index 0000000..9e1b150
--- /dev/null
@@ -0,0 +1,48 @@
+<%inherit file="base.mako"/>
+<%namespace name="nav" file="nav.mako" />
+
+<%block name="navigation">
+${nav.nav('games')}
+</%block>
+
+<h1>HTTP 404</h1>
+
+% if 0 <= rand < 30:
+<h2>Well this is <i>awkward</i>...I couldn't find what you were looking for!</h2>
+<p>(better get back to playing then, <b>hm</b>?)</p>
+% endif
+
+% if 30 <= rand < 40:
+<h2>Whoa there! Looks like you've taken a wrong turn.</h2>
+<p>(no one <i>tries</i> to get on highway 404, <b>no one</b>.)</p>
+% endif
+
+% if 40 <= rand < 50:
+<h2>There's nothing to see here. *waves hand*</h2>
+<p>(did Mirio put you up to this?)</p>
+% endif
+
+% if 50 <= rand < 60:
+<h2>Hey, you! Watch out - kojn's behind you!</h2>
+<p>(he killed this page, apparently)</p>
+% endif
+
+% if 60 <= rand < 70:
+<h2>Samual must have destroyed this page.</h2>
+<p>(it wasn't pulling its own weight anyway)</p>
+% endif
+
+% if 70 <= rand < 80:
+<h2>divVerent has encrypted this page so hard you'll never decipher it.</h2>
+<p>(either that or you've hit the wrong page or something)</p>
+% endif
+
+% if 80 <= rand < 90:
+<h2>merlijn was unhappy with this page, so he removed it from the server.</h2>
+<p>(after yelling at me about it, of course)</p>
+% endif
+
+% if 90 <= rand <= 100:
+<h2>Morphed is modeling this page. It's gonna be awesome.</h2>
+<p>(until then, you'll probably want to get in a game or two)</p>
+% endif
index f238d7adeea9f47c3df364c037122b02f4e5bf00..d88a1390eacc8a2cdefd281a7a986e87dcb93427 100644 (file)
@@ -22,4 +22,6 @@ from xonstat.views.server import server_index_json
 from xonstat.views.search import search_q, search
 from xonstat.views.search import search_json
 
+from xonstat.views.exceptions   import notfound
+
 from xonstat.views.main   import main_index
diff --git a/xonstat/views/exceptions.py b/xonstat/views/exceptions.py
new file mode 100644 (file)
index 0000000..0cc9148
--- /dev/null
@@ -0,0 +1,5 @@
+import logging
+import random
+
+def notfound(request):
+    return {'rand': int(random.random() * 100)}