diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/blog/models.py | 1 | ||||
-rw-r--r-- | app/builder/base.py | 16 | ||||
-rw-r--r-- | app/locations/models.py | 1 | ||||
-rw-r--r-- | app/pages/models.py | 1 | ||||
-rw-r--r-- | app/photos/models.py | 1 | ||||
-rw-r--r-- | app/projects/models/base.py | 9 | ||||
-rw-r--r-- | app/projects/models/natparks.py | 5 |
7 files changed, 25 insertions, 9 deletions
diff --git a/app/blog/models.py b/app/blog/models.py index e7f10ab..f01eeae 100644 --- a/app/blog/models.py +++ b/app/blog/models.py @@ -142,6 +142,7 @@ class EntryAside(models.Model): class BlogSitemap(Sitemap): changefreq = "never" priority = 1.0 + protocol = "https" def items(self): return Entry.objects.filter(status=1) diff --git a/app/builder/base.py b/app/builder/base.py index 09e0a95..4265b8d 100644 --- a/app/builder/base.py +++ b/app/builder/base.py @@ -22,12 +22,12 @@ class Build(): file.write(text_object) file.close() if ext == 'js': - import jsmin - compressed = jsmin.jsmin(str(text_object)) + from jsmin import jsmin fpath = '%s%s.min.%s' % (path, filename, ext) - file = open(fpath, 'wt') - file.write(str(compressed)) - file.close() + compressed = jsmin(text_object.decode(encoding='UTF-8')) + with open(fpath, 'wt') as js_file: + minified = js_file.write(compressed) + js_file.close() def build_archive_pages(self, qs=None, base_path='', paginate_by=10): """ @@ -43,7 +43,7 @@ class Build(): 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), 'builder': True}) + response = c.post(url, {'page_url': page_url, 'page': int(page), 'builder': True}, HTTP_HOST='127.0.0.1') if page == 0: self.write_file(base_path, response.content) self.write_file(path, response.content) @@ -236,7 +236,7 @@ class BuildProjects(Build): class BuildSitemap(Build): def build(self): c = Client() - response = c.get('/sitemap.xml') + response = c.get('/sitemap.xml', HTTP_HOST='127.0.0.1') self.write_file('', response.content, 'xml', 'sitemap') @@ -297,7 +297,7 @@ class BuildPages(Build): class BuildContact(Build): def build(self): c = Client() - response = c.get('/contact/') + response = c.get('/contact/', HTTP_HOST = '127.0.0.1') path = '%scontact/' % (settings.BAKED_ROOT) if not os.path.isdir(path): os.makedirs(path) diff --git a/app/locations/models.py b/app/locations/models.py index 0148327..5c27702 100644 --- a/app/locations/models.py +++ b/app/locations/models.py @@ -150,6 +150,7 @@ class Route(models.Model): class WritingbyCountrySitemap(Sitemap): changefreq = "weekly" priority = 0.6 + protocol = "https" def location(self, item): return '/writing/%s' % item.slug diff --git a/app/pages/models.py b/app/pages/models.py index 2462b06..0256508 100644 --- a/app/pages/models.py +++ b/app/pages/models.py @@ -29,6 +29,7 @@ class Page(models.Model): class PageSitemap(Sitemap): changefreq = "never" priority = 1.0 + protocol = "https" def items(self): return Page.objects.all() diff --git a/app/photos/models.py b/app/photos/models.py index 9916085..dce655e 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -201,6 +201,7 @@ class PhotoGallery(models.Model): class PhotoGallerySitemap(Sitemap): changefreq = "never" priority = 0.7 + protocol = "https" def items(self): return PhotoGallery.objects.all() diff --git a/app/projects/models/base.py b/app/projects/models/base.py index 51379a0..f0cd6d0 100644 --- a/app/projects/models/base.py +++ b/app/projects/models/base.py @@ -1,6 +1,7 @@ import datetime from django.contrib.gis.db import models from django.contrib.sitemaps import Sitemap +from django.conf import settings import markdown @@ -37,12 +38,17 @@ class Project(models.Model): '''Get the site's latitude.''' return self.point.y + @property + def get_project_image(self): + return "%s%s" % (settings.IMAGES_URL, self.image.name[7:]) + + class Meta: ordering = ('-pub_date',) get_latest_by = 'pub_date' app_label = 'projects' - def __unicode__(self): + def __str__(self): return self.title def get_absolute_url(self): @@ -58,6 +64,7 @@ class Project(models.Model): class ProjectSitemap(Sitemap): changefreq = "monthly" priority = 0.5 + protocol = "https" def items(self): return Project.objects.filter(status=1) diff --git a/app/projects/models/natparks.py b/app/projects/models/natparks.py index 3615737..2eee677 100644 --- a/app/projects/models/natparks.py +++ b/app/projects/models/natparks.py @@ -1,6 +1,7 @@ import datetime from PIL import Image from django.contrib.gis.db import models +from django.conf import settings from blog.models import Entry from photos.models import PhotoGallery from locations.models import State @@ -44,6 +45,10 @@ class NationalParks(models.Model): def __str__(self): return self.unit_name + @property + def get_image_url(self): + return "%s%s" % (settings.IMAGES_URL, self.image.name[7:]) + def save(self): #get image dimensions img = Image.open(self.image) |