from blog.models import BlogEntry, BlogSection
import re
+def blog_feed(request):
+ return {
+ 'BLOG_FEED_ROOT': settings.BLOG_FEED_ROOT,
+ }
+
def content_breadcrumb(request):
path = request.path
if path[0:len(settings.BLOG_ROOT)] == settings.BLOG_ROOT:
def author_email(self, obj):
return "iDunno@sommitrealweird.co.uk"
+ def item_author_name(self, obj):
+ return "Brett Parker"
+
+ def item_author_email(self, obj):
+ return "iDunno@sommitrealweird.co.uk"
+
def item_pubdate(self, obj):
return obj.publish_date
{% extends "base.html" %}
-{% load markup %}
+{% load xhtml11rst %}
-{% block title %}
-The world of sommitrealweird.
+{% block extrahead %}
+<link rel="alternate" type="application/atom+xml" title="iDunno's Blog - Atom Feed" href="{{ BLOG_FEED_ROOT }}/blog/" />
+<link rel="alternate" type="application/rss+xml" title="iDunno's Blog - RSS Feed" href="{{ BLOG_FEED_ROOT }}/blog/rss/" />
{% endblock %}
{% block content %}
-{% load markup %}
+{% load xhtml11rst %}
{{ obj.content|restructuredtext }}
{% extends "base.html" %}
-{% load markup %}
-
-{% block title %}
-{{ entry.title }}
-{% endblock %}
+{% load xhtml11rst %}
{% block content %}
<h1>{{ entry.title }}</h1>
year = int(year)
month = int(month)
day = int(day)
- blog_entry = BlogEntry.objects.get(publish_date__year=year, publish_date__month=month, publish_date__day=day, slug__exact=slug)
- template_name = "blog/single_entry_%s.html" %(blog_entry.format,)
- t = loader.get_template(template_name)
- c = RequestContext(request,
- {
- "entry": blog_entry,
- "publish_date": blog_entry.publish_date
- }
- )
- return HttpResponse(t.render(c))
+ try:
+ blog_entry = BlogEntry.objects.get(publish_date__year=year, publish_date__month=month, publish_date__day=day, slug__exact=slug)
+ template_name = "blog/single_entry_%s.html" %(blog_entry.format,)
+ t = loader.get_template(template_name)
+ c = RequestContext(request,
+ {
+ "entry": blog_entry,
+ "publish_date": blog_entry.publish_date
+ }
+ )
+ return HttpResponse(t.render(c))
+ except:
+ raise Http404
else:
entries = BlogEntry.objects.all()
if year and month and day:
-from models import Document, Folder
+from models import CSSDocument, Document, Folder
from django.contrib import admin
+class CSSDocumentAdmin(admin.ModelAdmin):
+ prepopulated_fields = { "slug": ("title",) }
+
+admin.site.register(CSSDocument, CSSDocumentAdmin)
+
class DocumentAdmin(admin.ModelAdmin):
prepopulated_fields = { "slug": ("title",) }
+ fields = ( "title", "islive", "extracss", "folder", "format", "slug", "content" )
admin.site.register(Document, DocumentAdmin)
menu_items.append(
{
'title': item.title,
- 'url': item.get_basic_url(),
+ 'url': item.get_absolute_url(),
}
)
folders = Folder.objects.filter(parent__isnull=True)
menu_items.append(
{
'title': item.title,
- 'url': folder.get_basic_url(),
+ 'url': folder.get_absolute_url(),
}
)
except:
menu_items.append(
{
'title': item.title,
- 'url': item.get_basic_url(),
+ 'url': item.get_absolute_url(),
}
)
- try:
- folders = Folder.objects.filter(parent__exact=folder)
- except:
- pass
+ folders = Folder.objects.filter(parent__exact=folder)
for folder in folders:
- try:
- items = Document.objects.filter(folder__exact=folder, \
- islive__exact=True, slug__exact='index')
- for item in items:
- menu_items.append(
- {
- 'title': item.title,
- 'url': folder.get_basic_url(),
- }
- )
- except:
- pass
+ items = Document.objects.filter(folder__exact=folder, \
+ islive__exact=True, slug__exact='index')
+ for item in items:
+ menu_items.append(
+ {
+ 'title': item.title,
+ 'url': folder.get_absolute_url(),
+ }
+ )
menu_items.sort( \
cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower()))
try:
item = Document.objects.get(folder__exact=folder,
slug__exact=u'index', islive__exact=True)
- breadcrumb.append({'url': folder.get_basic_url(),
+ breadcrumb.append({'url': folder.get_absolute_url(),
'title': item.title})
except:
- breadcrumb.append({'url': folder.get_basic_url(),
+ breadcrumb.append({'url': folder.get_absolute_url(),
'title': folder.title})
except:
# must have hit the end of the tree, lets see if we can get an
else:
item = Document.objects.get(folder__isnull=True, \
slug__exact=part, islive__exact=True)
- breadcrumb.append({'url': item.get_basic_url(), 'title': item.title})
+ breadcrumb.append({'url': item.get_absolute_url(), 'title': item.title})
except:
pass
break
from django.conf import settings
from django.contrib import admin
from django.core.cache import cache
+from django.core.urlresolvers import reverse
FORMAT_CHOICES = (
('rst', 'reStructuredText'),
('html', 'HTML'),
)
+class CSSDocument(models.Model):
+ title = models.CharField(max_length=150)
+ slug = models.SlugField()
+ content = models.TextField()
+
+ def __str__(self):
+ return self.__unicode__()
+
+ def __unicode__(self):
+ return u'%s' %(self.title,)
+
class Document(models.Model):
title = models.CharField(max_length=150)
islive = models.BooleanField()
+ extracss = models.ManyToManyField(CSSDocument, null=True, blank=True)
folder = models.ForeignKey('Folder', null=True, blank=True)
format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
slug = models.SlugField()
return self.__unicode__()
def __unicode__(self):
- return u'%s - %s' %(self.get_basic_url(), self.title)
+ return u'%s (%s)' %(self.title, self.slug)
def save(self):
super(Document, self).save()
doc.save()
def get_basic_url(self):
- folders = []
- curfolder = self.folder
- while curfolder != None:
- folders.append(curfolder.slug)
- curfolder = curfolder.parent
-
- folders.reverse()
- folderstring = "/".join(folders)
+ folderstring = self.get_folder_path()
if folderstring != u'':
folderstring = "%s/" %(folderstring,)
return "%s%s%s/" %(settings.BPCMS_ROOT, folderstring, self.slug)
+ def get_folder_path(self):
+ if not self.folder:
+ return ''
+ else:
+ return self.folder.get_path()
+
+ def get_absolute_url(self):
+ if self.slug == 'index':
+ if self.folder.parent:
+ return reverse('bpcms.views.document_view', kwargs={'folders': self.folder.parent.get_path(), 'slug': self.folder.slug})
+ else:
+ return reverse('bpcms.views.document_view', kwargs={'slug': self.folder.slug})
+ else:
+ if self.folder:
+ return reverse('bpcms.views.document_view', kwargs={'folders': self.get_folder_path(), 'slug': self.slug})
+ else:
+ return reverse('bpcms.views.document_view', kwargs={'slug': self.slug})
+
class Folder(models.Model):
title = models.CharField(max_length=150)
slug = models.SlugField()
while curfolder != None:
folders.append(curfolder.slug)
curfolder = curfolder.parent
-
+
folders.reverse()
folderstring = "/".join(folders)
- if folderstring != u'':
- folderstring = "%s/" %(folderstring,)
-
return folderstring
def save(self, force_insert=False, force_update=False):
cache.delete('bpcms_mainmenu')
else:
cache.delete('bpcms_submenu_%s' %(self.get_path()))
-
- def get_basic_url(self):
- return "%s%s" %(settings.BPCMS_ROOT, self.get_path())
+ def get_absolute_url(self):
+ if self.parent:
+ return reverse('bpcms.views.document_view', kwargs={'folders': self.parent.get_path(), 'slug': self.slug})
+ else:
+ return reverse('bpcms.views.document_view', kwargs={'slug': self.slug})
-{% extends "base.html" %}
-{% load markup %}
+{% extends "bpcms/bpcms.html" %}
{% block content %}
<h1>{{ title }}</h1>
-{% extends "base.html" %}
-{% load markup %}
+{% extends "bpcms/bpcms.html" %}
+{% load xhtml11rst %}
{% block content %}
<h1>{{ title }}</h1>
urlpatterns = patterns('',
(r'^$', 'bpcms.views.document_view', {'slug': 'index'}),
+ (r'^css-docs/(?P<slug>.*)$', 'bpcms.views.css_view'),
(r'^(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
(r'^(?P<folders>.*)/(?P<slug>[^/]+)/$', 'bpcms.views.document_view'),
)
-from bpcms.models import Document, Folder
+from bpcms.models import CSSDocument, Document, Folder
from django.http import Http404, HttpResponse
from django.template import RequestContext, loader
{
"content" : doc.content,
"title" : doc.title,
+ "extracss" : doc.extracss.all(),
})
return HttpResponse(t.render(c))
+
+def css_view(request, slug):
+ cssdoc = CSSDocument.objects.get(slug=slug)
+ if not cssdoc:
+ raise Http404()
+
+ return HttpResponse(cssdoc.content, content_type="text/css")
+
{% extends "base.html" %}
{% load thumbnail %}
-{% load markup %}
+{% load xhtml11rst %}
+
+{% block title %}Photos{% endblock %}
{% block content %}
{% if object_list %}
{% extends "base.html" %}
{% load thumbnail %}
+{% block title %}Photos - {{ object.album.title }} - {{ object.caption }}{% endblock %}
+
{% block content %}
<div class="single_photo">
<a href="{{ object.image.url }}"><img src='{{ object.image.url|thumbnail:"width=500" }}' alt="{{ object.caption }}" /></a>
{% extends "base.html" %}
{% load thumbnail %}
+{% block title %}Photos - {{ object_list.0.album.caption }}{% endblock %}
+
{% block content %}
{% if object_list %}
<h1>{{ object_list.0.album.name }}</h1>
from models import Album
urlpatterns = patterns('',
- (r'^$', 'django.views.generic.list_detail.object_list', { "paginate_by": 20, "queryset": Album.objects.all().order_by('name'), "template_name": "photo/album_index.html"}),
+ (r'^$', 'django.views.generic.list_detail.object_list', { "paginate_by": 20, "queryset": Album.objects.all().order_by('name').reverse(), "template_name": "photo/album_index.html"}),
(r'^(?P<slug>[^/]*)/$', 'photo.views.album_view'),
(r'^(?P<slug>[^/]*)/(?P<id>[0-9]+)/$', 'photo.views.photo_view'),
)
'bpcms.context_processors.content_submenu',
'bpcms.context_processors.content_breadcrumb',
'blog.context_processors.content_breadcrumb',
+ 'blog.context_processors.blog_feed',
'photo.context_processors.content_breadcrumb',
)
RESTRUCTUREDTEXT_FILTER_SETTINGS = {
'initial_header_level': 2,
- 'compact_field_list': 0,
}
BPCMS_ROOT = '/'
BLOG_ROOT = '/blog/'
BLOG_TITLE = u'The World of SommitRealWeird.'
+BLOG_FEED_ROOT = '/feeds/blog/'
try:
from localsettings import *
(r'^admin/(.*)$', admin.site.root),
(r'^blog/', include('blog.urls')),
(r'^photo/', include('photo.urls')),
+ (r'^photos/', include('photo.urls')),
(r'^feeds/rss/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': rssfeeds_dict}),
(r'^feeds/(?P<url>.*)/', 'django.contrib.syndication.views.feed', {'feed_dict': feeds_dict}),
(r'^(?:content/|)', include('bpcms.urls'))
<head>
<title>{% block title %}{{ title }}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}style/main.css" />
+ {% block extrahead %}{% endblock %}
</head>
<body>
<div id="page">
{% endblock %}
</div>
<div id="footer">
- <p>Copyright © 2008 - <a href="mailto:iDunno@sommitrealweird.co.uk">Brett Parker</a></p>
+ <p>Copyright © 2008, 2009 - <a href="mailto:iDunno@sommitrealweird.co.uk">Brett Parker</a></p>
</div>
</div>
</body>