diff options
Diffstat (limited to 'hyperkitty')
-rw-r--r-- | hyperkitty/urls.py | 11 | ||||
-rw-r--r-- | hyperkitty/views/__init__.py | 30 |
2 files changed, 37 insertions, 4 deletions
diff --git a/hyperkitty/urls.py b/hyperkitty/urls.py index f6cfa18..df580e6 100644 --- a/hyperkitty/urls.py +++ b/hyperkitty/urls.py @@ -22,7 +22,7 @@ from django.conf.urls.defaults import patterns, include, url from django.conf import settings -from django.views.generic.simple import direct_to_template +from django.views.generic.base import TemplateView from api import EmailResource, ThreadResource, SearchResource from django.contrib.staticfiles.urls import staticfiles_urlpatterns @@ -33,6 +33,10 @@ from django.contrib.auth.views import logout as logout_view from django.contrib import admin admin.autodiscover() +from hyperkitty.views import TextTemplateView + + + urlpatterns = patterns('hyperkitty.views', # Index url(r'^/$', 'pages.index', name='index'), @@ -88,7 +92,7 @@ urlpatterns = patterns('hyperkitty.views', # REST API - url(r'^api/$', direct_to_template, {"template": "api.html"}), + url(r'^api/$', TemplateView.as_view(template_name="api.html")), url(r'^api/email\/(?P<mlist_fqdn>[^/@]+@[^/@]+)\/(?P<hashid>.*)/', EmailResource.as_view(), name="api_email"), url(r'^api/thread\/(?P<mlist_fqdn>[^/@]+@[^/@]+)\/(?P<threadid>.*)/', @@ -103,8 +107,7 @@ urlpatterns = patterns('hyperkitty.views', url(r'^admin/', include(admin.site.urls), {"SSL": True}), # Robots.txt - url(r'^robots\.txt$', direct_to_template, - {'template': 'robots.txt', 'mimetype': 'text/plain'}), + url(r'^robots\.txt$', TextTemplateView.as_view(template_name="robots.txt")), # Social Auth url(r'', include('social_auth.urls'), {"SSL": True}), diff --git a/hyperkitty/views/__init__.py b/hyperkitty/views/__init__.py index e69de29..a27cf0b 100644 --- a/hyperkitty/views/__init__.py +++ b/hyperkitty/views/__init__.py @@ -0,0 +1,30 @@ +#-*- coding: utf-8 -*- +# Copyright (C) 1998-2012 by the Free Software Foundation, Inc. +# +# This file is part of HyperKitty. +# +# HyperKitty is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# HyperKitty is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# HyperKitty. If not, see <http://www.gnu.org/licenses/>. +# +# Author: Aurelien Bompard <abompard@fedoraproject.org> +# + + +from django.views.generic.base import TemplateView + +# https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/#mimetype + +class TextTemplateView(TemplateView): + def render_to_response(self, context, **kwargs): + return super(TextTemplateView, self).render_to_response(context, + content_type='text/plain', **kwargs) |