summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/builder/base.py6
-rw-r--r--app/builder/views.py6
-rw-r--r--app/jrnl/build.py15
-rw-r--r--app/locations/urls.py9
-rw-r--r--app/locations/views.py37
5 files changed, 66 insertions, 7 deletions
diff --git a/app/builder/base.py b/app/builder/base.py
index 67a259e..d9c2288 100644
--- a/app/builder/base.py
+++ b/app/builder/base.py
@@ -20,8 +20,6 @@ class _FileWriter(object):
os.makedirs(self.path)
fpath = '%s%s.%s' % (self.path, filename, ext)
self.write(fpath, text_object)
- if ext == 'js':
- self.compress_js(filename, text_object)
def write(self, fpath, text_object):
f = open(fpath, 'wb')
@@ -30,7 +28,7 @@ class _FileWriter(object):
def compress_js(self, filename, text_object):
path = '%s%s.min.js' % (self.path, filename)
- compressed = jsmin(text_object.decode(encoding='UTF-8'))
+ compressed = jsmin(text_object.decode('utf-8')).encode('utf-8')
self.write(path, compressed)
@@ -49,7 +47,7 @@ class BuildNew():
def write_file(self, path, text_object, ext='html', filename='index'):
self.writer = _FileWriter(path, text_object, ext=ext, filename=filename)
-
+
def get_pages(self, qs, paginate_by):
return int(ceil(Decimal(qs.count()) / Decimal(paginate_by)))
diff --git a/app/builder/views.py b/app/builder/views.py
index 1875a91..55a037c 100644
--- a/app/builder/views.py
+++ b/app/builder/views.py
@@ -2,7 +2,7 @@ from django.shortcuts import render_to_response
from django.template import RequestContext
from builder.base import BuildWriting, BuildWritingFeed, BuildMap, BuildPhotos, BuildProjects, BuildSitemap
from src.build import builder as src_builder
-from jrnl.build import archive_builder, detail_builder, home_builder, rss_builder, amp_builder
+from jrnl.build import archive_builder, detail_builder, home_builder, rss_builder, amp_builder, map_builder
from resume.build import builder as resume_builder
from books.build import builder as book_builder
from birds.build import builder as bird_builder
@@ -15,7 +15,6 @@ options = {
'writing': BuildWriting,
'photo_galleries': BuildPhotos,
'projects': BuildProjects,
- 'map': BuildMap,
'feed': BuildWritingFeed,
'sitemap': BuildSitemap,
}
@@ -60,6 +59,9 @@ def do_build(request):
elif section == 'pages':
context = {'message': 'Writing Pages to Disk'}
page_builder()
+ elif section == 'map':
+ context = {'message': 'Writing Map to Disk'}
+ map_builder()
else:
options[section]().build()
context = {'message': 'Writing %s to Disk' % section}
diff --git a/app/jrnl/build.py b/app/jrnl/build.py
index 1bc5d3e..0354470 100644
--- a/app/jrnl/build.py
+++ b/app/jrnl/build.py
@@ -3,6 +3,7 @@ from django.apps import apps
from builder.base import BuildNew
from itertools import chain
+from django.conf import settings
class BuildJrnl(BuildNew):
@@ -56,6 +57,16 @@ class BuildJrnl(BuildNew):
response = self.client.get('/')
self.write_file('', response.content)
+ def build_map(self):
+ self.build_list_view(
+ base_path=reverse("locations:maplist"),
+ paginate_by=1000000
+ )
+ url = "/media/js/mainmap.js"
+ response = self.client.get("/media/js/mainmap.js", HTTP_HOST='127.0.0.1')
+ self.write_file("media/js/mainmap", response.content, 'js', '')
+
+
def archive_builder():
j = BuildJrnl("jrnl", "entry")
@@ -81,3 +92,7 @@ def amp_builder():
j = BuildJrnl("jrnl", "entry")
j.build_amp_view()
+
+def map_builder():
+ j = BuildJrnl("jrnl", "entry")
+ j.build_map()
diff --git a/app/locations/urls.py b/app/locations/urls.py
index 77f9f0c..72a88de 100644
--- a/app/locations/urls.py
+++ b/app/locations/urls.py
@@ -2,7 +2,14 @@ from django.conf.urls import url
from . import views
+app_name = "locations"
+
urlpatterns = [
url(r'data/(?P<id>\d+)/$', views.data_json),
- url(r'^$', views.map_list),
+ url(
+ r'^$',
+ views.MapList.as_view(),
+ name="maplist"
+ ),
+ #url(r'^$', views.map_list),
]
diff --git a/app/locations/views.py b/app/locations/views.py
index 12901eb..c463eac 100644
--- a/app/locations/views.py
+++ b/app/locations/views.py
@@ -4,6 +4,9 @@ from jrnl.models import Entry
from locations.models import Country, Region, Route
from projects.shortcuts import render_to_geojson
+from django.views.generic import ListView
+from django.conf import settings
+
def map_list(request):
context = {
@@ -18,6 +21,40 @@ def map_list(request):
context_instance=RequestContext(request)
)
+class MapList(ListView):
+ """
+ Return list of Entries on map
+ """
+ context_object_name = 'object_list'
+ queryset = Entry.objects.filter(status__exact=1)
+ template_name = 'archives/map.html'
+
+ def get_context_data(self, **kwargs):
+ # Call the base implementation first to get a context
+ context = super(MapList, self).get_context_data(**kwargs)
+ context['country_list'] = Country.objects.filter(visited=True).exclude(name='default'),
+ context['route_list'] = Route.objects.all(),
+ context['region_list'] = Region.objects.all()
+ context['IMAGES_URL'] = settings.IMAGES_URL
+ return context
+
+
+class MapDataList(ListView):
+ """
+ Build data file for Entries on map
+ """
+ context_object_name = 'object_list'
+ queryset = Entry.objects.filter(status__exact=1)
+ template_name = 'archives/map_data.html'
+
+ def get_context_data(self, **kwargs):
+ # Call the base implementation first to get a context
+ context = super(MapDataList, self).get_context_data(**kwargs)
+ context['country_list'] = Country.objects.filter(visited=True).exclude(name='default'),
+ context['route_list'] = Route.objects.all(),
+ context['region_list'] = Region.objects.all()
+ context['IMAGES_URL'] = settings.IMAGES_URL
+ return context
def map_data(request):
context = {