summaryrefslogtreecommitdiff
path: root/app/builder/views.py
blob: 04c128509bbab8e0a62a214fe4bb0a013144b4e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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))