summaryrefslogtreecommitdiff
path: root/app/figments/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/figments/build.py')
-rw-r--r--app/figments/build.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/figments/build.py b/app/figments/build.py
new file mode 100644
index 0000000..b0890fd
--- /dev/null
+++ b/app/figments/build.py
@@ -0,0 +1,51 @@
+from builder.base import *
+from .models import Figment, Series
+
+
+class BuildSrc(Build):
+ def build(self):
+ self.build_archive()
+ self.build_topic_archive()
+ self.build_detail_pages()
+ self.build_feed()
+
+ 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 Figment.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/fignments.html', c).encode('utf-8')
+ path = 'figments/'
+ self.write_file(path, t, 'html', entry.slug)
+ s = render_to_string('details/note.txt', c).encode('utf-8')
+ self.write_file(path, s, 'txt', entry.slug)
+
+ def build_archive(self):
+ path = 'figments/'
+ c = Context({
+ 'object_list': Figment.objects.filter(status__exact=1),
+ 'MEDIA_URL': settings.BAKED_MEDIA_URL,
+ 'IMAGES_URL': settings.BAKED_IMAGES_URL
+ })
+ t = render_to_string('archives/figments.html', c).encode('utf-8')
+ self.write_file(path, t)
+
+ def build_topic_archive(self):
+ for series in Series.objects.all():
+ path = 'figments/series/'
+ c = Context({
+ 'object_list': Figment.objects.filter(series__slug=series.slug),
+ 'series': series,
+ 'MEDIA_URL': settings.BAKED_MEDIA_URL,
+ 'IMAGES_URL': settings.BAKED_IMAGES_URL
+ })
+ t = render_to_string('archives/figments.html', c).encode('utf-8')
+ self.write_file(path, t, 'html', topic.slug)
+
+ def build_feed(self):
+ qs = Figments.objects.filter(status__exact=1)
+ c = Context({'object_list': qs, 'SITE_URL': settings.SITE_URL})
+ t = render_to_string('feed.xml', c).encode('utf-8')
+ fpath = '%s' % ('/figments/rss/',)
+ self.write_file(fpath, t, 'xml')