diff --git a/pyi2phosts/lib/generic.py b/pyi2phosts/lib/generic.py new file mode 100755 index 0000000..68945a1 --- /dev/null +++ b/pyi2phosts/lib/generic.py @@ -0,0 +1,14 @@ +from django.views.generic.base import TemplateView +from pyi2phosts.lib.utils import get_b32 +import settings + +class LocalTemplateView(TemplateView): + def get_context_data(self, **kwargs): + context = super(LocalTemplateView, self).get_context_data(**kwargs) + context.update({ + 'title': settings.SITE_NAME, + 'domain': settings.DOMAIN, + 'b64': settings.MY_B64, + 'b32': get_b32(settings.MY_B64) + }) + return context diff --git a/pyi2phosts/urls.py b/pyi2phosts/urls.py index 9405f2a..155a13a 100644 --- a/pyi2phosts/urls.py +++ b/pyi2phosts/urls.py @@ -1,5 +1,4 @@ from django.conf.urls.defaults import * -from django.views.generic.simple import direct_to_template from django.views.generic.list_detail import object_list # Uncomment the next two lines to enable the admin: @@ -8,6 +7,7 @@ admin.autodiscover() from pyi2phosts.lib.rss import AliveHostsFeed from pyi2phosts.lib.utils import get_b32 +from pyi2phosts.lib.generic import LocalTemplateView from pyi2phosts.extsources.models import ExternalSource from pyi2phosts.postkey.models import i2phost import settings @@ -32,15 +32,7 @@ browse_hosts = { } urlpatterns = patterns('', - url(r'^$', direct_to_template, { - 'template': 'index.html', - 'extra_context': { - 'title': settings.SITE_NAME, - 'domain': settings.DOMAIN, - 'b64': settings.MY_B64, - 'b32': get_b32(settings.MY_B64) - } - }, name='index'), + url(r'^$', LocalTemplateView.as_view(template_name='index.html'), name='index'), url(r'^faq/$', object_list, extsources, name='faq'), url(r'^browse/$', object_list, browse_hosts, name='browse'), url(r'^browse/rss/$', AliveHostsFeed(), name='browse-rss'),