]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Add a robots view to support robots.txt.
authorAnt Zucaro <azucaro@gmail.com>
Fri, 26 Sep 2014 01:50:25 +0000 (21:50 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Fri, 26 Sep 2014 01:50:25 +0000 (21:50 -0400)
xonstat/__init__.py
xonstat/static/robots.txt [new file with mode: 0644]
xonstat/views/__init__.py
xonstat/views/static.py [new file with mode: 0644]

index d2ace0ae6e46d0f45d4675473c0257a4b0ed985b..0dfe363c72bea32d7b4a097dacc4df2292e5c426 100644 (file)
@@ -42,6 +42,10 @@ def main(global_config, **settings):
     # for static assets
     config.add_static_view('static', 'xonstat:static')
 
+    # robots
+    config.add_route("robots", "robots.txt")
+    config.add_view(robots, route_name="robots")
+
     # for 404s
     config.add_view(notfound, context=HTTPNotFound, renderer="404.mako")
 
diff --git a/xonstat/static/robots.txt b/xonstat/static/robots.txt
new file mode 100644 (file)
index 0000000..9c6ebed
--- /dev/null
@@ -0,0 +1,7 @@
+User-agent: *
+Disallow: /players/
+Disallow: /player/
+Disallow: /games/
+Disallow: /game/
+Disallow: /servers/
+Disallow: /server/
index 85fd2caf81c36fdff8ab837cbffc1a820e407607..e79530805141f5d226357dc10b9641c0ffccffcc 100644 (file)
@@ -30,3 +30,5 @@ from xonstat.views.main   import main_index, top_players_by_time, top_servers_by
 from xonstat.views.main   import top_servers_by_players, top_maps_by_times_played
 
 from xonstat.views.admin   import forbidden, login, merge
+
+from xonstat.views.static   import robots
diff --git a/xonstat/views/static.py b/xonstat/views/static.py
new file mode 100644 (file)
index 0000000..9d45854
--- /dev/null
@@ -0,0 +1,7 @@
+import os
+from pyramid.response import FileResponse
+
+def robots(request):
+    here = os.path.dirname(__file__)
+    robots_txt = os.path.join(here, "../static", "robots.txt")
+    return FileResponse(robots_txt, request=request)