diff options
author | luxagraf <sng@luxagraf.net> | 2015-11-06 23:09:56 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-11-06 23:09:56 -0500 |
commit | dbb8c23a81361b2bdd1128c997c8ce74a0cb4bd7 (patch) | |
tree | 05496f5684b216565dd8ebb6e18e1c7eddc96638 /app/src/build.py | |
parent | 78dc05f455f234da32c8c4d60b1b074755758d1c (diff) |
refactored src to use new build system with CBVs
Diffstat (limited to 'app/src/build.py')
-rw-r--r-- | app/src/build.py | 91 |
1 files changed, 49 insertions, 42 deletions
diff --git a/app/src/build.py b/app/src/build.py index a60f80c..6fe1f17 100644 --- a/app/src/build.py +++ b/app/src/build.py @@ -1,51 +1,58 @@ -from builder.base import * -from .models import Topic, Entry +import os +from builder.base import BuildNew +from django.core.urlresolvers import reverse +from . import models -class BuildSrc(Build): +class BuildSrc(BuildNew): + 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 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/' - 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 = 'src/' + self.build_list_view( + base_path=reverse("src:list"), + ) + self.build_list_view( + base_path=reverse("src:list_books"), + ) + self.build_detail_view() + # These are the unique classes for this model: + self.build_books_view() + self.build_topic_view() + self.build_feed("src:feed") + + def build_topic_view(self): + for topic in models.Topic.objects.all(): + url = reverse("src:list_topics", kwargs={'slug': topic.slug, }) + path, slug = os.path.split(url) + response = self.client.get(url, HTTP_HOST='127.0.0.1') + self.write_file('%s/' % path, response.content, filename=slug) + + def build_books_view(self): + for obj in models.Book.objects.all(): + url = reverse("src:detail_book", kwargs={'slug': obj.slug, }) + path, slug = os.path.split(url) + response = self.client.get(url, HTTP_HOST='127.0.0.1') + self.write_file('%s/' % path, response.content, filename=slug) + + + +def builder(): + j = BuildSrc("src", "entry") + j.build() + + +""" + + + + + def build_books(self): + path = 'src/books/' c = Context({ - 'object_list': Entry.objects.filter(status__exact=1), + 'object_list': Book.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') + t = render_to_string('archives/src_books.html', c).encode('utf-8') self.write_file(path, t) - def build_topic_archive(self): - for topic in Topic.objects.all(): - path = 'src/topic/' - c = Context({ - 'object_list': Entry.objects.filter(topics__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, 'html', topic.slug) - - def build_feed(self): - qs = Entry.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' % ('/src/rss/',) - self.write_file(fpath, t, 'xml') +""" |