diff options
author | luxagraf <sng@luxagraf.net> | 2015-10-30 10:37:12 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-10-30 10:37:12 -0400 |
commit | f41c933746845277c66eb6c19f355d62ed7029aa (patch) | |
tree | 20a4f279599bbd583029a8231ce8132f5aad5dd7 /app/src/build.py | |
parent | 0afcb2b02354d4af9f53c5084b70b80afbce1a09 (diff) |
added build script and templates for topic pages
Diffstat (limited to 'app/src/build.py')
-rw-r--r-- | app/src/build.py | 23 |
1 files changed, 15 insertions, 8 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) |