From 3ec79710ca046b2c172eb77679eb5e2983460a1a Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 4 Nov 2011 22:10:49 +0100 Subject: [PATCH] Render html pages in templates/html_pages --- pages/__init__.py | 0 pages/models.py | 3 +++ pages/urls.py | 5 +++++ pages/views.py | 18 ++++++++++++++++++ templates/pages/index.html | 5 +++++ urls.py | 4 ++++ 6 files changed, 35 insertions(+) create mode 100644 pages/__init__.py create mode 100644 pages/models.py create mode 100644 pages/urls.py create mode 100644 pages/views.py create mode 100644 templates/pages/index.html diff --git a/pages/__init__.py b/pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pages/models.py b/pages/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/pages/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/pages/urls.py b/pages/urls.py new file mode 100644 index 0000000..1c0cf82 --- /dev/null +++ b/pages/urls.py @@ -0,0 +1,5 @@ +from django.conf.urls.defaults import * + +urlpatterns = patterns('pages.views', + (r'^(?P.+)/$', 'index'), +) diff --git a/pages/views.py b/pages/views.py new file mode 100644 index 0000000..2f902a6 --- /dev/null +++ b/pages/views.py @@ -0,0 +1,18 @@ +import os.path + +from django.http import Http404 +from django.views.generic.simple import direct_to_template + +from settings import DEPLOY_PATH + +def index(request, page): + + template = 'html_pages/%s/index.html' % page + if not os.path.exists('%s/templates/%s' % (DEPLOY_PATH, template): + raise Http404 + + c = { + "page": template, + } + + return direct_to_template(request, "pages/index.html", c) diff --git a/templates/pages/index.html b/templates/pages/index.html new file mode 100644 index 0000000..18988f9 --- /dev/null +++ b/templates/pages/index.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} + +{% block content %} +{% include page %} +{% endblock %} diff --git a/urls.py b/urls.py index a5e253d..3b24bf7 100644 --- a/urls.py +++ b/urls.py @@ -15,4 +15,8 @@ urlpatterns = patterns('', if DEBUG: urlpatterns += patterns('', (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': '%s/static' % DEPLOY_PATH}) + ) + +urlpatterns += patterns('', + (r'^', include("pages.urls")) )