Skip to content

Commit

Permalink
added robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Lungsangg authored Jul 16, 2024
1 parent 05c8767 commit b6d92bd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions reader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ def sitemap(request):
return HttpResponse("Sitemap not found", status=404, content_type='text/plain')


def robot(request):
# Define the path to the robots.txt file
filepath = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'robots.txt')
try:
with open(filepath, 'r') as f:
robots_content = f.read()
return HttpResponse(robots_content, content_type='text/plain')
except FileNotFoundError:
return HttpResponse("robots.txt not found", status=404, content_type='text/plain')


def render_template(request, template_name='base.html', app_props=None, template_context=None, content_type=None, status=None, using=None):
"""
This is a general purpose custom function that serves to render all the templates in the project and provide a central point for all similar processing.
Expand Down
18 changes: 18 additions & 0 deletions robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
User-agent: *
Disallow: /admin/
Disallow: /accounts/
Disallow: /api/
Disallow: /settings/
Disallow: /login/
Disallow: /logout/
Disallow: /register/
Disallow: /reset/
Disallow: /password_change/
Disallow: /password_reset/
Disallow: /search/

Allow: /static/
Allow: /media/

Sitemap: https://pecha.org/sitemap.xml

1 change: 1 addition & 0 deletions sefaria/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

# App Pages
urlpatterns = [
url(r'^robots.txt$', reader_views.robot, name='robots_txt'),
url(r'^sitemap\.xml$', reader_views.sitemap, name='sitemap'),
url(r'^$', reader_views.home, name="home"),
url(r'^texts/?$', reader_views.texts_list, name="table_of_contents"),
Expand Down

0 comments on commit b6d92bd

Please sign in to comment.