diff options
Diffstat (limited to 'app/builder')
-rw-r--r-- | app/builder/base.py | 17 | ||||
-rw-r--r-- | app/builder/views.py | 22 |
2 files changed, 37 insertions, 2 deletions
diff --git a/app/builder/base.py b/app/builder/base.py index 0d2cb0f..839c522 100644 --- a/app/builder/base.py +++ b/app/builder/base.py @@ -1,4 +1,6 @@ import os +from operator import attrgetter +from itertools import chain from math import ceil from decimal import Decimal from django.test.client import Client @@ -150,3 +152,18 @@ class BuildPages(BuildNew): fpath = '%s' %(page.slug) self.write_file('', t, 'html', page.slug) self.write_file('', t, 'txt', page.slug) + + +class BuildRSS(BuildNew): + def build(self): + entry_list = apps.get_model('blog', 'entry').objects.filter(status=1) + link_list = apps.get_model('links', 'link').objects.filter(status=1) + result_list = sorted( + chain(entry_list, link_list), + key=attrgetter('pub_date') + ) + qs = reversed(result_list) + c = {'object_list': qs, 'SITE_URL': settings.SITE_URL} + t = render_to_string('feed.xml', c).encode('utf-8') + fpath = '%s' % ('rss/',) + self.write_file(fpath, t, 'xml') diff --git a/app/builder/views.py b/app/builder/views.py index 9d12aaa..3c63b00 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -1,13 +1,31 @@ from django.shortcuts import render_to_response -from django.template import RequestContext -#from src.build import builder as src_builder from pages.build import builder as page_builder +from builder.base import BuildSitemap, BuildRSS +from blog.build import essaybuilder, homebuilder +from links.build import linkbuilder def do_build(request): section = request.GET.get('id', '') context = {} + if section == 'essays': + context = {'message': 'Writing Essays to Disk'} + essaybuilder() + if section == 'links': + context = {'message': 'Writing Links to Disk'} + linkbuilder() if section == 'pages': context = {'message': 'Writing Pages to Disk'} page_builder() + if section == 'home': + context = {'message': 'Writing Homepage to Disk'} + homebuilder() + if section == 'sitemap': + context = {'message': 'Writing Sitemap to Disk'} + j = BuildSitemap("blog", "Entry") + j.build() + if section == 'rss': + context = {'message': 'Writing RSS feed to Disk'} + j = BuildRSS("blog", "Entry") + j.build() return render_to_response('admin/message.html', context) |