--- /dev/null
+eatslugs.db
+*.pyc
+*.pyo
--- /dev/null
+from django.conf import settings
+
+def media(request):
+ return {
+ 'MEDIA_URL': settings.MEDIA_URL,
+ }
--- /dev/null
+# Author: Brett Parker <iDunno@sommitrealweird.co.uk>
+
+"""
+HTML1.1 Writer.
+"""
+
+__docformat__ = 'reStructuredText'
+
+import sys
+import os
+import os.path
+import codecs
+import docutils
+from docutils import frontend, nodes, utils, writers
+from docutils.writers import html4css1
+
+class Writer(html4css1.Writer):
+
+ config_section = 'xhtml11 writer'
+ config_section_dependencies = ('writers', 'html4css1 writer')
+
+ def __init__(self):
+ html4css1.Writer.__init__(self)
+ self.translator_class = HTMLTranslator
+
+class HTMLTranslator(html4css1.HTMLTranslator):
+
+ def is_compactable(self, node):
+ return False
+
+ def should_be_compact_paragraph(self, node):
+ return False
--- /dev/null
+from django.conf import settings
+from PIL import Image
+import os, sys
+
+def make_thumbnail(imagefile,width=None,height=None):
+ # first check that the thumbnail image doesn't already exist
+ # and if it does that it's newer than the origional image
+
+ base_dir = settings.MEDIA_ROOT
+ thumbs_dir = base_dir
+ if not thumbs_dir.endswith("/"):
+ thumbs_dir = "%s/" %(thumbs_dir,)
+ base_dir = "%s/" %(base_dir,)
+
+ try:
+ thumbs_dir = "%s%s/" %(thumbs_dir, settings.THUMBS_DIRECTORY)
+ thumbsdirectory = settings.THUMBS_DIRECTORY
+ except:
+ thumbs_dir = "%sthumbs/" %(thumbs_dir,)
+ thumbsdirectory = "thumbs"
+
+ if width != None:
+ try:
+ thumb = os.stat("%sw%d/%s" % (thumbs_dir, width, imagefile))
+ pic = os.stat("%s%s" % (base_dir, imagefile))
+ if thumb.st_ctime < pic.st_ctime:
+ # regenerate the icon
+ img = Image.open("%s%s" %(base_dir, imagefile))
+ (curwidth,curheight) = img.size
+
+ newwidth = width
+ newheight = int((newwidth * curheight) / curwidth)
+
+ newimg = img.resize((newwidth, newheight))
+ newimg.save("%sw%d/%s" %(thumbs_dir, width, imagefile))
+
+ return "%s%s/w%d/%s" %(settings.MEDIA_URL, thumbsdirectory, width, imagefile)
+ else:
+ # we have a winner!
+ return "%s%s/w%d/%s" %(settings.MEDIA_URL, thumbsdirectory, width, imagefile)
+ except:
+ # well, there's not one there. feh. sucks.
+ try:
+ directory_to_create = imagefile[:imagefile.rindex(os.sep)]
+ img = Image.open("%s%s" %(base_dir, imagefile))
+ if not os.path.isdir("%sw%d/%s" %(thumbs_dir, width, directory_to_create)):
+ os.makedirs("%sw%d/%s" %(thumbs_dir, width, directory_to_create))
+ (curwidth,curheight) = img.size
+
+ newwidth = width
+ newheight = int((newwidth * curheight) / curwidth)
+
+ newimg = img.resize((newwidth, newheight))
+ newimg.save("%sw%d/%s" %(thumbs_dir, width, imagefile))
+
+ return "%s%s/w%d/%s" %(settings.MEDIA_URL, thumbsdirectory, width, imagefile)
+ except Exception, e:
+ sys.stderr.write("Got exception: %s" %(e,))
+
+ elif height != None:
+ try:
+ thumb = os.stat("%sh%d/%s" % (thumbs_dir, height, imagefile))
+ pic = os.stat("%s%s" % (base_dir, imagefile))
+ if thumb.st_ctime < pic.st_ctime:
+ # regenerate the icon
+ img = Image.open("%s%s" %(base_dir, imagefile))
+ (curwidth,curheight) = img.size
+
+ newheight = height
+ newheight = int((newheight * curwidth) / curheight)
+
+ newimg = img.resize((newwidth, newheight))
+ newimg.save("%sh%d/%s" %(thumbs_dir, height, imagefile))
+
+ return "%s%s/h%d/%s" %(settings.MEDIA_URL, thumbsdirectory, height, imagefile)
+ else:
+ # we have a winner!
+ return "%s%s/h%d/%s" %(settings.MEDIA_URL, thumbsdirectory, height, imagefile)
+ except:
+ # well, there's not one there. feh. sucks.
+ try:
+ directory_to_create = imagefile[:imagefile.rindex(os.sep)]
+ img = Image.open("%s%s" %(base_dir, imagefile))
+ os.makedirs("%sh%h/%s" %(thumbs_dir, height, directory_to_create))
+ (curwidth,curheight) = img.size
+
+ newheight = height
+ newwidth = int((newheight * curwidth) / curheight)
+
+ newimg = img.resize((newwidth, newheight))
+ newimg.save("%sh%d/%s" %(thumbs_dir, height, imagefile))
+
+ return "%s%s/h%d/%s" %(settings.MEDIA_URL, thumbsdirectory, height, imagefile)
+ except:
+ pass
+
+ # if everything fails, we'll return the origional image URL
+ # this is for simpilicity
+ return "%s%s" %(settings.MEDIA_URL, imagefile)
+
--- /dev/null
+from django import template
+from django.conf import settings
+from generic import helpers
+import sys
+
+register = template.Library()
+
+def thumbnail(image_url, args=''):
+ options = {}
+
+ if ',' not in args:
+ args = "%s," %(args,)
+
+ for arg in args.split(','):
+ arg = arg.strip()
+ try:
+ (kw,val) = arg.split('=', 1)
+ try:
+ options[kw] = int(val)
+ except:
+ pass
+ except:
+ pass
+
+ if options.has_key("height") or options.has_key("width"):
+ if options.has_key("width") and options.has_key("height"):
+ return helpers.make_thumbnail(image_url[len(settings.MEDIA_URL):], width=options["width"], height=options["height"])
+ elif options.has_key("width"):
+ return helpers.make_thumbnail(image_url[len(settings.MEDIA_URL):], width=options["width"])
+ else:
+ return helpers.make_thumbnail(image_url[len(settings.MEDIA_URL):], height=options["height"])
+ else:
+ pass
+
+ return "%s" %(image_url)
+
+register.filter(thumbnail)
--- /dev/null
+from django import template
+from django.conf import settings
+from django.utils.encoding import smart_str, force_unicode
+from django.utils.safestring import mark_safe
+from generic import docutils_xhtml11
+
+register = template.Library()
+
+def restructuredtext(value):
+ try:
+ from docutils.core import publish_parts
+ except ImportError:
+ if settings.DEBUG:
+ raise template.TemplateSyntaxError, "Error in {% restructuredtext %} filter: The Python docutils library isn't installed."
+ return force_unicode(value)
+ else:
+ docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
+ parts = publish_parts(source=smart_str(value), writer=docutils_xhtml11.Writer(), settings_overrides=docutils_settings)
+ return mark_safe(force_unicode(parts["fragment"]))
+restructuredtext.is_safe = True
+
+register.filter(restructuredtext)
--- /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
+from django.contrib import admin
+from models import Drink, Recipe, Combination
+
+admin.site.register(Drink)
+admin.site.register(Recipe)
+admin.site.register(Combination)
+
--- /dev/null
+from django.db import models
+
+# Create your models here.
+
+class Recipe(models.Model):
+ name = models.CharField(max_length=250)
+ ingrediants = models.TextField()
+ description = models.TextField()
+
+class Drink(models.Model):
+ name = models.CharField(max_length=250)
+ description = models.TextField()
+
+class Combination(models.Model):
+ recipe = models.ForeignKey('Recipe')
+ drink = models.ForeignKey('Drink')
--- /dev/null
+# Create your views here.
--- /dev/null
+# Django settings for eatslugs project.
+
+# Rather than editing settings here, add them to the localsettings.py file
+# which will be included at the end of the run and replace anything in here.
+
+import os
+topdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ ('Brett Parker', 'iDunno@sommitrealweird.co.uk'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = 'sqlite3'
+DATABASE_NAME = os.path.join(topdir, 'eatslugs.db')
+DATABASE_USER = ''
+DATABASE_PASSWORD = ''
+DATABASE_HOST = ''
+DATABASE_PORT = ''
+
+TIME_ZONE = 'Europe/London'
+
+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
+
+MEDIA_ROOT = os.path.join(topdir, 'media') + os.sep
+MEDIA_URL = '/media/'
+
+ADMIN_MEDIA_PREFIX = '/admin-media/'
+
+import random
+import string
+key_chars = "%s%s%s" %(string.letters, string.digits, '+-()_#~')
+SECRET_KEY = "".join([random.choice(key_chars) for a in range(0,50)])
+
+# 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',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+ROOT_URLCONF = 'urls'
+
+TEMPLATE_DIRS = (
+ os.path.join(topdir, 'templates')
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'recipes',
+)
+
+TEMPLATE_CONTEXT_PROCESSORS = (
+ 'django.core.context_processors.auth',
+ 'django.core.context_processors.debug',
+ 'django.core.context_processors.i18n',
+ 'generic.context_processors.media',
+)
+
+try:
+ from localsettings import *
+except:
+ pass
+
--- /dev/null
+from django.conf.urls.defaults import *
+from django.views.generic.simple import direct_to_template
+from django.views.static import serve
+from django.conf import settings
+
+# Uncomment the next two lines to enable the admin:
+from django.contrib import admin
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ # Example:
+ # (r'^recipes/', include('recipes.urls')),
+ (r'^$', direct_to_template, {"template": 'main_index.html'},),
+ (r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT, 'show_indexes': False}),
+ (r'^admin/(.*)', admin.site.root),
+)
--- /dev/null
+body {
+ background: white;
+ color: black;
+ font-family: arial, helvetica, sans-serif;
+}
+
+#page {
+ position: relative;
+ width: 98%;
+}
+
+#websitetitle img.logoleft {
+ float: left;
+}
+
+#websitetitle img.logoright {
+ float: right;
+}
+
+#websitetitle p.title {
+ font-size: 240%;
+ vertical-align: middle;
+ text-align: center;
+ padding-left: 1em;
+ padding-right: 1em;
+}
+
+#content {
+ clear: both;
+ width: 100%;
+}
--- /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
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <title>{% block title %}{% if title %}{{ title }}{% else %}EATSLUGS{% endif %}{% endblock %}</title>
+ <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}style/main.css" />
+ {% block extrahead %}{% endblock %}
+ </head>
+ <body>
+ <div id="page">
+ <div id="websitetitle">
+ <img src="{{ MEDIA_URL }}img/sandwich.png" alt="A Yummy Sandwich" class="logoleft" /><img src="{{ MEDIA_URL }}img/slug.png" alt="A Slug... no, really." class="logoright" /><p class="title">East Anglian Sandwich, Toasty and Luncheon Users Group Symposium</p>
+ </div>
+ <div id="content">
+ {% block content %}
+ {% endblock %}
+ </div>
+ </div>
+ </body>
+</html>
--- /dev/null
+{% extends "base.html" %}
+
+{% block content %}
+ <h1>Welcome to the EATSLUGS website</h1>
+ <p>
+ This will be a collection of random sandwich and drink combinations come up with by our resident experts (or just generally by us lot being insane...) - we hope you will like them.
+ </p>
+{% endblock %}