From: Ant Zucaro Date: Fri, 26 Sep 2014 01:50:25 +0000 (-0400) Subject: Add a robots view to support robots.txt. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bcfa0b24c1352fe523a70901cb9f278e6df16c00;p=xonotic%2Fxonstat.git Add a robots view to support robots.txt. --- diff --git a/xonstat/__init__.py b/xonstat/__init__.py index d2ace0a..0dfe363 100644 --- a/xonstat/__init__.py +++ b/xonstat/__init__.py @@ -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 index 0000000..9c6ebed --- /dev/null +++ b/xonstat/static/robots.txt @@ -0,0 +1,7 @@ +User-agent: * +Disallow: /players/ +Disallow: /player/ +Disallow: /games/ +Disallow: /game/ +Disallow: /servers/ +Disallow: /server/ diff --git a/xonstat/views/__init__.py b/xonstat/views/__init__.py index 85fd2ca..e795308 100644 --- a/xonstat/views/__init__.py +++ b/xonstat/views/__init__.py @@ -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 index 0000000..9d45854 --- /dev/null +++ b/xonstat/views/static.py @@ -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)