summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/build.py23
-rw-r--r--app/src/urls.py1
-rw-r--r--app/src/views.py9
3 files changed, 24 insertions, 9 deletions
diff --git a/app/src/build.py b/app/src/build.py
index 46cfd79..3abd8ff 100644
--- a/app/src/build.py
+++ b/app/src/build.py
@@ -1,23 +1,19 @@
from builder.base import *
-from django.apps import apps
+from .models import Topic, Entry
class BuildSrc(Build):
def build(self):
self.build_archive()
+ self.build_topic_archive()
self.build_detail_pages()
- def queryset(self):
- return self.get_model().objects.filter(status__exact=1).order_by('-pub_date')
-
- def get_model(self):
- return apps.get_model('src', 'Entry')
def build_detail_pages(self):
'''
Grab all the notes, render them to a template string and write that out to the filesystem
'''
- for entry in self.queryset():
+ for entry in Entry.objects.filter(status__exact=1):
c = Context({'object': entry, 'MEDIA_URL': settings.BAKED_MEDIA_URL, 'IMAGES_URL': settings.BAKED_IMAGES_URL, 'SITE_URL':settings.SITE_URL})
t = render_to_string('details/src_entry.html', c).encode('utf-8')
path = 'src/'
@@ -28,10 +24,21 @@ class BuildSrc(Build):
def build_archive(self):
path = 'src/'
c = Context({
- 'object_list': self.queryset(),
+ 'object_list': Entry.objects.filter(status__exact=1),
'MEDIA_URL': settings.BAKED_MEDIA_URL,
'IMAGES_URL': settings.BAKED_IMAGES_URL
})
t = render_to_string('archives/src_home.html', c).encode('utf-8')
self.write_file(path, t)
+ def build_topic_archive(self):
+ for topic in Topic.objects.all():
+ path = 'src/%s' % topic.slug
+ c = Context({
+ 'object_list': Entry.objects.filter(topic__slug=topic.slug),
+ 'topic': topic,
+ 'MEDIA_URL': settings.BAKED_MEDIA_URL,
+ 'IMAGES_URL': settings.BAKED_IMAGES_URL
+ })
+ t = render_to_string('archives/src_home.html', c).encode('utf-8')
+ self.write_file(path, t)
diff --git a/app/src/urls.py b/app/src/urls.py
index c9e8077..a2368e3 100644
--- a/app/src/urls.py
+++ b/app/src/urls.py
@@ -4,6 +4,7 @@ from django.views.generic import ListView
from .models import Entry, Book
urlpatterns = patterns('',
+ (r'topic/(?P<slug>[-\w]+)/$', 'src.views.topic'),
(r'books/$', ListView.as_view(
queryset=Book.objects.filter(status__exact=1).order_by('-pub_date'),
template_name="archives/src_books.html",
diff --git a/app/src/views.py b/app/src/views.py
index f3803b9..ceba079 100644
--- a/app/src/views.py
+++ b/app/src/views.py
@@ -1,6 +1,13 @@
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
-from .models import Entry
+from .models import Entry, Topic
+
+
+def topic(request, slug):
+ obj = get_object_or_404(Topic, slug__exact=slug)
+ qs = Entry.objects.filter(topics__slug=slug).order_by('-pub_date')
+ return render_to_response('archives/src_home.html', {'object_list': qs, 'topic':obj}, context_instance=RequestContext(request))
+
def detail(request, slug):
obj = get_object_or_404(Entry, slug__exact=slug)