summaryrefslogtreecommitdiff
path: root/app/builder/base.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2014-05-27 14:18:50 -0400
committerluxagraf <sng@luxagraf.net>2014-05-27 14:18:50 -0400
commit18de08b5dfcc40243bfe8531bce775d0cf106293 (patch)
tree214567b93b0a1f499cc0edab76ac920062a590a1 /app/builder/base.py
parent4b46285558ccbe10e9a2a5887c630fce6e355d52 (diff)
moved all the js files to their respective projects and added the
leftlet providers code inline at the top as part of the build process. Also converted everything to stop using google maps.
Diffstat (limited to 'app/builder/base.py')
-rw-r--r--app/builder/base.py42
1 files changed, 28 insertions, 14 deletions
diff --git a/app/builder/base.py b/app/builder/base.py
index 9cd5af7..cd51265 100644
--- a/app/builder/base.py
+++ b/app/builder/base.py
@@ -18,15 +18,15 @@ class Build():
if not os.path.isdir(path):
os.makedirs(path)
fpath = '%s%s.%s' % (path, filename, ext)
- file = open(fpath, 'wb')
- file.write(text_object)
+ file = open(fpath, 'wt')
+ file.write(str(text_object))
file.close()
if ext == 'js':
import jsmin
compressed = jsmin.jsmin(str(text_object))
fpath = '%s%s.min.%s' % (path, filename, ext)
- file = open(fpath, 'wb')
- file.write(bytes(compressed, 'UTF-8'))
+ file = open(fpath, 'wt')
+ file.write(str(compressed))
file.close()
def build_archive_pages(self, qs=None, base_path='', paginate_by=10):
@@ -137,6 +137,7 @@ class BuildPhotos(Build):
def build(self):
self.build_photo_archive_pages()
self.build_detail_pages()
+ self.build_js()
def build_photo_archive_pages(self):
qs = get_model('photos', 'PhotoGallery').objects.all()
@@ -150,7 +151,14 @@ class BuildPhotos(Build):
t = render_to_string('details/photo_galleries.html', c).encode('utf-8')
path = 'photos/galleries/%s/' % (photo.set_slug)
self.write_file(path, t)
-
+
+ def build_js(self):
+ fpath = '%sdesign/templates/js/leaflet-providers.js' % settings.PROJ_ROOT
+ leaflet_providers_js = open(fpath, 'r').read()
+ fpath = '%sapp/photos/photos.js' % settings.PROJ_ROOT
+ photos_js = open(fpath, 'r').read()
+ js = leaflet_providers_js + photos_js
+ self.write_file('media/js/', str(js), 'js', 'photos')
class BuildProjects(Build):
def build(self):
@@ -213,17 +221,20 @@ class BuildProjects(Build):
model = get_model('projects', 'NationalParks')
for park in model.objects.filter(visited__exact=True):
qs = model.objects.filter(pk=park.id)
- json = render_to_geojson(
- qs,
- included_fields=['id'],
- geom_attribute='mpoly',
- mimetype='application/json',
- )
+ json = render_to_geojson(qs)
json = str(json)
+ print(json)
json = "\n".join(json.splitlines()[3:])
- #print json
path = 'projects/data/natparks/'
- self.write_file(path, bytes(json, 'UTF-8'), 'json', park.id)
+ self.write_file(path, json, 'json', park.id)
+
+ def build_np_basejs(self):
+ fpath = '%sdesign/templates/js/leaflet-providers.js' % settings.PROJ_ROOT
+ leaflet_providers_js = open(fpath, 'r').read()
+ fpath = '%sapp/projects/natparks.js' % settings.PROJ_ROOT
+ natparks_js = open(fpath, 'r').read()
+ js = leaflet_providers_js + natparks_js
+ self.write_file('media/js/', str(js), 'js', 'natparks')
class BuildSitemap(Build):
@@ -257,7 +268,10 @@ class BuildMap(Build):
'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')
+ fpath = '%sdesign/templates/js/leaflet-providers.js' % settings.PROJ_ROOT
+ leaflet_providers_js = open(fpath, 'r').read()
+ js = leaflet_providers_js + t.decode(encoding='UTF-8')
+ self.write_file('media/js/', str(js), 'js', 'mainmap')
c = Context({
'country_list': cl,
'region_list': rl,