--- /dev/null
+*.py[oc]
+/sommitrealweird.db
--- /dev/null
+body {
+ font-family: freesans, georgia, arial, helvetica, sans-serif;
+ background: white;
+ color: black;
+}
+
+body #page {
+ background: url(../img/background.png) white no-repeat;
+ width: 90%;
+ text-align: center;
+ margin-left: auto;
+ margin-right: auto;
+ font-size: 100%;
+ border: thin solid #000000;
+}
+
+body #page #headerbar {
+ position: relative;
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ min-height: 160px;
+}
+
+body #page #headerbar #websitetitle {
+ color: #721263;
+ text-align: right;
+ padding-top: 0.3em;
+ padding-bottom: 0.3em;
+ padding-right: 0.3em;
+ font-weight: bold;
+}
+
+body #page #headerbar #websitetitle h1 {
+ font-size: 250%;
+}
+
+body #page #headerbar #menu {
+ font-size: 90%;
+ margin-top: 1em;
+ margin-right: 0;
+ text-align: right;
+ width: 100%;
+ border-top: thin solid #bababa;
+ border-bottom: thin solid #bababa;
+ background: url(../img/menu-back.png);
+ padding-top: 0.3em;
+ padding-bottom: 0.3em;
+ bottom: 0;
+ position: absolute;
+}
+
+body #page #headerbar #menu ul {
+ display: inline;
+}
+
+body #page #headerbar #menu ul li {
+ display: inline;
+ padding-left: 1em;
+ padding-right: 1em;
+ margin: 0;
+ color: #9a9a9a;
+ font-weight: bold;
+}
+
+body #page #headerbar #menu ul li:hover {
+ color: #ffffff;
+}
+
+body #page #content {
+ font-family: arial, helvetica, sans-serif;
+ text-align: left;
+ margin-left: 0.8em;
+ margin-right: 0.3em;
+}
+
+body #page #content h1 {
+ margin-left: -0.3em;
+}
+
+body #page #footer {
+ width: 100%;
+ font-size: 70%;
+ text-align: center;
+ margin: 0;
+ padding: 0.1em;
+}
+
--- /dev/null
+from django.core import validators
+
+def is_unique_name(slug, all_data):
+ from content.models import Document, Folder
+ if all_data["folder"] != '' and all_data["id"] == '':
+ folder_id = int(all_data["folder"])
+ try:
+ doc = Document.object.get(folder__exact=folder_id, slug__exact=slug)
+ raise validators.ValidationError(u'There is already a document with that name')
+ except:
+ pass
+
+ try:
+ folder = Folder.object.get(slug__exact=slug, parent__exact=folder_id)
+ raise validators.ValidationError(u'There is already a folder with that name')
+ except:
+ pass
--- /dev/null
+from django.db import models
+from content.content_val import is_unique_name
+
+FORMAT_CHOICES = (
+ ('rst', 'reStructuredText'),
+ ('html', 'HTML'),
+ )
+
+class Document(models.Model):
+ title = models.CharField(maxlength=150)
+ islive = models.BooleanField()
+ folder = models.ForeignKey('Folder', null=True, blank=True)
+ format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
+ slug = models.SlugField(prepopulate_from=("title",), validator_list=[is_unique_name,])
+ content = models.TextField()
+
+ def __str__(self):
+ return self.__unicode__()
+
+ def __unicode__(self):
+ return u'%s (%s)' %(self.title, self.slug)
+
+ def save(self):
+ super(Document, self).save()
+ # now check if we just set our selves to be live
+ if self.islive:
+ if self.folder:
+ otherdocs = Document.objects.filter(slug__exact=self.slug, islive__exact=True, folder__exact=self.folder).exclude(pk=self.id)
+ else:
+ otherdocs = Document.objects.filter(slug__exact=self.slug, islive__exact=True, folder__isnull=True).exclude(pk=self.id)
+ for doc in otherdocs:
+ doc.islive = False
+ doc.save()
+
+ class Admin:
+ pass
+
+class Folder(models.Model):
+ title = models.CharField(maxlength=150)
+ slug = models.SlugField(prepopulate_from=("title",))
+ parent = models.ForeignKey('self', null=True, blank=True)
+
+ def __str__(self):
+ return self.__unicode__()
+
+ def __unicode__(self):
+ return u'%s' %(self.title)
+
+ class Admin:
+ pass
--- /dev/null
+{% extends "base.html" %}
+{% load markup %}
+
+{% block content %}
+<h1> {{ title }}</h1>
+{{ content }}
+{% endblock %}
--- /dev/null
+{% extends "base.html" %}
+{% load markup %}
+
+{% block content %}
+<h1> {{ title }}</h1>
+{{ content|restructuredtext }}
+{% endblock %}
--- /dev/null
+from content.models import Document, Folder
+from django.http import Http404, HttpResponse
+from django.template import RequestContext, loader
+from settings import MEDIA_URL
+
+def document_view(request, slug=None, folders=None):
+ if folders == None and slug == None:
+ raise Http404()
+
+ folder = None
+
+ if folders != None:
+ folders = folders.split('/')
+ resfolder = None
+ for folder in folders:
+ try:
+ if resfolder:
+ resfolder = Folder.objects.get(slug__exact=folder, parent__exact=resfolder)
+ else:
+ resfolder = Folder.objects.get(slug__exact=folder, parent__isnull=True)
+ resfolder = resfolder.id
+ except:
+ raise Http404
+ try:
+ folder = Folder.objects.get(pk=resfolder)
+ except:
+ raise Http404
+
+ if folder != None:
+ try:
+ doc = Document.objects.get(slug__exact=slug, islive__exact=True, folder__exact=folder)
+ except:
+ try:
+ folder = Folder.objects.get(slug__exact=slug, parent__exact=folder)
+ doc = Document.objects.get(slug__exact='index', islive__exact=True, folder__exact=folder)
+ except:
+ raise Http404
+ else:
+ try:
+ doc = Document.objects.get(slug__exact=slug, islive__exact=True, folder__isnull=True)
+ except:
+ try:
+ folder = Folder.objects.get(slug__exact=slug, parent__isnull=True)
+ doc = Document.objects.get(slug__exact='index', islive__exact=True, folder__exact=folder)
+ except:
+ raise Http404
+ template_name = "%s.html" %(doc.format,)
+ t = loader.get_template(template_name)
+ c = RequestContext(request,
+ {
+ "content" : doc.content,
+ "title" : doc.title,
+ "media_url" : MEDIA_URL,
+ })
+ return HttpResponse(t.render(c))
--- /dev/null
+from settings import MEDIA_URL
+from django.http import HttpResponseNotFound
+from django.template import RequestContext, loader
+
+
+def render_404(request, template_name='404.html'):
+ t = loader.get_template(template_name)
+ return HttpResponseNotFound( \
+ t.render(RequestContext(request,
+ {
+ 'request_path': request.path,
+ 'media_url' : MEDIA_URL,
+ }
+ )))
--- /dev/null
+#!/usr/bin/python
+from django.core.management import execute_manager
+try:
+ import settings # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.exit(1)
+
+if __name__ == "__main__":
+ execute_manager(settings)
--- /dev/null
+# Django settings for sommitrealweird project.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ # ('Your Name', 'your_email@domain.com'),
+ ('Brett Parker', 'iDunno@sommitrealweird.co.uk'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
+DATABASE_NAME = '/home/brettp/dev/sommitrealweird/sommitrealweird.db' # Or path to database file if using sqlite3.
+DATABASE_USER = '' # Not used with sqlite3.
+DATABASE_PASSWORD = '' # Not used with sqlite3.
+DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
+DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
+
+# Local time zone for this installation. Choices can be found here:
+# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
+# although not all variations may be possible on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'Europe/London'
+
+# Language code for this installation. All choices can be found here:
+# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
+# http://blogs.law.harvard.edu/tech/stories/storyReader$15
+LANGUAGE_CODE = 'en-gb'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = '/home/brettp/dev/sommitrealweird/media/'
+
+# URL that handles the media served from MEDIA_ROOT.
+# Example: "http://media.lawrence.com"
+MEDIA_URL = '/media/'
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/admin-media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '$!roq-b5snvjxi4dr2y7(l(@$@k+2%aub&)s__0)k#r&c(8(4x'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.middleware.doc.XViewMiddleware',
+)
+
+ROOT_URLCONF = 'urls'
+
+TEMPLATE_DIRS = (
+ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+ "/home/brettp/dev/sommitrealweird/templates",
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ 'django.contrib.markup',
+ 'content',
+ 'generic',
+)
--- /dev/null
+from django.conf.urls.defaults import *
+from settings import MEDIA_ROOT, MEDIA_URL
+
+handler404 = 'generic.views.render_404'
+
+urlpatterns = patterns('',
+ # Example:
+ # (r'^sommitrealweird/', include('sommitrealweird.foo.urls')),
+
+ # Uncomment this for admin:
+ (r'^$', 'content.views.document_view', {'slug': 'index'}),
+ (r'^admin/', include('django.contrib.admin.urls')),
+ (r'^content/(?P<slug>[^/]+)/$', 'content.views.document_view'),
+ (r'^content/(?P<folders>.*)/(?P<slug>[^/]+)/$', 'content.views.document_view'),
+ (r'^content/$', 'content.views.document_view', {'slug': 'index'}),
+ (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT, 'show_indexes': True}),
+)
--- /dev/null
+{% extends "base.html" %}
+
+{% block title %}Not Found{% endblock %}
+{% block content %}
+ <p>Sorry, couldn't find what you were looking for. Oops.</p>
+{% endblock %}
--- /dev/null
+{% extends "base.html" %}
+
+{% block title %}Not Found{% endblock %}
+{% block cmsnavigation %}
+ <ul>
+ <li><a href="/cms/">Home</a></li>
+ </ul>
+{% endblock %}
+{% block content %}
+ <p>Sorry, couldn't find what you were looking for. Oops.</p>
+{% endblock %}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <title>{% block title %}{{ title }}{% endblock %}</title>
+ <link rel="stylesheet" type="text/css" href="{{ media_url }}style/main.css" />
+ </head>
+ <body>
+ <div id="page">
+ <div id="headerbar">
+ <div id="websitetitle">
+ <h1>SommitRealWeird</h1>
+ </div>
+ <div id="menu">
+ {% block meny %}
+ <ul>
+ <li>Home</li>
+ <li>Development</li>
+ <li>Links</li>
+ <li>People</li>
+ <li>CSS Examples</li>
+ <li>Photos</li>
+ <li>Blog</li>
+ </ul>
+ {% endblock %}
+ </div>
+ </div>
+ <div id="content">
+ {% block content %}
+ {{ content }}
+ {% endblock %}
+ </div>
+ <div id="footer">
+ <p>Copyright © 2008 - <a href="mailto:iDunno@sommitrealweird.co.uk">Brett Parker</a></p>
+ </div>
+ </div>
+ </body>
+</html>