summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README24
-rw-r--r--app/blog/views.py6
-rw-r--r--app/build/base.py281
-rw-r--r--app/lib/templatetags/templatetags/html5_datetime.py16
-rw-r--r--app/pages/__init__.py0
-rw-r--r--app/pages/admin.py26
-rw-r--r--app/pages/models.py41
-rw-r--r--app/pages/views.py13
-rw-r--r--app/photos/models.py2
-rw-r--r--app/projects/admin.py15
-rw-r--r--app/projects/models/__init__.py3
-rw-r--r--app/projects/urls.py1
-rw-r--r--app/projects/views.py7
-rw-r--r--config/base_urls.py12
-rw-r--r--config/requirements.txt2
-rw-r--r--config/settings/settings.py169
-rw-r--r--design/templates/archives/homepage.html2
-rw-r--r--design/templates/archives/map.html29
-rw-r--r--design/templates/bin/map_entry_list.html111
19 files changed, 412 insertions, 348 deletions
diff --git a/README b/README
index 373f345..1d6587e 100644
--- a/README
+++ b/README
@@ -1,2 +1,24 @@
-created a v8 branch with the goal of merging in the pub system I've created for install plan and longhandpixels, but thus far I haven't done anything because I want to finish both of them first.
+Currently caught in the middle between static_generator and build
+Static generator is cleaner, but much of the build code is hard to port. Keep going back and rorth and so far neither works save for building the feed.
+
+What I should do is refactor both into a single clean module with methods for building the things I need to be able to build:
+
+# each section individually
+ * All Writing pages -- done
+ * All Photo -- done
+ * All Projects
+ * Links
+# Everything needed to post a new entry...
+ * writing archives
+ * map
+ * homepage
+ * feed
+ * sitemap
+# Individual pages that need periodic rebuilding
+ * feed -- done
+ * sitemap -- done
+ * map
+# The whole goddamn thing.
+
+In build each model has a build function that calls all the routines necessary to build everything. I like that model, but then I need to expose those functions a bit more.
diff --git a/app/blog/views.py b/app/blog/views.py
index 72c769e..8d14fe3 100644
--- a/app/blog/views.py
+++ b/app/blog/views.py
@@ -9,7 +9,7 @@ from django.conf import settings
from blog.models import Entry, Topic
from locations.models import Region, Country
from photos.models import Photo, PhotoGallery
-from chunks.models import Chunk
+#from chunks.models import Chunk
def home(request):
featured = Entry.objects.filter(status__exact=1).select_related().latest()
@@ -71,10 +71,12 @@ def entry_list_by_area(request,slug,page):
return object_list(request, queryset=qs, template_name='archives/writing.html',
extra_context=context)
+"""
def about(request):
qs = Chunk.objects.filter(key__in=['about_top','about_middle','about_bottom'])
context = {
'object_list':qs,
'IMAGES_URL' : settings.IMAGES_URL
}
- return render_to_response('details/about.html', context, context_instance=RequestContext(request)) \ No newline at end of file
+ return render_to_response('details/about.html', context, context_instance=RequestContext(request))
+"""
diff --git a/app/build/base.py b/app/build/base.py
index f6df69d..49f1989 100644
--- a/app/build/base.py
+++ b/app/build/base.py
@@ -10,27 +10,54 @@ from django.conf import settings
class Build():
- def write_file(self, path, object):
- file = open(path, 'w')
+ def write_file(self, path, object, ext='html',filename='index'):
+ """
+ Given a path and object intended to be a webpage, write the page the
+ disc
+ """
+ path = '%s%s' %(settings.FLATFILES_ROOT, path)
+ if not os.path.isdir(path):
+ os.makedirs(path)
+ fpath = '%s%s.%s' %(path, filename, ext)
+ file = open(fpath, 'w')
file.write(object)
file.close()
+ if ext == 'js':
+ import jsmin
+ compressed = jsmin.jsmin(object)
+ fpath = '%s%s.min.%s' %(path, filename, ext)
+ file = open(fpath, 'w')
+ file.write(compressed)
+ file.close()
-class BuildSitemap(Build):
- def build(self):
+ def build_archive_pages(self, qs=None, base_path='', paginate_by=10):
+ """
+ Archive Page builder that actually crawls the urls
+ because we need to be able to pass a request object to the template
+
+ """
+ if qs == None:
+ qs = self.get_model_querset()
c = Client()
- response = c.get('/sitemap.xml')
- fpath = '%ssitemap.xml' %(settings.BAKED_ROOT)
- self.write_file(fpath,str(response.content))
-
+ pages = ceil(Decimal(qs.count())/Decimal(paginate_by))
+ for page in range(int(pages)):
+ path = '%s%s/' %(base_path, page+1)
+ url = '/%s%s/' %(base_path, str(page+1))
+ page_url = base_path+'%d/'
+ response = c.post(url, {'page_url': page_url, 'page': int(page)})
+ if page == 0:
+ self.write_file(base_path,str(response.content))
+ self.write_file(path,str(response.content))
+
class BuildWriting(Build):
-
-
def build(self):
self.build_detail_pages()
- self.build_archive_pages()
+ self.build_writing_archives()
self.build_location_archive_pages()
self.build_homepage()
-
+ self.writing_year_archives()
+ self.writing_month_archives()
+
def get_model_querset(self):
model = get_model('blog', 'entry')
qs = model.objects.filter(status__exact=1)
@@ -44,31 +71,16 @@ class BuildWriting(Build):
for entry in qs:
c = Context({'object':entry,'MEDIA_URL':settings.BAKED_MEDIA_URL, 'IMAGES_URL':settings.BAKED_IMAGES_URL})
t = render_to_string('details/entry.html',c).encode('utf-8')
- 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)
- self.write_file(fpath,t)
+ path = '%s/%s/' %(entry.pub_date.strftime("%Y/%b/%d").lower(), entry.slug)
+ self.write_file(path,t)
+ s = render_to_string('details/entry.txt',c).encode('utf-8')
+ self.write_file(path,s,'txt')
- def build_archive_pages(self, qs=None, extra='writing/', paginate_by=10):
- if qs == None:
- qs = self.get_model_querset()
- c = Client()
- pages = ceil(Decimal(qs.count())/Decimal(paginate_by))
- print pages
- for page in range(int(pages)):
- base_path = '%s%s' %(settings.BAKED_ROOT, extra)
- path = '%s%s/' %(base_path, page+1)
- if not os.path.isdir(path):
- os.makedirs(path)
- url = '/%s%s/' %(extra, str(page+1))
- page_url = extra+'%d/'
- response = c.post(url, {'page_url': page_url, 'page': int(page)})
- fpath = '%sindex.html' %(path)
- if page == 0:
- self.write_file(base_path+'/index.html',str(response.content))
- self.write_file(fpath,str(response.content))
-
+
+ def build_writing_archives(self):
+ qs = self.get_model_querset()
+ self.build_archive_pages(qs, 'writing/')
+
def build_location_archive_pages(self):
model = get_model('locations', 'Country')
blog = get_model('blog', 'entry')
@@ -77,28 +89,39 @@ class BuildWriting(Build):
qs = blog.objects.filter(status__exact=1,location__state__country = c).order_by('-pub_date')
path = 'writing/%s/' %(c.slug)
self.build_archive_pages(qs, path)
-
- def build_recent_entries(self):
- 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).encode('utf-8')
- fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/recent_entries.html')
- self.write_file(fpath,t)
-
-
-
+
+ def writing_year_archives(self):
+ entry = get_model('blog', 'entry')
+ years = entry.objects.dates('pub_date', 'year')
+ for year in years:
+ year = year.strftime('%Y')
+ qs = entry.objects.filter(status__exact=1,pub_date__year=year).order_by('-pub_date')
+ c = Context({'type':'year','date': year, 'object_list':qs,})
+ t = render_to_string('archives/writing_date.html',c).encode('utf-8')
+ fpath = '%s/' %(year)
+ self.write_file(fpath,t)
+
+ def writing_month_archives(self):
+ entry = get_model('blog', 'entry')
+ months = entry.objects.dates('pub_date', 'month')
+ for m in months:
+ year = m.strftime('%Y')
+ month = m.strftime('%m')
+ month_name = m.strftime('%b')
+ month_full_name = m.strftime('%B')
+ qs = entry.objects.filter(status__exact=1,pub_date__year=year,pub_date__month=month).order_by('-pub_date')
+ c = Context({'type':'monthly','date': '%s %s' %(month_full_name,year), 'object_list':qs,})
+ t = render_to_string('archives/writing_date.html',c).encode('utf-8')
+ fpath = '%s/%s/' %(year,month_name)
+ self.write_file(fpath,t)
+
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.BAKED_MEDIA_URL, 'IMAGES_URL':settings.BAKED_IMAGES_URL})
t = render_to_string('archives/homepage.html',c).encode('utf-8')
- fpath = '%s%s' %(settings.BAKED_ROOT,'index.html')
- self.write_file(fpath,t)
-
-
-class BuildPhotos(BuildWriting):
+ self.write_file('',t)
+class BuildPhotos(Build):
def build(self):
self.build_photo_archive_pages()
self.build_detail_pages()
@@ -110,76 +133,13 @@ class BuildPhotos(BuildWriting):
def build_detail_pages(self):
qs = get_model('photos', 'PhotoGallery').objects.all()
- path = 'photos/galleries/'
- '''
- 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.BAKED_MEDIA_URL, 'IMAGES_URL':settings.BAKED_IMAGES_URL})
t = render_to_string('details/photo_galleries.html',c).encode('utf-8')
- path = '%sphotos/galleries/%s/' %(settings.BAKED_ROOT, photo.set_slug)
- if not os.path.isdir(path):
- os.makedirs(path)
- fpath = '%sindex.html' %(path)
- self.write_file(fpath,t)
-
-
+ path = 'photos/galleries/%s/' %(photo.set_slug)
+ self.write_file(path,t)
-class BuildAbout(Build):
- def build(self):
- model = get_model('chunks', 'Chunk')
- qs = model.objects.filter(key__in=['about_top','about_middle','about_bottom'])
- c = Context({
- 'object_list': qs,
- 'IMAGES_URL' : settings.BAKED_IMAGES_URL,
- 'MEDIA_URL':settings.BAKED_MEDIA_URL
- })
- t = render_to_string('details/about.html',c).encode('utf-8')
- path = '%sabout/' %(settings.BAKED_ROOT)
- if not os.path.isdir(path):
- os.makedirs(path)
- fpath = '%sindex.html' %(path)
- self.write_file(fpath,t)
-
-class BuildMap(Build):
-
- def build_map_templates(self):
- import codecs
- qs = get_model('blog', 'entry').objects.filter(status__exact=1)
- 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.BAKED_MEDIA_URL, 'IMAGES_URL':settings.BAKED_IMAGES_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.BAKED_MEDIA_URL, 'IMAGES_URL':settings.BAKED_IMAGES_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.BAKED_MEDIA_URL,'IMAGES_URL':settings.BAKED_IMAGES_URL})
- t = render_to_string('archives/map.html', c).encode('utf-8')
- path = '%smap/' %(settings.BAKED_ROOT)
- if not os.path.isdir(path):
- os.makedirs(path)
- fpath = '%sindex.html' %(path)
- self.write_file(fpath,t)
-
-class BuildContact(Build):
- def build(self):
- c = Client()
- response = c.get('/contact/')
- path = '%scontact/' %(settings.BAKED_ROOT)
- if not os.path.isdir(path):
- os.makedirs(path)
- fpath = '%sindex.html' %(path)
- self.write_file(fpath,str(response.content))
-
class BuildProjects(Build):
-
def build(self):
self.build_project_archive()
self.build_project_details()
@@ -197,11 +157,7 @@ class BuildProjects(Build):
qs = get_model('projects', 'Project').objects.filter(status__exact=1).order_by('-pub_date')
c = Context({'object_list': qs,'MEDIA_URL':settings.BAKED_MEDIA_URL,'IMAGES_URL':settings.BAKED_IMAGES_URL})
t = render_to_string('archives/projects.html', c).encode('utf-8')
- path = '%sprojects/' %(settings.BAKED_ROOT)
- if not os.path.isdir(path):
- os.makedirs(path)
- fpath = '%sindex.html' %(path)
- self.write_file(fpath,t)
+ self.write_file('projects/',t)
def build_project_details(self):
projects = self.get_projects()
@@ -213,11 +169,9 @@ class BuildProjects(Build):
qs = model.objects.filter(status__exact=1)
c = Context({'object_list': qs,'MEDIA_URL':settings.BAKED_MEDIA_URL,'IMAGES_URL':settings.BAKED_IMAGES_URL})
t = render_to_string('details/%s.html' %(proj['slug']), c).encode('utf-8')
- path = '%sprojects/%s/' %(settings.BAKED_ROOT, proj['slug'])
- if not os.path.isdir(path):
- os.makedirs(path)
- fpath = '%sindex.html' %(path)
- self.write_file(fpath,t)
+ path = 'projects/%s/' %(proj['slug'])
+ self.write_file(path,t)
+
def build_project_data(self):
from projects.shortcuts import render_to_geojson
model = get_model('projects', 'NationalParks')
@@ -233,9 +187,74 @@ class BuildProjects(Build):
json = str(json)
json ="\n".join(json.splitlines()[3:])
#print json
- path = '%sprojects/data/' %(settings.BAKED_ROOT)
- if not os.path.isdir(path):
- os.makedirs(path)
+ path = 'projects/data/'
fpath = '%s%s.json' %(path, park.id)
self.write_file(fpath,json)
+class BuildSitemap(Build):
+ def build(self):
+ c = Client()
+ response = c.get('/sitemap.xml')
+ self.write_file('',str(response.content), 'xml','sitemap')
+
+class BuildWritingFeed(Build):
+ def build(self):
+ qs = Entry.objects.filter(status__exact=1).order_by('-pub_date')[:20]
+ c = Context({'object_list':qs,'SITE_URL':settings.SITE_URL})
+ t = render_to_string('feed.xml',c).encode('utf-8')
+ fpath = '%s' %('feed/',)
+ self.write_file(fpath,t,'xml')
+
+class BuildMap(Build):
+ def build(self):
+ qs = get_model('blog', 'entry').objects.filter(status__exact=1)
+ 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.BAKED_MEDIA_URL, 'IMAGES_URL':settings.BAKED_IMAGES_URL})
+ t = render_to_string('archives/map_data.html',c).encode('utf-8')
+ self.write_file('media/js/',t, 'js','mainmap')
+ c = Context({'country_list':cl,'region_list':rl,'route_list':rtl,'MEDIA_URL':settings.BAKED_MEDIA_URL, 'IMAGES_URL':settings.BAKED_IMAGES_URL})
+ t = render_to_string('archives/map.html',c).encode('utf-8')
+ self.write_file('map/',t)
+
+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,'IMAGES_URL':settings.BAKED_IMAGES_URL})
+ t = render_to_string('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 BuildContact(Build):
+ def build(self):
+ c = Client()
+ response = c.get('/contact/')
+ path = '%scontact/' %(settings.BAKED_ROOT)
+ if not os.path.isdir(path):
+ os.makedirs(path)
+ fpath = '%sindex.html' %(path)
+ self.write_file(fpath,str(response.content))
+
+class BuildAbout(Build):
+ def build(self):
+ model = get_model('chunks', 'Chunk')
+ qs = model.objects.filter(key__in=['about_top','about_middle','about_bottom'])
+ c = Context({
+ 'object_list': qs,
+ 'IMAGES_URL' : settings.BAKED_IMAGES_URL,
+ 'MEDIA_URL':settings.BAKED_MEDIA_URL
+ })
+ t = render_to_string('details/about.html',c).encode('utf-8')
+ path = '%sabout/' %(settings.BAKED_ROOT)
+ if not os.path.isdir(path):
+ os.makedirs(path)
+ fpath = '%sindex.html' %(path)
+ self.write_file(fpath,t)
+
diff --git a/app/lib/templatetags/templatetags/html5_datetime.py b/app/lib/templatetags/templatetags/html5_datetime.py
new file mode 100644
index 0000000..20b5f27
--- /dev/null
+++ b/app/lib/templatetags/templatetags/html5_datetime.py
@@ -0,0 +1,16 @@
+from django.utils import dateformat
+import datetime
+from django import template
+from django.utils.safestring import mark_safe
+register = template.Library()
+
+@register.filter
+def html5_datetime(value):
+ """
+ Adds to colons to django's "Z" format to match html5 guidelines
+ """
+ fmt = "Y-m-d\TH:i:sO"
+ value = value
+ str = dateformat.format(value, fmt)
+ s = str[:-2] + ':' + str[-2:]
+ return mark_safe(s)
diff --git a/app/pages/__init__.py b/app/pages/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/pages/__init__.py
diff --git a/app/pages/admin.py b/app/pages/admin.py
new file mode 100644
index 0000000..e1328e9
--- /dev/null
+++ b/app/pages/admin.py
@@ -0,0 +1,26 @@
+from django.contrib import admin
+from django import forms
+from pages.models import Page
+from django.conf import settings
+
+from django.forms import TextInput, Textarea
+from django.db import models
+class PageAdmin(admin.ModelAdmin):
+ formfield_overrides = {
+ models.TextField: {'widget': Textarea(attrs={'rows':25, 'cols':40})},
+ }
+ list_display = ('title', 'slug',)
+ search_fields = ['title', 'body_markdown']
+ prepopulated_fields = {"slug" : ('title',)}
+ fieldsets = (
+ ('Page', {
+ 'fields': ('title','body_markdown', 'slug'),
+ 'classes': ('show','extrapretty','wide')
+ }),
+ ('Metadata', {
+ 'classes': ('collapse closed',),
+ 'fields': ('meta_description',),
+ })
+ )
+
+admin.site.register(Page, PageAdmin)
diff --git a/app/pages/models.py b/app/pages/models.py
new file mode 100644
index 0000000..198e186
--- /dev/null
+++ b/app/pages/models.py
@@ -0,0 +1,41 @@
+import datetime
+from django.db import models
+from django.conf import settings
+from django.contrib.sitemaps import Sitemap
+
+from utils import markdown2 as markdown
+
+def markdown_processor(md):
+ return markdown.markdown(md, ['footnotes'],safe_mode = False)
+
+TEMPLATES = (
+ (0, 'single'),
+ (1, 'double'),
+ (2, 'single-dark'),
+ (3, 'double-dark'),
+ )
+
+class Page(models.Model):
+ title = models.CharField(max_length=200)
+ slug = models.SlugField()
+ body_html = models.TextField(blank=True)
+ body_markdown = models.TextField()
+ meta_description = models.CharField(max_length=256, null=True, blank=True)
+
+ def __unicode__(self):
+ return self.title
+
+ def get_absolute_url(self):
+ return "/%s/" % (self.slug)
+
+ def save(self):
+ #run markdown
+ self.body_html = markdown_processor(self.body_markdown)
+ super(Page, self).save()
+
+class PageSitemap(Sitemap):
+ changefreq = "never"
+ priority = 1.0
+
+ def items(self):
+ return Page.objects.all()
diff --git a/app/pages/views.py b/app/pages/views.py
new file mode 100644
index 0000000..016c2ed
--- /dev/null
+++ b/app/pages/views.py
@@ -0,0 +1,13 @@
+from django.shortcuts import render_to_response,get_object_or_404
+from django.template import RequestContext
+from django.conf import settings
+
+
+from pages.models import Page
+
+def page(request,slug):
+ obj = get_object_or_404(Page, slug__exact=slug)
+ context = { 'object': obj,}
+ return render_to_response('details/page.html', context, context_instance = RequestContext(request))
+
+
diff --git a/app/photos/models.py b/app/photos/models.py
index dcb3d8a..7b75397 100644
--- a/app/photos/models.py
+++ b/app/photos/models.py
@@ -39,7 +39,7 @@ class Photo(models.Model):
slideshowimage_height = models.CharField(max_length=4, blank=True, null=True)
slideshowimage_margintop = models.CharField(max_length=4, blank=True, null=True)
slideshowimage_marginleft = models.CharField(max_length=4, blank=True, null=True)
-
+ is_public = models.BooleanField(default=True)
class Meta:
diff --git a/app/projects/admin.py b/app/projects/admin.py
index 94c4780..13357b0 100644
--- a/app/projects/admin.py
+++ b/app/projects/admin.py
@@ -7,6 +7,7 @@ from django.conf import settings
from projects.models.base import Project
from projects.models.fiveby import FiveBy
from projects.models.natparks import NationalParks
+from projects.models.gifs import AnimatedGif
GMAP = GoogleMap(key=settings.GOOGLE_MAPS_API_KEY)
@@ -174,9 +175,17 @@ class CodeAdmin(admin.ModelAdmin):
fieldsets = (
(None, {'fields': ('name','date_created','slug','status','body_html')}),
)
-
-admin.site.register(Code, CodeAdmin)
+class AnimatedGifAdmin(admin.ModelAdmin):
+ list_display = ('title', 'date_created')
+ search_fields = ['title',]
+ fieldsets = (
+ (None, {'fields': ('title','gif','date_created','slug','music_ogg','music_mp3')}),
+ )
+
+
+admin.site.register(AnimatedGif, AnimatedGifAdmin)
+admin.site.register(Code, CodeAdmin)
admin.site.register(Project, ProjectAdmin)
admin.site.register(FiveBy, FiveByAdmin)
-admin.site.register(NationalParks, NationalParksAdmin) \ No newline at end of file
+admin.site.register(NationalParks, NationalParksAdmin)
diff --git a/app/projects/models/__init__.py b/app/projects/models/__init__.py
index 7fe6077..6f61282 100644
--- a/app/projects/models/__init__.py
+++ b/app/projects/models/__init__.py
@@ -1,4 +1,5 @@
from base import Project
from fiveby import FiveBy
from natparks import NationalParks
-from code import Code \ No newline at end of file
+from code import Code
+from gifs import AnimatedGif
diff --git a/app/projects/urls.py b/app/projects/urls.py
index 14722a8..83f07c7 100644
--- a/app/projects/urls.py
+++ b/app/projects/urls.py
@@ -11,6 +11,7 @@ projects = {
urlpatterns = patterns('',
(r'data/(?P<id>\d+)/$', 'projects.views.data_json'),
+ (r'gifs/(?P<slug>[-\w]+)/$', 'projects.views.gif_detail'),
(r'(?P<slug>[-\w]+)/$', 'projects.views.detail'),
(r'^$',list_detail.object_list, dict(projects, template_name='archives/projects.html')),
)
diff --git a/app/projects/views.py b/app/projects/views.py
index 64857a7..e25802b 100644
--- a/app/projects/views.py
+++ b/app/projects/views.py
@@ -9,6 +9,7 @@ from projects.shortcuts import render_to_geojson
from projects.models.base import Project
from projects.models.fiveby import FiveBy
from projects.models.natparks import NationalParks
+from projects.models.gifs import AnimatedGif
projects = {'5x5':'FiveBy','6x6':'SixBy','national-parks':'NationalParks','code':'Code'}
@@ -25,6 +26,10 @@ def detail(request,slug):
template = 'details/%s.html' %(slug)
return object_list(request, queryset=qs, template_name=template,)
+def gif_detail(request,slug):
+ obj = get_object_or_404(AnimatedGif, slug__exact=slug)
+ return render_to_response('details/gifs.html', {'object': obj}, context_instance=RequestContext(request))
+
def data_json(request, id):
qs = NationalParks.objects.filter(pk=id)
@@ -35,4 +40,4 @@ def data_json(request, id):
mimetype = 'application/json',
pretty_print=True
)
- \ No newline at end of file
+
diff --git a/config/base_urls.py b/config/base_urls.py
index 6e9e15f..91ab63d 100644
--- a/config/base_urls.py
+++ b/config/base_urls.py
@@ -42,13 +42,14 @@ urlpatterns += patterns('',
urlpatterns += patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
- (r'^admin/filebrowser/', include('filebrowser.urls')),
+ #(r'^admin/filebrowser/', include('filebrowser.urls')),
+ (r'^admin/build/.*', 'static_generator.views.do_build'),
(r'^admin/', include(admin.site.urls),),
(r'^grappelli/', include('grappelli.urls')),
- (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
+ #(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
(r'^robots.txt$', direct_to_template, {'template': 'archives/robots.html'}),
(r'^googleb11655cd59dacf3c.html$', direct_to_template, {'template': 'static/gverify.html'}),
- (r'^contact/', direct_to_template, {'template': 'details/contact.html'}),
+ #(r'^contact/', direct_to_template, {'template': 'details/contact.html'}),
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
(r'^writing/', include('blog.urls')),
(r'^projects/', include('projects.urls')),
@@ -62,7 +63,10 @@ urlpatterns += patterns('',
# map
(r'^map/', include('locations.urls')),
#about
- (r'^about/$', 'blog.views.about'), #'blog.views.home'),
+ #(r'^about/$', 'blog.views.about'), #'blog.views.home'),
#homepage
(r'^$', 'blog.views.home'), #'blog.views.home'),
+ #pages
+ (r'^(?P<slug>[-\w]+)/$', 'pages.views.page'),
+
)
diff --git a/config/requirements.txt b/config/requirements.txt
index 6ef8852..cd13a58 100644
--- a/config/requirements.txt
+++ b/config/requirements.txt
@@ -3,6 +3,8 @@ PIL==1.1.7
django-extensions==0.9
django-filebrowser==3.5.0
django-grappelli==2.4.2
+django-pipeline==1.2.17
psycopg2==2.4.5
wsgiref==0.1.2
yolk==0.4.3
+yuicompressor==2.4.7
diff --git a/config/settings/settings.py b/config/settings/settings.py
index e83c772..8b71e3c 100644
--- a/config/settings/settings.py
+++ b/config/settings/settings.py
@@ -1,4 +1,4 @@
-# Django settings for The Installment Plan
+# Django settings for luxagraf.
import os
from os.path import dirname, abspath
@@ -6,13 +6,11 @@ PROJ_ROOT = abspath(dirname(dirname(dirname(__file__))))+'/'
DEBUG = True
TEMPLATE_DEBUG = DEBUG
-DEVELOPMENT = False
+
ADMINS = (
- ('sng', 'luxagraf@gmail.com'),
-)
-CONTACT = (
- ('sng', 'sng@luxagraf.net'),
+ # ('Your Name', 'your_email@example.com'),
)
+
MANAGERS = ADMINS
DATABASES = {
@@ -24,111 +22,112 @@ DATABASES = {
}
}
-#Email Setting for Webfaction
-EMAIL_HOST = 'mail2.webfaction.com'
-EMAIL_HOST_USER = 'luxagraf'
-EMAIL_HOST_PASSWORD = 'translinguis#'
-DEFAULT_FROM_EMAIL = 'sng@luxagraf.net'
-SEND_BROKEN_LINK_EMAILS = True
-SERVER_EMAIL = 'sng@luxagraf.net'
-EMAIL_PORT = 25
-
-SITE_NAME = 'luxagraf'
+TIME_ZONE = 'America/New_York'
+LANGUAGE_CODE = 'en-us'
+SITE_ID = 1
SITE_URL = 'http://luxagraf.net/'
GRAPPELLI_ADMIN_TITLE = 'Luxagraf Admin'
-
-TIME_ZONE = 'America/New_York'
-
+USE_I18N = False
+USE_L10N = True
+USE_TZ = True
#API key for Google Maps in Admin
MAP_API = "google"
GOOGLE_MAPS_API_KEY = MAP_API_KEY = 'ABQIAAAAEZ0Oz7LFDmdS1OBHm6HLgRQT5Lr-mnFT_29u-YVgAYs_K_u6-BQ627CkPKq44oaHpmSt2497hDj_LQ'
-
# API key for Flickr imports
FLICKR_API_KEY = '7b9d978a440c6ab65a545adc0aa0d693'
FLICKR_USER_ID = '85322932@N00'
-DELICIOUS_USER = 'luxagraf'
-DELICIOUS_PASS = 'translinguis#'
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-us'
-
-SITE_ID = 1
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = False
+#path to the folder that holds the generated html files
+FLATFILES_ROOT = os.path.join(PROJ_ROOT, 'site/')
+#media and image URLs for the generated html files
+BAKED_IMAGES_URL = 'http://images.luxagraf.net/'
+BAKED_MEDIA_URL = 'http://luxagraf.net/media/'
+#BAKED_MEDIA_URL = 'http://127.0.0.1:8000/media/'
+#path to http://images.luxagraf.net root
+IMAGES_ROOT = os.path.join(PROJ_ROOT, 'site/media/images')
+IMAGES_URL = 'http://images.luxagraf.net/'
-# Absolute path to the directory that holds media.
-# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = PROJ_ROOT+'media/'
-IMAGES_ROOT = PROJ_ROOT+'media/images/'
-STATIC_ROOT = PROJ_ROOT+'static/'
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+MEDIA_ROOT = os.path.join(PROJ_ROOT, 'site/media')
-# URL that handles the media served from MEDIA_ROOT.
-# Example: "http://media.lawrence.com"
-MEDIA_URL = 'http://media.luxagraf.net/'
-IMAGES_URL = 'http://images.luxagraf.net/'
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/media/admin/'
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = 'http://luxagraf.net/media/'
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+STATIC_ROOT = os.path.join(PROJ_ROOT, 'static/')
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = '/static/'
+
+# Additional locations of static files
+STATICFILES_DIRS = (
+ # Put strings here, like "/home/html/static" or "C:/www/django/static".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = '-kzv5^z9@j%cvk6u#lcf&nuga4oiy_-6q^-+#iybt44t_ii-1o'
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
-#CACHE_BACKEND = 'memcached://174.133.21.78:32348/'
-#CACHE_MIDDLEWARE_SECONDS = 3600
-#CACHE_MIDDLEWARE_KEY_PREFIX = 'luxagraf_net'
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '^gaz8-&amp;iy8z@(nwp#xe1age(t141w-47fh=cv8a7w2=x2=a-&amp;7'
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+# 'django.template.loaders.eggs.Loader',
+)
MIDDLEWARE_CLASSES = (
- 'django.middleware.gzip.GZipMiddleware',
- #'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
- # 'django.middleware.cache.FetchFromCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.middleware.doc.XViewMiddleware',
- 'pagination.middleware.PaginationMiddleware',
- #'ssl.middleware.SSLRedirect',
- #'debug_toolbar.middleware.DebugToolbarMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ # Uncomment the next line for simple clickjacking protection:
+ # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
+
TEMPLATE_CONTEXT_PROCESSORS = (
- 'django.core.context_processors.request',
- 'django.contrib.auth.context_processors.auth',
- 'django.core.context_processors.debug',
- 'django.core.context_processors.media',
- "grappelli.context_processors.admin_template_path",
-)
-ROOT_URLCONF = 'settings.base_urls'
-INTERNAL_IPS = (
- '67.15.64.48',
- '63.251.179.56',
- '127.0.0.1'
+ "django.core.context_processors.request",
+ "django.contrib.auth.context_processors.auth",
+ "django.core.context_processors.debug",
+ "django.core.context_processors.i18n",
+ "django.core.context_processors.media",
+ "django.core.context_processors.static",
+ "django.core.context_processors.tz",
+ "django.contrib.messages.context_processors.messages"
)
+ROOT_URLCONF = 'config.base_urls'
+
TEMPLATE_DIRS = (
- PROJ_ROOT+'templates',
- PROJ_ROOT+'lib/templates',
- PROJ_ROOT+'lib/grappelli/templates',
- #PROJ_ROOT+'lib/debug_toolbar/templates',
+ os.path.join(PROJ_ROOT, 'design/templates')
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
-TEMPLATE_LOADERS = (
- ('django.template.loaders.cached.Loader', (
- 'django.template.loaders.filesystem.Loader',
- 'django.template.loaders.app_directories.Loader',
- )),
-)
+
+
INSTALLED_APPS = (
'grappelli',
'django.contrib.auth',
+ 'django.contrib.staticfiles',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
@@ -139,18 +138,18 @@ INSTALLED_APPS = (
'locations',
'blog',
'photos',
- #'tagging',
'taggit',
- #'chunks',
'links',
'pagination',
'templatetags',
- #'contact_form',
'projects',
- 'guide'
+ 'guide',
+ 'static_generator',
+ 'pages'
)
-try:
- from settings_local import *
-except:
- pass
+DEVELOPMENT = True
+if DEVELOPMENT:
+ INSTALLED_APPS += ('django_extensions',)
+ MEDIA_URL = 'http://127.0.0.1:8000/media/'
+
diff --git a/design/templates/archives/homepage.html b/design/templates/archives/homepage.html
index 11cbf4b..56b7f57 100644
--- a/design/templates/archives/homepage.html
+++ b/design/templates/archives/homepage.html
@@ -24,7 +24,7 @@
</section>{%endcomment%}
<section class="home harchive">
<h1 class="sh">From the Archive</h1>
- {% include 'includes/recent_entries.html' %}
+ {%comment%} {% include 'includes/recent_entries.html' %}{%endcomment%}
</section>
{% endblock %}
diff --git a/design/templates/archives/map.html b/design/templates/archives/map.html
index effe150..3c644eb 100644
--- a/design/templates/archives/map.html
+++ b/design/templates/archives/map.html
@@ -2,7 +2,6 @@
{% load typogrify %}
{% load truncateletters %}
{% load slugify_under %}
-
{% block pagetitle %}Luxagraf | Map and Trips{% endblock %}
{% block metadescription %}Browse luxagraf by map, see trip routes and discover essays and dispatches from around the world{% endblock %}
@@ -12,17 +11,13 @@ Google Maps code
{% block extrahead %}
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
-<script type="text/javascript" src="{{MEDIA_URL}}js/mainmap.js"></script>
+<script type="text/javascript" src="{{MEDIA_URL}}js/mainmap.min.js"></script>
{% endblock %}
{%block bodyid%}id="map" {%endblock%}
{% block bodyevents %}onload="initialize()"{% endblock %}
-
-
-
-
{% block primary %}<ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<li><a href="/" itemprop="url" title="luxagraf homepage"><span itemprop="title">Home</span></a> &rarr;</li>
<li>Map</li>
@@ -30,6 +25,26 @@ Google Maps code
<section>
<h1 class="hide">Browse luxagraf by map</h1>
<div id="map-canvas"></div>
- {% include 'includes/map_sidebar.html' %}
+ <div class="map-legend">
+ <h4>Trips</h4>
+ <ul>
+ {% for route in route_list %}
+ <li><a onclick="showRoute('{{route.template_var_name}}', {{route.zoom}}, '{{route.geometry.centroid.y}}','{{route.geometry.centroid.x}}');" href="#" title="show {{route.name}} on map">{{route.name}}</a></li>
+ {% endfor %}
+ </ul>
+ <h4>Regions</h4>
+ <ul>
+ {%for region in region_list %}
+ <li><a href="#{{region.slug}}" onclick="focusCountry({{region.lat}}, {{region.lon}}, {{region.zoom_level}});" title="See all writing from {{region.name|title}}">{{region.name}}</a></li>
+ {% endfor %}
+ </ul>
+ <h4>Countries</h4>
+ <ul>
+ <li><a onclick="focusCountry(19.311143,2.460938,2);" href="#" title="view all countries">All</a></li>
+ {%for country in country_list %}
+ <li><a href="#{{country.slug}}" onclick="focusCountry({{country.lat}}, {{country.lon}}, {{country.zoom_level}});" title="See all writing from {{country.name|title}}">{{country.name}}</a></li>
+ {% endfor %}
+ </ul>
+ </div>
</section>
{% endblock %}
diff --git a/design/templates/bin/map_entry_list.html b/design/templates/bin/map_entry_list.html
deleted file mode 100644
index a58de05..0000000
--- a/design/templates/bin/map_entry_list.html
+++ /dev/null
@@ -1,111 +0,0 @@
-{% load typogrify %}
-{% load truncateletters %}
-{% load slugify_under %}
-
- // center on a country
- function focusCountry(latitude, longitude, zoom) {
- map.setZoom(zoom);
- map.panTo(new google.maps.LatLng(latitude, longitude));
- };
-
- {% for route in route_list %}
- var {{route.template_var_name}} = [
- {% for point in route.geometry.coords%}
- new google.maps.LatLng({{point.1}}, {{point.0}}){% if forloop.last%}{%else%},{%endif%}
- {% endfor %}
- ];
- {% endfor %}
- function showRoute(route, zoom, latitude, longitude) {
- var routePath = new google.maps.Polyline({
- path: eval(route),
- strokeColor: "#FF0000",
- strokeOpacity: 1.0,
- strokeWeight: 2
- });
- map.setZoom(zoom);
- map.panTo(new google.maps.LatLng(latitude, longitude));
- routePath.setMap(map);
- return false;
- };
-var map;
-function initialize() {
-
- //custom marker
- var image = new google.maps.MarkerImage('http://luxagraf.net/media/img/marker-entry.png',
- new google.maps.Size(15, 26),
- new google.maps.Point(0, 0),
- new google.maps.Point(7, 26)
- );
- //custom marker shadow
- var shadow = new google.maps.MarkerImage('http://luxagraf.net/media/img/shadow.png',
- new google.maps.Size(37, 34),
- new google.maps.Point(0,0),
- new google.maps.Point(8, 34)
- );
-
-
- //check for a permalink
- var location = window.location.hash;
- //find a centerpoint
- var pts = new Array();
- {%for c in country_list%}pts[{{forloop.counter0}}] = ["#{{c.slug}}", {{c.lat}},{{c.lon}},{{c.zoom_level}}];{% endfor %}
- {%for c in region_list%}pts[pts.length] = ["#{{c.slug}}", {{c.lat}},{{c.lon}},{{c.zoom_level}}];{% endfor %}
- if (location.length>1) {
- for (i=0;i<pts.length;i++) {
- if (location == pts[i][0]) {
- centerCoord = new google.maps.LatLng(pts[i][1],pts[i][2]);
- zoom = pts[i][3];
- break;
- } else {
- centerCoord = new google.maps.LatLng(19.311143,2.460938);
- zoom = 2;
- }
- }
- } else {
- centerCoord = new google.maps.LatLng(19.311143,2.460938);
- zoom = 2;
- }
- //set up map options
- var mapOptions = {
- zoom: zoom,
- center: centerCoord,
- mapTypeId: google.maps.MapTypeId.TERRAIN,
- disableDefaultUI: true,
- navigationControl: true,
- navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}
- };
- //create map
- map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
-
-
- //loop through and set up markers/info windows
-
- {% for entry in object_list %}
- var marker_{{entry.title|truncatewords:2|slugify_under}} = new google.maps.Marker({
- position: new google.maps.LatLng({{entry.latitude}}, {{entry.longitude}}),
- map: map,
- shadow: shadow,
- icon: image
- });
-
- var c_{{entry.title|truncatewords:2|slugify_under}} = '<div class="infowin"><h4>{{entry.title}}<\/h4><span class="date blok">{{entry.pub_date|date:"F j, Y"}} ({% if entry.location.state.country.name == "United States" %}{{entry.location.name|smartypants|safe}}, {{entry.location.state.name}}){%else%}{{entry.location.name|smartypants|safe}}, {{entry.location.state.country.name}}){%endif%}<\/span><p><img src="{{entry.get_thumbnail_url}}" height="100" alt="{{ entry.title }}" style="float: left; border: #000 10px solid; margin-right: 8px; margin-bottom: 4px; height: 100px;" \/>{{entry.dek|escapejs}} <a href="{{entry.get_absolute_url}}">Read it &raquo;<\/a><\/p><\/div>';
-
- google.maps.event.addListener(marker_{{entry.title|truncatewords:2|slugify_under}}, 'click', function() {
- openWin(c_{{entry.title|truncatewords:2|slugify_under}},marker_{{entry.title|truncatewords:2|slugify_under}});
- });
-
- {% endfor %}
- // create an empty info window instance, set max width
- var infowindow = new google.maps.InfoWindow({
- content: ' ',
- maxWidth: 400
- });
- //function to handle click event and display single info window
- function openWin(content, marker) {
- infowindow.close();
- infowindow.setContent(content);
- infowindow.open(map,marker);
- };
-
-
-}