]> git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/__init__.py
Sanitize the scope at the endpoint level.
[xonotic/xonstat.git] / xonstat / __init__.py
index b925989c2be691d0e948cebcf16d769f5b978ae4..877e4b88be04a502834e8c5613a0408b1d5a352e 100644 (file)
@@ -1,6 +1,5 @@
 import sqlahelper
 from pyramid_beaker import set_cache_regions_from_settings
-from pyramid.authentication import AuthTktAuthenticationPolicy
 from pyramid.config import Configurator
 from pyramid.httpexceptions import HTTPNotFound
 from pyramid.renderers import JSONP
@@ -28,15 +27,6 @@ def main(global_config, **settings):
     # mako for templating
     config.include('pyramid_mako')
 
-    # Mozilla Persona as the login verifier. It defines default
-    # authentication and authorization policies.
-    config.include('pyramid_persona')
-
-    # override the authn policy to provide a callback
-    secret = settings.get('persona.secret', None)
-    authn_policy = AuthTktAuthenticationPolicy(secret, callback=groupfinder, hashalg='sha512')
-    config.set_authentication_policy(authn_policy)
-
     # for json-encoded responses
     config.add_renderer('jsonp', JSONP(param_name='callback'))
 
@@ -54,6 +44,10 @@ def main(global_config, **settings):
     config.add_route("main_index", "/")
     config.add_view(main_index, route_name="main_index", renderer="main_index.mako")
 
+    config.add_route("summary_stats_json", "/summary")
+    config.add_view(view=summary_stats_json, route_name="summary_stats_json", renderer="json",
+                    accept="application/json")
+
     # MAIN SUBMISSION ROUTE
     config.add_route("submit_stats", "stats/submit")
     config.add_view(submit_stats, route_name="submit_stats", renderer="submit_stats.mako")
@@ -121,12 +115,6 @@ def main(global_config, **settings):
     config.add_route("game_info_json", "/game/{id:\d+}.json")
     config.add_view(game_info_json, route_name="game_info_json", renderer="jsonp")
 
-    config.add_route("rank_index", "/ranks/{game_type_cd}")
-    config.add_view(rank_index,      route_name="rank_index",      renderer="rank_index.mako")
-
-    config.add_route("rank_index_json", "/ranks/{game_type_cd}.json")
-    config.add_view(rank_index_json, route_name="rank_index_json", renderer="jsonp")
-
     config.add_route("game_index", "/games")
     config.add_view(game_finder, route_name="game_index", renderer="game_finder.mako")
 
@@ -135,43 +123,59 @@ def main(global_config, **settings):
 
     # SERVER ROUTES
     config.add_route("server_index", "/servers")
-    config.add_view(
-        view=ServerIndex,
-        route_name="server_index",
-        attr="html",
-        renderer="server_index.mako",
-        accept="text/html"
-    )
-    config.add_view(
-        view=ServerIndex,
-        route_name="server_index",
-        attr="json",
-        renderer="json",
-        accept="text/json"
-    )
+    config.add_view(view=ServerIndex, route_name="server_index", attr="html",
+                    renderer="server_index.mako", accept="text/html")
+    config.add_view(view=ServerIndex, route_name="server_index", attr="json", renderer="json",
+                    accept="application/json")
+
+    config.add_route("server_top_maps", "/server/{id:\d+}/topmaps")
+    config.add_view(view=ServerTopMaps, route_name="server_top_maps", attr="html",
+                    renderer="server_top_maps.mako", accept="text/html")
+    config.add_view(view=ServerTopMaps, route_name="server_top_maps", attr="json", renderer="json",
+                    accept="application/json")
+
+    config.add_route("server_top_active", "/server/{id:\d+}/topactive")
+    config.add_view(view=ServerTopPlayers, route_name="server_top_active", attr="html",
+                    renderer="server_top_active.mako", accept="text/html")
+    config.add_view(view=ServerTopPlayers, route_name="server_top_active", attr="json",
+                    renderer="json", accept="application/json")
+
+    config.add_route("server_top_scorers", "/server/{id:\d+}/topscorers")
+    config.add_view(view=ServerTopScorers, route_name="server_top_scorers", attr="html",
+                    renderer="server_top_scorers.mako", accept="text/html")
+    config.add_view(view=ServerTopScorers, route_name="server_top_scorers", attr="json",
+                    renderer="json", accept="application/json")
 
     config.add_route("server_info", "/server/{id:\d+}")
-    config.add_view(
-        view=ServerInfo,
-        route_name="server_info",
-        attr="html",
-        renderer="server_info.mako",
-        accept="text/html"
-    )
-    config.add_view(
-        view=ServerInfo,
-        route_name="server_info",
-        attr="json",
-        renderer="server_info.mako",
-        accept="text/json"
-    )
+    config.add_view(view=ServerInfo, route_name="server_info", attr="html",
+                    renderer="server_info.mako", accept="text/html")
+    config.add_view(view=ServerInfo, route_name="server_info", attr="json", renderer="json",
+                    accept="application/json")
 
     # MAP ROUTES
-    config.add_route("map_index",      "/maps")
-    config.add_view(map_index,      route_name="map_index",      renderer="map_index.mako")
-
-    config.add_route("map_index_json", "/maps.json")
-    config.add_view(map_index_json, route_name="map_index_json", renderer="jsonp")
+    config.add_route("map_index", "/maps")
+    config.add_view(view=MapIndex, route_name="map_index", attr="html",
+                    renderer="map_index.mako", accept="text/html")
+    config.add_view(view=MapIndex, route_name="map_index", attr="json", renderer="json",
+                    accept="application/json")
+
+    config.add_route("map_top_scorers", "/map/{id:\d+}/topscorers")
+    config.add_view(view=MapTopScorers, route_name="map_top_scorers", attr="html",
+                    renderer="map_top_scorers.mako", accept="text/html")
+    config.add_view(view=MapTopScorers, route_name="map_top_scorers", attr="json",
+                    renderer="json", accept="application/json")
+
+    config.add_route("map_top_active", "/map/{id:\d+}/topactive")
+    config.add_view(view=MapTopPlayers, route_name="map_top_active", attr="html",
+                    renderer="map_top_active.mako", accept="text/html")
+    config.add_view(view=MapTopPlayers, route_name="map_top_active", attr="json",
+                    renderer="json", accept="application/json")
+
+    config.add_route("map_top_servers", "/map/{id:\d+}/topservers")
+    config.add_view(view=MapTopServers, route_name="map_top_servers", attr="html",
+                    renderer="map_top_servers.mako", accept="text/html")
+    config.add_view(view=MapTopServers, route_name="map_top_servers", attr="json",
+                    renderer="json", accept="application/json")
 
     config.add_route("map_info",      "/map/{id:\d+}")
     config.add_view(map_info,      route_name="map_info",      renderer="map_info.mako")