From b460162a8c744486857dae48c6afc1632c7115ba Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 14 Nov 2016 17:53:43 -0500 Subject: pushed up new image insert script --- app/jrnl/models.py | 4 +++- app/photos/models.py | 5 +++++ app/utils/widgets.py | 6 ++++++ design/sass/_writing_details.scss | 4 +--- design/templates/admin/insert_images.html | 25 ++++++++++++++++++++----- design/templates/base.html | 2 +- design/templates/details/entry.html | 23 ++++++++++++++++++++--- 7 files changed, 56 insertions(+), 13 deletions(-) diff --git a/app/jrnl/models.py b/app/jrnl/models.py index 20d753f..254662d 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -20,7 +20,7 @@ from bs4 import BeautifulSoup from photos.models import PhotoGallery, LuxImage from locations.models import Location -from utils.widgets import parse_image +from utils.widgets import parse_image, parse_video from utils.widgets import markdown_to_html @@ -82,6 +82,7 @@ class Entry(models.Model): ) template_name = models.IntegerField(choices=TEMPLATES, default=0) featured_image = models.ForeignKey(LuxImage, null=True, blank=True) + #has_video = models.BooleanField(blank=True, default=False) class Meta: ordering = ('-pub_date',) @@ -164,6 +165,7 @@ class Entry(models.Model): else: md = image_url_replace(self.body_markdown) self.body_html = markdown.markdown(md, extensions=['extra'], safe_mode=False) + self.has_video = parse_video(self.body_html) self.dek = markdown_to_html(self.dek) try: self.location = Location.objects.filter(geometry__contains=self.point).get() diff --git a/app/photos/models.py b/app/photos/models.py index 4207ad4..ac85a50 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -87,6 +87,11 @@ class LuxImage(models.Model): print("Size name" +size.name) return self.get_image_by_size(size.name) + def get_video_base_url(self): + if self.is_video: + return self.image.url[:-4] + + def get_largest_image(self): t = [] for size in self.sizes.all(): diff --git a/app/utils/widgets.py b/app/utils/widgets.py index d588b08..4f96e38 100644 --- a/app/utils/widgets.py +++ b/app/utils/widgets.py @@ -162,3 +162,9 @@ def parse_image(s): return render_to_string("lib/img_%s.html" % css_class, c) +def parse_video(s): + soup = BeautifulSoup(s.group(), "lxml") + for vid in soup.find_all('video'): + return True + return False + diff --git a/design/sass/_writing_details.scss b/design/sass/_writing_details.scss index 875267e..9697ddf 100644 --- a/design/sass/_writing_details.scss +++ b/design/sass/_writing_details.scss @@ -360,7 +360,7 @@ figure.picwide img.picwide { } } } -.image-cluster { +.image-cluster, .cluster { .row-2, .row-3, .row-4, .stack-2, .stack-3 { display: block; } @@ -486,11 +486,9 @@ figure.picwide img.picwide { .embed-wrapper { @include constrain_wide; - margin-bottom: 1em; @include breakpoint(gamma) { margin-left: auto; margin-right: auto; - border: 5px solid $brown; } } .embed-container { diff --git a/design/templates/admin/insert_images.html b/design/templates/admin/insert_images.html index 70e1965..f9a2fa6 100644 --- a/design/templates/admin/insert_images.html +++ b/design/templates/admin/insert_images.html @@ -31,8 +31,18 @@ figure { {% with object.template_name as t %}{%if t == 1 or t == 3 %} -- cgit v1.2.3