diff options
author | luxagraf <sng@luxagraf.net> | 2014-11-10 20:44:49 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2014-11-10 20:44:49 -0500 |
commit | f650f1860eabfb7d114513dbd0980698ca2b7f84 (patch) | |
tree | a190e56d224baeeb3c8cc7adeb4233c47646c79f /app/builder | |
parent | d283e039666fa57ccf06c3d235162927db285fb8 (diff) |
reverted Pages to database
Diffstat (limited to 'app/builder')
-rw-r--r-- | app/builder/base.py | 15 | ||||
-rw-r--r-- | app/builder/views.py | 18 |
2 files changed, 24 insertions, 9 deletions
diff --git a/app/builder/base.py b/app/builder/base.py index 7382655..0b92832 100644 --- a/app/builder/base.py +++ b/app/builder/base.py @@ -7,7 +7,7 @@ from django.template import Context from django.db.models import get_model from django.conf import settings -from pages.models import PageGenerator +#from pages.models import PageGenerator class Build(): def write_file(self, path, text_object, ext='html', filename='index'): @@ -57,7 +57,7 @@ class BuildAll(Build): BuildMap().build() BuildWritingFeed().build() BuildSitemap().build() - p = PageGenerator(settings.PROJ_ROOT + '_pages') + BuildPages().build() p.write_files() class BuildWriting(Build): @@ -261,6 +261,17 @@ class BuildWritingFeed(Build): fpath = '%s' % ('rss/',) self.write_file(fpath, t, 'xml') +class BuildPages(Build): + def build(self): + model = get_model('pages', 'page') + pages = model.objects.all() + for page in pages: + c = Context({'object':page,'SITE_URL':settings.SITE_URL, 'MEDIA_URL':settings.BAKED_MEDIA_URL}) + t = render_to_string(["details/%s.html" % page.slug, 'details/page.html'],c).encode('utf-8') + s = render_to_string('details/page.txt',c).encode('utf-8') + fpath = '%s' %(page.slug) + self.write_file(fpath,t) + self.write_file(fpath,s,'txt') class BuildMap(Build): def build(self): diff --git a/app/builder/views.py b/app/builder/views.py index 04c1285..4d820e2 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -1,14 +1,14 @@ from django.shortcuts import render_to_response from django.template import RequestContext from django.conf import settings -from builder.base import BuildWriting, BuildWritingFeed, BuildMap, BuildPhotos, BuildProjects, BuildSitemap -from pages.models import PageGenerator +from builder.base import BuildWriting, BuildWritingFeed, BuildMap, BuildPhotos, BuildProjects, BuildSitemap, BuildPages +#from pages.models import PageGenerator options = { 'writing': BuildWriting, 'photo_galleries': BuildPhotos, 'projects': BuildProjects, - 'pages': PageGenerator, + 'pages': BuildPages, 'map': BuildMap, 'feed': BuildWritingFeed, 'sitemap': BuildSitemap, @@ -24,10 +24,6 @@ def do_build(request): BuildWritingFeed().build() BuildSitemap().build() context = {'message': 'Writing %s to Disk' % section} - elif section == 'pages': - p = PageGenerator(settings.PROJ_ROOT + '_pages') - p.write_files() - context = {'message': 'Building pages from flatfiles'} elif section == 'scrapeflickr': from photos import retriever retriever.sync_sets() @@ -36,3 +32,11 @@ def do_build(request): options[section]().build() context = {'message': 'Writing %s to Disk' % section} return render_to_response('admin/message.html', context, context_instance=RequestContext(request)) + + +""" +elif section == 'pages': + p = PageGenerator(settings.PROJ_ROOT + '_pages') + p.write_files() + context = {'message': 'Building pages from flatfiles'} +""" |