From 3f9852d768a892e063e0c4ff191e009114ba96fa Mon Sep 17 00:00:00 2001 From: khashashin Date: Tue, 5 Sep 2017 16:24:48 +0200 Subject: [PATCH 1/6] template error included --- feedler/migrations/0004_auto_20170905_1502.py | 20 ++++++++ publichealth/home/models/models.py | 11 +++- .../home/templates/home/article_page.html | 50 ++++++++++++++++++- publichealth/static/css/sw_carousel.min.css | 1 + 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 feedler/migrations/0004_auto_20170905_1502.py create mode 100644 publichealth/static/css/sw_carousel.min.css diff --git a/feedler/migrations/0004_auto_20170905_1502.py b/feedler/migrations/0004_auto_20170905_1502.py new file mode 100644 index 0000000..3e36893 --- /dev/null +++ b/feedler/migrations/0004_auto_20170905_1502.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-09-05 13:02 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('feedler', '0003_entry_lang'), + ] + + operations = [ + migrations.AlterField( + model_name='entry', + name='lang', + field=models.CharField(blank=True, choices=[('de', 'Deutsch'), ('fr', 'Français'), ('it', 'Italiano'), ('en', 'English'), ('', ' * * * ')], default='', max_length=2), + ), + ] diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 6fd1eb1..3732688 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -7,7 +7,7 @@ from django.utils import translation from modelcluster.fields import ParentalKey -from wagtail.wagtailcore.blocks import StructBlock, CharBlock, URLBlock, RichTextBlock +from wagtail.wagtailcore.blocks import StructBlock, CharBlock, URLBlock, RichTextBlock, ListBlock, TextBlock from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailcore.fields import StreamField, RichTextField from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePanel, MultiFieldPanel @@ -77,6 +77,13 @@ class ArticleIndexPage(Page): class Meta: verbose_name = "Rubrik" +class ImageCarouselBlock(StructBlock): + image = ImageChooserBlock() + caption = TextBlock(required=False) + + class Meta: + icon = 'image' + class ArticlePage(Page): title_fr = models.CharField(max_length=255, default="") trans_title = TranslatedField( @@ -93,7 +100,7 @@ class ArticlePage(Page): body_de = StreamField([ ('paragraph', RichTextBlock()), - ('image', ImageChooserBlock()), + ('image_carousel', ListBlock(ImageCarouselBlock(),template='publichealth/templates/home/article_page.html',icon="image")), ('section', CharBlock(classname="full title")), ('info', InfoBlock()), ], null=True, blank=True) diff --git a/publichealth/home/templates/home/article_page.html b/publichealth/home/templates/home/article_page.html index 71336e8..5fd16e0 100644 --- a/publichealth/home/templates/home/article_page.html +++ b/publichealth/home/templates/home/article_page.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{% load wagtailcore_tags wagtailimages_tags %} +{% load wagtailcore_tags wagtailimages_tags static block_tags %} {% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %} @@ -10,5 +10,53 @@ {% include 'home/page_content.html' %} + + + + + + + {% endblock %} diff --git a/publichealth/static/css/sw_carousel.min.css b/publichealth/static/css/sw_carousel.min.css new file mode 100644 index 0000000..64fc064 --- /dev/null +++ b/publichealth/static/css/sw_carousel.min.css @@ -0,0 +1 @@ +#gallery-1{width:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none}#gallery-2,.gallery-2{margin:0 auto;display:block}@media (max-width: 600px){#gallery-2,.gallery-2{width:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none}}.rsDefault,.rsDefault .rsOverflow,.rsDefault .rsSlide,.rsDefault .rsVideoFrameHolder,.rsDefault .rsThumbs{background:#F8F8FF;color:#6d6f72;width:100%;padding-bottom:10px}.container-carousel{margin:10px 0 10px 0}.rsWithThumbs .rsGCaption{font-size:1em;line-height:18px;padding:12px 0 16px;background:#fff;width:100%;position:static;float:left;left:auto;bottom:auto;text-align:center;margin-bottom:10px;color:#6d6f72}.visibleNearby{width:100%;background:#F8F8FF;color:#333;padding-top:25px}.visibleNearby .rsGCaption{font-size:1em;line-height:18px;padding:12px 0 16px;background:#F8F8FF;width:100%;position:static;float:left;left:auto;bottom:auto;text-align:center;margin-bottom:10px;color:#6d6f72}.visibleNearby .rsGCaption span{display:block;clear:both;color:#6d6f72;font-size:1.2em;line-height:22px}.visibleNearby .rsSlide img{opacity:0.45;-webkit-transition:all 0.3s ease-out;-moz-transition:all 0.3s ease-out;transition:all 0.3s ease-out;-webkit-transform:scale(0.9);-moz-transform:scale(0.9);-ms-transform:scale(0.9);-o-transform:scale(0.9);transform:scale(0.9)}.visibleNearby .rsActiveSlide img{opacity:1;-webkit-transform:scale(1);-moz-transform:scale(1);-ms-transform:scale(1);-o-transform:scale(1);transform:scale(1)}@media screen and (min-width: 0px) and (max-width: 900px){#gallery-1 .rsOverflow,.royalSlider#gallery-1{height:400px !important}}@media screen and (min-width: 0px) and (max-width: 500px){#gallery-1 .rsOverflow,.royalSlider#gallery-1{height:300px !important}} From dbee8509f26ba8e0c95b71885aaac2ac31db5945 Mon Sep 17 00:00:00 2001 From: Oleg Lavrovsky Date: Wed, 6 Sep 2017 14:57:19 +0200 Subject: [PATCH 2/6] Refactoring from khashashin --- .../migrations/0021_auto_20170906_1453.py | 33 ++++++++++++ publichealth/home/models/models.py | 18 +++++-- .../home/templates/home/article_page.html | 52 +------------------ .../home/templates/home/page_content.html | 4 ++ .../home/templates/home/photo_gallery.html | 20 +++++++ publichealth/static/js/main.js | 23 ++++++++ 6 files changed, 96 insertions(+), 54 deletions(-) create mode 100644 publichealth/home/migrations/0021_auto_20170906_1453.py create mode 100644 publichealth/home/templates/home/photo_gallery.html diff --git a/publichealth/home/migrations/0021_auto_20170906_1453.py b/publichealth/home/migrations/0021_auto_20170906_1453.py new file mode 100644 index 0000000..aef05e4 --- /dev/null +++ b/publichealth/home/migrations/0021_auto_20170906_1453.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2017-09-06 12:53 +from __future__ import unicode_literals + +from django.db import migrations +import wagtail.wagtailcore.blocks +import wagtail.wagtailcore.fields +import wagtail.wagtailimages.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0020_auto_20170904_2233'), + ] + + operations = [ + migrations.AddField( + model_name='articlepage', + name='gallery', + field=wagtail.wagtailcore.fields.StreamField((('image', wagtail.wagtailcore.blocks.ListBlock(wagtail.wagtailcore.blocks.StructBlock((('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('caption', wagtail.wagtailcore.blocks.TextBlock(required=False)))), icon='image')),), blank=True), + ), + migrations.AlterField( + model_name='articlepage', + name='body_de', + field=wagtail.wagtailcore.fields.StreamField((('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('section', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.wagtailcore.blocks.RichTextBlock(required=True)), ('action', wagtail.wagtailcore.blocks.CharBlock(required=False)), ('url', wagtail.wagtailcore.blocks.URLBlock(required=False))))), ('placer', wagtail.wagtailcore.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='cup'))), blank=True, null=True), + ), + migrations.AlterField( + model_name='articlepage', + name='body_fr', + field=wagtail.wagtailcore.fields.StreamField((('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('section', wagtail.wagtailcore.blocks.CharBlock(classname='full title')), ('info', wagtail.wagtailcore.blocks.StructBlock((('title', wagtail.wagtailcore.blocks.CharBlock(required=True)), ('photo', wagtail.wagtailimages.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.wagtailcore.blocks.RichTextBlock(required=True)), ('action', wagtail.wagtailcore.blocks.CharBlock(required=False)), ('url', wagtail.wagtailcore.blocks.URLBlock(required=False))))), ('placer', wagtail.wagtailcore.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='cup'))), blank=True, null=True), + ), + ] diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 3732688..45be7cb 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -7,7 +7,7 @@ from django.utils import translation from modelcluster.fields import ParentalKey -from wagtail.wagtailcore.blocks import StructBlock, CharBlock, URLBlock, RichTextBlock, ListBlock, TextBlock +from wagtail.wagtailcore.blocks import StructBlock, CharBlock, URLBlock, RichTextBlock, ListBlock, TextBlock, ChoiceBlock from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailcore.fields import StreamField, RichTextField from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel, InlinePanel, MultiFieldPanel @@ -98,17 +98,28 @@ class ArticlePage(Page): 'intro_fr', ) + gallery = StreamField([ + ('image', ListBlock(ImageCarouselBlock(), icon="image")), + ], blank=True) + # documents = StreamField([ + # ('documents', ListBlock(DocumentChooserBlock(), icon="document")), + # ]) + body_de = StreamField([ ('paragraph', RichTextBlock()), - ('image_carousel', ListBlock(ImageCarouselBlock(),template='publichealth/templates/home/article_page.html',icon="image")), ('section', CharBlock(classname="full title")), ('info', InfoBlock()), + ('placer', ChoiceBlock(choices=[ + ('gallery', 'Image gallery'), + ], icon='user')) ], null=True, blank=True) body_fr = StreamField([ ('paragraph', RichTextBlock()), - ('image', ImageChooserBlock()), ('section', CharBlock(classname="full title")), ('info', InfoBlock()), + ('placer', ChoiceBlock(choices=[ + ('gallery', 'Image gallery'), + ], icon='user')) ], null=True, blank=True) trans_body = TranslatedField( 'body_de', @@ -149,6 +160,7 @@ class ArticlePage(Page): MultiFieldPanel([ ImageChooserPanel('feed_image'), ], heading="Images"), + StreamFieldPanel('gallery'), ] promote_panels = [ InlinePanel('related_links', label="Links"), diff --git a/publichealth/home/templates/home/article_page.html b/publichealth/home/templates/home/article_page.html index 5fd16e0..7c46641 100644 --- a/publichealth/home/templates/home/article_page.html +++ b/publichealth/home/templates/home/article_page.html @@ -1,62 +1,12 @@ {% extends "base.html" %} -{% load wagtailcore_tags wagtailimages_tags static block_tags %} +{% load wagtailcore_tags %} {% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %} {% block content %}
- {% include 'home/page_content.html' %} -
- - - - - - -
{% endblock %} diff --git a/publichealth/home/templates/home/page_content.html b/publichealth/home/templates/home/page_content.html index db2dd41..5c32aeb 100644 --- a/publichealth/home/templates/home/page_content.html +++ b/publichealth/home/templates/home/page_content.html @@ -19,6 +19,10 @@ {% for block in page.trans_body %} {% if block.block_type == 'heading' %}

{{ block.value }}

+ {% elif block.block_type == 'placer' %} + {% if block.value == 'gallery' %} + {% include 'home/photo_gallery.html' %} + {% endif %} {% elif block.block_type != 'info' %}

{% include_block block %} diff --git a/publichealth/home/templates/home/photo_gallery.html b/publichealth/home/templates/home/photo_gallery.html new file mode 100644 index 0000000..b3f4fed --- /dev/null +++ b/publichealth/home/templates/home/photo_gallery.html @@ -0,0 +1,20 @@ +{% load wagtailcore_tags wagtailimages_tags static %} + + + +

diff --git a/publichealth/static/js/main.js b/publichealth/static/js/main.js index 982e842..2abefad 100644 --- a/publichealth/static/js/main.js +++ b/publichealth/static/js/main.js @@ -25,4 +25,27 @@ $(document).ready(function() { // $(this).css('border-top', '3px solid ' + pastel); // }); + // Carousel gallery component (article_page) + var si = $('#article_page-gallery').royalSlider({ + addActiveClass: true, + arrowsNav: true, + controlNavigation: 'none', + autoScaleSlider: true, + autoScaleSliderWidth: 900, + autoScaleSliderHeight: 250, + loop: true, + fadeinLoadedSlide: false, + globalCaption: true, + keyboardNavEnabled: true, + globalCaptionInside: false, + visibleNearby: { + enabled: true, + centerArea: 0.4, + center: true, + breakpoint: 650, + breakpointCenterArea: 0.64, + navigateByCenterClick: true + } + }).data('royalSlider'); + }); From 88d9b570672fd332dad748880e240143c1da4101 Mon Sep 17 00:00:00 2001 From: khashashin Date: Fri, 8 Sep 2017 11:08:16 +0200 Subject: [PATCH 3/6] prepull commit, need some fixes --- bower.json | 3 +- .../home/templates/home/photo_gallery.html | 44 +++++++++++++------ publichealth/static/css/sw_carousel.min.css | 1 - publichealth/static/js/main.js | 23 ---------- 4 files changed, 33 insertions(+), 38 deletions(-) delete mode 100644 publichealth/static/css/sw_carousel.min.css diff --git a/bower.json b/bower.json index 338479c..a8cc1a2 100644 --- a/bower.json +++ b/bower.json @@ -15,6 +15,7 @@ ], "dependencies": { "bootstrap-sass": "bootstrap-sass-official#^3.3.7", - "slick-carousel": "^1.6.0" + "slick-carousel": "^1.6.0", + "slick-lightbox": "^0.2.10" } } diff --git a/publichealth/home/templates/home/photo_gallery.html b/publichealth/home/templates/home/photo_gallery.html index b3f4fed..959375e 100644 --- a/publichealth/home/templates/home/photo_gallery.html +++ b/publichealth/home/templates/home/photo_gallery.html @@ -1,20 +1,38 @@ -{% load wagtailcore_tags wagtailimages_tags static %} +{% load compress static wagtailcore_tags wagtailimages_tags %} +{% compress js %} + + + + +{% endcompress %} + +{% block extra_css %} + + + +{% endblock %} - -