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 options = { 'writing': BuildWriting, 'photo_galleries': BuildPhotos, 'projects': BuildProjects, 'pages': PageGenerator, 'map': BuildMap, 'feed': BuildWritingFeed, 'sitemap': BuildSitemap, } def do_build(request): section = request.GET.get('id', '') context = {} if section == 'newpost': BuildWriting().build() BuildMap().build() 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() context = {'message': 'Crawling Flickr for new photosets'} else: options[section]().build() context = {'message': 'Writing %s to Disk' % section} return render_to_response('admin/message.html', context, context_instance=RequestContext(request))