Merge branch 'master' of github.com:asmaps/nsupdate.info

This commit is contained in:
Fabian Faessler 2013-09-29 21:13:24 +02:00
commit 7eb23300bd
2 changed files with 22 additions and 2 deletions

View File

@ -1,7 +1,8 @@
from django.conf.urls import patterns, url from django.conf.urls import patterns, url
from django.views.generic import TemplateView from django.views.generic import TemplateView
from main.views import ( from main.views import (
HomeView, OverviewView, HostView, DeleteHostView, AboutView, HelpView, GenerateSecretView) HomeView, OverviewView, HostView, DeleteHostView, AboutView, HelpView, GenerateSecretView,
RobotsTxtView, )
from api.views import ( from api.views import (
MyIpView, DetectIpView, NicUpdateView, AuthorizedNicUpdateView) MyIpView, DetectIpView, NicUpdateView, AuthorizedNicUpdateView)
@ -23,4 +24,5 @@ urlpatterns = patterns(
url(r'^nic/update$', NicUpdateView), url(r'^nic/update$', NicUpdateView),
url(r'^nic/update_authorized$', url(r'^nic/update_authorized$',
AuthorizedNicUpdateView, name='nic_update_authorized'), AuthorizedNicUpdateView, name='nic_update_authorized'),
url(r'^robots.txt$', RobotsTxtView),
) )

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.views.generic import TemplateView, CreateView from django.views.generic import TemplateView, CreateView
from django.views.generic.edit import UpdateView, DeleteView from django.views.generic.edit import UpdateView, DeleteView
from django.http import HttpResponseRedirect from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib import messages from django.contrib import messages
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
@ -154,3 +154,21 @@ class DeleteHostView(DeleteView):
context['nav_overview'] = True context['nav_overview'] = True
context['hosts'] = Host.objects.filter(created_by=self.request.user) context['hosts'] = Host.objects.filter(created_by=self.request.user)
return context return context
def RobotsTxtView(request):
"""
Dynamically serve robots.txt content.
If you like, you can optimize this by statically serving this by your web server.
:param request: django request object
:return: HttpResponse object
"""
content = """\
User-agent: *
Crawl-delay: 10
Disallow: /accounts/
Disallow: /myip/
Disallow: /nic/update/
"""
return HttpResponse(content, content_type="text/plain")