diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/blog/signals.py | 38 | ||||
-rw-r--r-- | apps/build/base.py | 57 | ||||
-rw-r--r-- | apps/photos/retriever.py | 2 |
3 files changed, 50 insertions, 47 deletions
diff --git a/apps/blog/signals.py b/apps/blog/signals.py index 798a78f..55f2efa 100644 --- a/apps/blog/signals.py +++ b/apps/blog/signals.py @@ -6,32 +6,16 @@ from django.conf import settings from locations.models import Region,Country,Route +from build.base import BuildWriting + def update_recent(sender, instance, signal, *args, **kwargs): if not settings.DEVELOPMENT: - # Update recent entries static file - model = get_model('blog', 'entry') - qs = {'object_list': model.objects.filter(status__exact=1).order_by('-pub_date')[1:4]} - c = Context(qs) - t = render_to_string('bin/recent_entries.html',c) - fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/recent_entries.html') - file = open(fpath, 'w') - file.write(t) - file.close() - # Update map template - import codecs - qs = model.objects.filter(status__exact=1) - cl = Country.objects.filter(visited=True).exclude(name='default') - rl = Region.objects.all() - rtl = Route.objects.all() - c = Context({'object_list':qs, 'country_list':cl,'region_list':rl, 'route_list':rtl}) - t = render_to_string('bin/map_entry_list.html',c) - fpath = '%s%s' %(settings.PROJ_ROOT,'media/js/mainmap.js') - file = codecs.open(fpath, 'w','utf8') - file.write(t) - file.close() - c = Context({'country_list':cl,'region_list':rl,'route_list':rtl}) - t = render_to_string('bin/map_sidebar.html',c) - fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/map_sidebar.html') - file = codecs.open(fpath, 'w','utf8') - file.write(t) - file.close()
\ No newline at end of file + if instance.status == 1: + #update homepage, archives and details + b = BuildWriting() + b.build_homepage() + b.build_archive_pages() + b.build_detail_pages() + #update map + b = BuildMap() + b.build()
\ No newline at end of file diff --git a/apps/build/base.py b/apps/build/base.py index d8e4cdc..9ba6dfb 100644 --- a/apps/build/base.py +++ b/apps/build/base.py @@ -17,6 +17,14 @@ class Build(): class BuildWriting(Build): + + + def build(self): + self.build_detail_pages() + self.build_archive_pages() + self.build_location_archive_pages() + self.build_homepage() + def get_model_querset(self): model = get_model('blog', 'entry') qs = model.objects.filter(status__exact=1) @@ -28,9 +36,9 @@ class BuildWriting(Build): ''' qs = self.get_model_querset() for entry in qs: - c = Context({'object':entry,'MEDIA_URL':settings.MEDIA_URL}) + c = Context({'object':entry,'MEDIA_URL':settings.BAKED_MEDIA_URL}) t = render_to_string('details/entry.html',c).encode('utf-8') - path = '%s%s/%s/' %(settings.STATIC_ROOT, entry.pub_date.strftime("%Y/%b/%d").lower(), entry.slug) + path = '%s%s/%s/' %(settings.BAKED_ROOT, entry.pub_date.strftime("%Y/%b/%d").lower(), entry.slug) if not os.path.isdir(path): os.makedirs(path) fpath = '%sindex.html' %(path) @@ -43,7 +51,7 @@ class BuildWriting(Build): pages = ceil(Decimal(qs.count())/Decimal(paginate_by)) print pages for page in range(int(pages)): - base_path = '%s%s' %(settings.STATIC_ROOT, extra) + base_path = '%s%s' %(settings.BAKED_ROOT, extra) path = '%s%s/' %(base_path, page+1) if not os.path.isdir(path): os.makedirs(path) @@ -77,13 +85,18 @@ class BuildWriting(Build): def build_homepage(self): self.build_recent_entries() qs = get_model('blog', 'entry').objects.filter(status__exact=1).latest() - c = Context({'featured':qs,'MEDIA_URL':settings.MEDIA_URL}) + c = Context({'featured':qs,'MEDIA_URL':settings.BAKED_MEDIA_URL}) t = render_to_string('archives/homepage.html',c).encode('utf-8') - fpath = '%s%s' %(settings.STATIC_ROOT,'index.html') + fpath = '%s%s' %(settings.BAKED_ROOT,'index.html') self.write_file(fpath,t) class BuildPhotos(BuildWriting): + + def build(self): + self.build_photo_archive_pages() + self.build_detail_pages() + def build_photo_archive_pages(self): qs = get_model('photos', 'PhotoGallery').objects.all() path = 'photos/' @@ -96,9 +109,9 @@ class BuildPhotos(BuildWriting): Grab all the blog posts, render them to a template string and write that out to the filesystem ''' for photo in qs: - c = Context({'object':photo,'MEDIA_URL':settings.MEDIA_URL}) + c = Context({'object':photo,'MEDIA_URL':settings.BAKED_MEDIA_URL}) t = render_to_string('details/photo_galleries.html',c).encode('utf-8') - path = '%sphotos/galleries/%s/' %(settings.STATIC_ROOT, photo.set_slug) + path = '%sphotos/galleries/%s/' %(settings.BAKED_ROOT, photo.set_slug) if not os.path.isdir(path): os.makedirs(path) fpath = '%sindex.html' %(path) @@ -113,10 +126,10 @@ class BuildAbout(Build): c = Context({ 'object_list': qs, 'IMAGES_URL' : settings.IMAGES_URL, - 'MEDIA_URL':settings.MEDIA_URL + 'MEDIA_URL':settings.BAKED_MEDIA_URL }) t = render_to_string('details/about.html',c).encode('utf-8') - path = '%sabout/' %(settings.STATIC_ROOT) + path = '%sabout/' %(settings.BAKED_ROOT) if not os.path.isdir(path): os.makedirs(path) fpath = '%sindex.html' %(path) @@ -130,20 +143,20 @@ class BuildMap(Build): cl = get_model('locations', 'Country').objects.filter(visited=True).exclude(name='default') rl = get_model('locations', 'Region').objects.all() rtl = get_model('locations', 'Route').objects.all() - c = Context({'object_list':qs, 'country_list':cl,'region_list':rl, 'route_list':rtl, 'MEDIA_URL':settings.MEDIA_URL}) + c = Context({'object_list':qs, 'country_list':cl,'region_list':rl, 'route_list':rtl, 'MEDIA_URL':settings.BAKED_MEDIA_URL}) t = render_to_string('bin/map_entry_list.html',c).encode('utf-8') fpath = '%s%s' %(settings.PROJ_ROOT,'media/js/mainmap.js') self.write_file(fpath,t) - c = Context({'country_list':cl,'region_list':rl,'route_list':rtl,'MEDIA_URL':settings.MEDIA_URL}) + c = Context({'country_list':cl,'region_list':rl,'route_list':rtl,'MEDIA_URL':settings.BAKED_MEDIA_URL}) t = render_to_string('bin/map_sidebar.html',c).encode('utf-8') fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/map_sidebar.html') self.write_file(fpath,t) def build(self): self.build_map_templates() - c = Context({'MEDIA_URL':settings.MEDIA_URL,}) + c = Context({'MEDIA_URL':settings.BAKED_MEDIA_URL,}) t = render_to_string('archives/map.html', c).encode('utf-8') - path = '%smap/' %(settings.STATIC_ROOT) + path = '%smap/' %(settings.BAKED_ROOT) if not os.path.isdir(path): os.makedirs(path) fpath = '%sindex.html' %(path) @@ -153,10 +166,16 @@ class BuildContact(Build): def build(self): c = Client() response = c.get('/contact/') - fpath = '%scontact/index.html' %(settings.STATIC_ROOT) + fpath = '%scontact/index.html' %(settings.BAKED_ROOT) self.write_file(fpath,str(response.content)) class BuildProjects(Build): + + def build(self): + self.build_project_archive() + self.build_project_details() + self.build_project_data() + def get_projects(self): all_proj = [] projects = get_model('projects', 'Project').objects.filter(status__exact=1).order_by('-pub_date') @@ -167,9 +186,9 @@ class BuildProjects(Build): def build_project_archive(self): qs = get_model('projects', 'Project').objects.filter(status__exact=1).order_by('-pub_date') - c = Context({'object_list': qs,'MEDIA_URL':settings.MEDIA_URL,}) + c = Context({'object_list': qs,'MEDIA_URL':settings.BAKED_MEDIA_URL,}) t = render_to_string('archives/projects.html', c).encode('utf-8') - path = '%sprojects/' %(settings.STATIC_ROOT) + path = '%sprojects/' %(settings.BAKED_ROOT) if not os.path.isdir(path): os.makedirs(path) fpath = '%sindex.html' %(path) @@ -183,9 +202,9 @@ class BuildProjects(Build): qs = model.objects.filter(visited__exact=True).order_by("-date_visited_begin") else: qs = model.objects.filter(status__exact=1) - c = Context({'object_list': qs,'MEDIA_URL':settings.MEDIA_URL,}) + c = Context({'object_list': qs,'MEDIA_URL':settings.BAKED_MEDIA_URL,}) t = render_to_string('details/%s.html' %(proj['slug']), c).encode('utf-8') - path = '%sprojects/%s/' %(settings.STATIC_ROOT, proj['slug']) + path = '%sprojects/%s/' %(settings.BAKED_ROOT, proj['slug']) if not os.path.isdir(path): os.makedirs(path) fpath = '%sindex.html' %(path) @@ -205,7 +224,7 @@ class BuildProjects(Build): json = str(json) json ="\n".join(json.splitlines()[3:]) #print json - path = '%sprojects/data/' %(settings.STATIC_ROOT) + path = '%sprojects/data/' %(settings.BAKED_ROOT) if not os.path.isdir(path): os.makedirs(path) fpath = '%s%s.json' %(path, park.id) diff --git a/apps/photos/retriever.py b/apps/photos/retriever.py index 8d7b07c..2a98d09 100644 --- a/apps/photos/retriever.py +++ b/apps/photos/retriever.py @@ -166,7 +166,7 @@ def slideshow_image(photo): img.save(filename) else: #image portrait - new_height = 600 + new_height = 800 #check to make sure we aren't upsizing if cur_height > new_height: ratio = float(new_height)/cur_height |