Add basic 'robots.txt' support to CommonView
This commit is contained in:
parent
737973f4fc
commit
9460b41ec2
2
tailbone/static/robots.txt
Normal file
2
tailbone/static/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
Disallow: /
|
|
@ -26,12 +26,16 @@ Various common views
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import six
|
||||
|
||||
import rattail
|
||||
from rattail.mail import send_email
|
||||
from rattail.util import OrderedDict
|
||||
from rattail.files import resource_path
|
||||
|
||||
import formencode as fe
|
||||
from pyramid import httpexceptions
|
||||
from pyramid.response import Response
|
||||
from pyramid_simpleform import Form
|
||||
|
||||
import tailbone
|
||||
|
@ -55,6 +59,7 @@ class CommonView(View):
|
|||
"""
|
||||
project_title = "Tailbone"
|
||||
project_version = tailbone.__version__
|
||||
robots_txt_path = resource_path('tailbone.static:robots.txt')
|
||||
|
||||
def home(self, mobile=False):
|
||||
"""
|
||||
|
@ -65,6 +70,14 @@ class CommonView(View):
|
|||
default=self.request.static_url('tailbone:static/img/home_logo.png'))
|
||||
return {'image_url': image_url}
|
||||
|
||||
def robots_txt(self):
|
||||
"""
|
||||
Returns a basic 'robots.txt' response
|
||||
"""
|
||||
with open(self.robots_txt_path, 'rt') as f:
|
||||
content = f.read()
|
||||
return Response(content_type=six.binary_type('text/plain'), body=content)
|
||||
|
||||
def mobile_home(self):
|
||||
"""
|
||||
Home page view for mobile.
|
||||
|
@ -135,6 +148,10 @@ class CommonView(View):
|
|||
config.add_route('mobile.home', '/mobile/')
|
||||
config.add_view(cls, attr='mobile_home', route_name='mobile.home', renderer='/mobile/home.mako')
|
||||
|
||||
# robots.txt
|
||||
config.add_route('robots.txt', '/robots.txt')
|
||||
config.add_view(cls, attr='robots_txt', route_name='robots.txt')
|
||||
|
||||
# about
|
||||
config.add_route('about', '/about')
|
||||
config.add_view(cls, attr='about', route_name='about', renderer='/about.mako')
|
||||
|
|
Loading…
Reference in a new issue