]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Lots of changes to fix lots of bugs and add comments to blog
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 9 Sep 2009 16:11:45 +0000 (17:11 +0100)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 9 Sep 2009 16:11:45 +0000 (17:11 +0100)
20 files changed:
sommitrealweird/blog/context_processors.py
sommitrealweird/blog/feeds.py
sommitrealweird/blog/templates/blog/blog_index.html
sommitrealweird/blog/templates/blog/feeds/description.html
sommitrealweird/blog/templates/blog/single_entry_rst.html
sommitrealweird/blog/views.py
sommitrealweird/bpcms/admin.py
sommitrealweird/bpcms/context_processors.py
sommitrealweird/bpcms/models.py
sommitrealweird/bpcms/templates/bpcms/html.html
sommitrealweird/bpcms/templates/bpcms/rst.html
sommitrealweird/bpcms/urls.py
sommitrealweird/bpcms/views.py
sommitrealweird/photo/templates/photo/album_index.html
sommitrealweird/photo/templates/photo/photo.html
sommitrealweird/photo/templates/photo/photo_index.html
sommitrealweird/photo/urls.py
sommitrealweird/settings.py
sommitrealweird/urls.py
templates/base.html

index bbfc3eae02a2135dc6714e5031a7f22fe53f905e..9c203cfcf3103103159eace676a744493c2e9603 100644 (file)
@@ -2,6 +2,11 @@ from django.conf import settings
 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:
index 8242cfea56a3b2dd2adb47e997492f59ccb3dc0e..69eb81fe346d323dacb11add90740623ae66e7e4 100644 (file)
@@ -23,6 +23,12 @@ class LatestBlogEntriesRss(Feed):
     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
 
index d4a86cdfea5c66d6e36769868733141ec401c528..f7f3ab0373d0a588f7734cfe1281e5ec6dda6db7 100644 (file)
@@ -1,8 +1,9 @@
 {% 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 %}
index d16eb9be1544c999fea21f1bf7b21fd006b93253..b9c17eac381b3a09e8ae35d34a9afb135385d37b 100644 (file)
@@ -1,3 +1,3 @@
-{% load markup %}
+{% load xhtml11rst %}
 
 {{ obj.content|restructuredtext }}
index 2fa2af2a9bca92a1c25c30f96454ade1de8d2a28..9b49f5539dccb7dcd4f0867a877530bed3c7c791 100644 (file)
@@ -1,10 +1,6 @@
 {% extends "base.html" %}
 
-{% load markup %}
-
-{% block title %}
-{{ entry.title }}
-{% endblock %}
+{% load xhtml11rst %}
 
 {% block content %}
 <h1>{{ entry.title }}</h1>
index 08b52670cb00ce3c15507d9e500e8b7631d7e7e8..841b1ca2d0d7a5e1e1419a26cc51de0ecbe29e68 100644 (file)
@@ -43,16 +43,19 @@ def blog_view(request, year=None, month=None, day=None, hour=None, minutes=None,
             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:
index 2c4c86d24db75087443f93cc8ffa0f80568b3370..cb6d3960be874278fd7524ceb4735b50b7b587e7 100644 (file)
@@ -1,8 +1,14 @@
-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)
 
index a78976df893f1f919eff7a92b6f959b431bcb3b5..c235c9b31e39db17b27da878d49a7eabada45517 100644 (file)
@@ -14,7 +14,7 @@ def content_menu(request):
                 menu_items.append(
                     {
                         'title': item.title,
-                        'url': item.get_basic_url(),
+                        'url': item.get_absolute_url(),
                     }
                 )
         folders = Folder.objects.filter(parent__isnull=True)
@@ -25,7 +25,7 @@ def content_menu(request):
                 menu_items.append(
                     {
                         'title': item.title,
-                        'url': folder.get_basic_url(),
+                        'url': folder.get_absolute_url(),
                     }
                 )
             except:
@@ -70,26 +70,20 @@ def content_submenu(request):
                     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()))
@@ -122,10 +116,10 @@ def content_breadcrumb(request):
             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
@@ -137,7 +131,7 @@ def content_breadcrumb(request):
                 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
index f3d9b8ae492a7da57e29cd387a7e2ed74616e3ee..ca3eb06a380326a3cda7142f9f0b9e2300cf3359 100644 (file)
@@ -2,15 +2,28 @@ from django.db import models
 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()
@@ -20,7 +33,7 @@ class Document(models.Model):
         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()
@@ -35,19 +48,30 @@ class Document(models.Model):
                 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()
@@ -65,12 +89,9 @@ class Folder(models.Model):
         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):
@@ -79,7 +100,9 @@ class Folder(models.Model):
             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})
index b6466bbdcf094567a36e019d473f3a41b22b72ac..7728032cc1fdb999eccb598e487995169fc3f74b 100644 (file)
@@ -1,5 +1,4 @@
-{% extends "base.html" %}
-{% load markup %}
+{% extends "bpcms/bpcms.html" %}
 
 {% block content %}
 <h1>{{ title }}</h1>
index 5257b78e523c0d24198e272808879b608c4e12b6..caf2f4f2928212b42e642c69b33badda61ff3b2d 100644 (file)
@@ -1,5 +1,5 @@
-{% extends "base.html" %}
-{% load markup %}
+{% extends "bpcms/bpcms.html" %}
+{% load xhtml11rst %}
 
 {% block content %}
 <h1>{{ title }}</h1>
index 9143a6714d3351d85549a4116bf4f786529169cf..d29225af7e0dc49a1e3a10c70d32d474f1c4b02b 100644 (file)
@@ -2,6 +2,7 @@ from django.conf.urls.defaults import *
 
 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'),
 )
index fd23428a89498c5816674696c956ddeb697fa0ad..9cb3e42e031b7ce7162df2a05a81bbc139dd2c68 100644 (file)
@@ -1,4 +1,4 @@
-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
 
@@ -62,5 +62,14 @@ def document_view(request, slug=None, folders=None):
         {
             "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")
+    
index 83c179170e2b71f0016cbde227cb664e487ebc90..beaeacbd6300333795079ec794917138bc0528dc 100644 (file)
@@ -1,6 +1,8 @@
 {% extends "base.html" %}
 {% load thumbnail %}
-{% load markup %}
+{% load xhtml11rst %}
+
+{% block title %}Photos{% endblock %}
 
 {% block content %}
     {% if object_list %}
index b62dc07f1eea1af3b62adee6c720740df4e02b94..5a0e04b761c9ffce5ffb0ac74ebb7acc2cfaa10f 100644 (file)
@@ -1,6 +1,8 @@
 {% 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>
index 1afcccf5868ad6e6e912ed49d40c711de06838e3..27e441793c72123650a0718ef04893480dcebd97 100644 (file)
@@ -1,6 +1,8 @@
 {% 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>
index 64026ce61393d68e2b51627fd8ce5eb9b7e0b797..12c8dfbba02250291d6abe4c8bac933af24aaf26 100644 (file)
@@ -2,7 +2,7 @@ from django.conf.urls.defaults import *
 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'),
 )
index cc4b236e7c62d97891f6fc6a2b632b96cf1621c7..f0a5725bf29ebe99bb5ce0aba1c1d860475922c0 100644 (file)
@@ -82,6 +82,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     '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',
 )
 
@@ -89,7 +90,6 @@ APPEND_SLASH=False
 
 RESTRUCTUREDTEXT_FILTER_SETTINGS = {
     'initial_header_level': 2,
-    'compact_field_list': 0,
 }
 
 BPCMS_ROOT = '/'
@@ -101,6 +101,7 @@ BPCMS_DISALLOWED_ROOT_DOC_NAMES = (
 
 BLOG_ROOT = '/blog/'
 BLOG_TITLE = u'The World of SommitRealWeird.'
+BLOG_FEED_ROOT = '/feeds/blog/'
 
 try:
     from localsettings import *
index 23c848ccf6e54de525e676afc63479b51092d6bb..dc24d72990bf072f98dc7d31eb03e68093c5b023 100644 (file)
@@ -25,6 +25,7 @@ urlpatterns = patterns('',
     (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'))
index ee565e117bc45884d7d802a130bce276e1ed4e5c..3446a04cdec4fb2aa59cf42f6744191d13178f7c 100644 (file)
@@ -4,6 +4,7 @@
     <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">
@@ -54,7 +55,7 @@
                 {% endblock %}
             </div>
             <div id="footer">
-                <p>Copyright &copy; 2008 - <a href="mailto:iDunno@sommitrealweird.co.uk">Brett Parker</a></p>
+                <p>Copyright &copy; 2008, 2009 - <a href="mailto:iDunno@sommitrealweird.co.uk">Brett Parker</a></p>
             </div>
         </div>
     </body>