The following commit has been merged in the master branch:
commit 8425af24c36a0049150482d18f4b715e2b4fa579
Author: Michal Čihař <[email protected]>
Date: Fri Oct 9 14:24:29 2009 +0200
Add handling of robots.txt.
We need to have current site domain in robots.txt so it has to be
dynamic.
diff --git a/html/robots.txt b/html/robots.txt
new file mode 100644
index 0000000..166fa0f
--- /dev/null
+++ b/html/robots.txt
@@ -0,0 +1,3 @@
+User-agent: *
+Disallow: /admin
+Sitemap: http://{{ current_site.domain }}/sitemap.xml
diff --git a/media/robots.txt b/media/robots.txt
deleted file mode 100644
index 6cb0426..0000000
--- a/media/robots.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-User-agent: *
-Disallow: /admin
-Sitemap: http://wammu.eu/sitemap.xml
diff --git a/urls.py b/urls.py
index cf4d678..e385a46 100644
--- a/urls.py
+++ b/urls.py
@@ -180,4 +180,7 @@ urlpatterns = patterns('',
# Sitemap
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.index', {'sitemaps':
sitemaps}),
(r'^sitemap-(?P<section>.+)\.xml$',
'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
+
+ # Robots
+ (r'^robots.txt$', 'wammu.views.robots'),
)
diff --git a/wammu/views.py b/wammu/views.py
index cf694aa..7d651f1 100644
--- a/wammu/views.py
+++ b/wammu/views.py
@@ -9,6 +9,7 @@ from downloads.views import get_mirrors
from django.conf import settings
+from django.contrib.sites.models import Site, RequestSite
# Create your views here.
def index(request):
@@ -51,3 +52,12 @@ def libgammu(request):
def static(request, page):
return render_to_response(page, WammuContext(request, {
}))
+
+def robots(request):
+ if Site._meta.installed:
+ current_site = Site.objects.get_current()
+ else:
+ current_site = RequestSite(self.request)
+ return render_to_response('robots.txt', WammuContext(request, {
+ 'current_site': current_site,
+ }), mimetype = 'text/plain')
--
UNNAMED PROJECT
_______________________________________________
Wammu-svn mailing list
[email protected]
https://lists.cihar.com/cgi-bin/mailman/listinfo/wammu-svn