Browse Source

Merge branch 'master' of github.com:wagtail/bakerydemo

Edd Baldry 8 years ago
parent
commit
9f2ca052a1

+ 1 - 1
Procfile

@@ -1,2 +1,2 @@
 release: yes "yes" | python manage.py migrate
-web: uwsgi --http :$PORT --module bakerydemo.heroku_wsgi --master --offload-threads 1
+web: gunicorn bakerydemo.heroku_wsgi --log-file -

+ 2 - 1
bakerydemo/base/blocks.py

@@ -40,7 +40,7 @@ class BlockQuote(StructBlock):
     """
     Custom `StructBlock` that allows the user to attribute a quote to the author
     """
-    text = TextBlock(),
+    text = TextBlock()
     attribute_name = CharBlock(
         blank=True, required=False, label='e.g. Guy Picciotto')
 
@@ -54,6 +54,7 @@ class BaseStreamBlock(StreamBlock):
     """
     Define the custom blocks that `StreamField` will utilize
     """
+    intro_block = TextBlock()
     heading_block = HeadingBlock()
     paragraph_block = RichTextBlock(
         icon="fa-paragraph",

+ 16 - 0
bakerydemo/base/migrations/0005_merge_20170210_1539.py

@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-10 15:39
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('base', '0004_auto_20170210_1445'),
+        ('base', '0004_auto_20170210_1420'),
+    ]
+
+    operations = [
+    ]

+ 34 - 0
bakerydemo/base/migrations/0006_auto_20170210_1556.py

@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-10 15:56
+from __future__ import unicode_literals
+
+from django.db import migrations
+import wagtail.wagtailcore.blocks
+import wagtail.wagtailcore.fields
+import wagtail.wagtailembeds.blocks
+import wagtail.wagtailimages.blocks
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('base', '0005_merge_20170210_1539'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='aboutpage',
+            name='body',
+            field=wagtail.wagtailcore.fields.StreamField([(b'intro_block', wagtail.wagtailcore.blocks.TextBlock()), (b'heading_block', wagtail.wagtailcore.blocks.StructBlock([(b'heading_text', wagtail.wagtailcore.blocks.CharBlock(classname=b'title', required=True)), (b'size', wagtail.wagtailcore.blocks.ChoiceBlock(blank=True, choices=[(b'', b'Select a header size'), (b'h2', b'H2'), (b'h3', b'H3'), (b'h4', b'H4')], required=False))])), (b'paragraph_block', wagtail.wagtailcore.blocks.RichTextBlock(icon=b'fa-paragraph', template=b'blocks/paragraph_block.html')), (b'image_block', wagtail.wagtailcore.blocks.StructBlock([(b'image', wagtail.wagtailimages.blocks.ImageChooserBlock(required=True)), (b'caption', wagtail.wagtailcore.blocks.CharBlock(required=False)), (b'attribution', wagtail.wagtailcore.blocks.CharBlock(required=False))])), (b'block_quote', wagtail.wagtailcore.blocks.StructBlock([(b'text', wagtail.wagtailcore.blocks.TextBlock()), (b'attribute_name', wagtail.wagtailcore.blocks.CharBlock(blank=True, label=b'e.g. Guy Picciotto', required=False))])), (b'embed_block', wagtail.wagtailembeds.blocks.EmbedBlock(help_text=b'Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks', icon=b'fa-s15', template=b'blocks/embed_block.html'))], blank=True, verbose_name='About page detail'),
+        ),
+        migrations.AlterField(
+            model_name='formpage',
+            name='body',
+            field=wagtail.wagtailcore.fields.StreamField([(b'intro_block', wagtail.wagtailcore.blocks.TextBlock()), (b'heading_block', wagtail.wagtailcore.blocks.StructBlock([(b'heading_text', wagtail.wagtailcore.blocks.CharBlock(classname=b'title', required=True)), (b'size', wagtail.wagtailcore.blocks.ChoiceBlock(blank=True, choices=[(b'', b'Select a header size'), (b'h2', b'H2'), (b'h3', b'H3'), (b'h4', b'H4')], required=False))])), (b'paragraph_block', wagtail.wagtailcore.blocks.RichTextBlock(icon=b'fa-paragraph', template=b'blocks/paragraph_block.html')), (b'image_block', wagtail.wagtailcore.blocks.StructBlock([(b'image', wagtail.wagtailimages.blocks.ImageChooserBlock(required=True)), (b'caption', wagtail.wagtailcore.blocks.CharBlock(required=False)), (b'attribution', wagtail.wagtailcore.blocks.CharBlock(required=False))])), (b'block_quote', wagtail.wagtailcore.blocks.StructBlock([(b'text', wagtail.wagtailcore.blocks.TextBlock()), (b'attribute_name', wagtail.wagtailcore.blocks.CharBlock(blank=True, label=b'e.g. Guy Picciotto', required=False))])), (b'embed_block', wagtail.wagtailembeds.blocks.EmbedBlock(help_text=b'Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks', icon=b'fa-s15', template=b'blocks/embed_block.html'))]),
+        ),
+        migrations.AlterField(
+            model_name='homepage',
+            name='body',
+            field=wagtail.wagtailcore.fields.StreamField([(b'intro_block', wagtail.wagtailcore.blocks.TextBlock()), (b'heading_block', wagtail.wagtailcore.blocks.StructBlock([(b'heading_text', wagtail.wagtailcore.blocks.CharBlock(classname=b'title', required=True)), (b'size', wagtail.wagtailcore.blocks.ChoiceBlock(blank=True, choices=[(b'', b'Select a header size'), (b'h2', b'H2'), (b'h3', b'H3'), (b'h4', b'H4')], required=False))])), (b'paragraph_block', wagtail.wagtailcore.blocks.RichTextBlock(icon=b'fa-paragraph', template=b'blocks/paragraph_block.html')), (b'image_block', wagtail.wagtailcore.blocks.StructBlock([(b'image', wagtail.wagtailimages.blocks.ImageChooserBlock(required=True)), (b'caption', wagtail.wagtailcore.blocks.CharBlock(required=False)), (b'attribution', wagtail.wagtailcore.blocks.CharBlock(required=False))])), (b'block_quote', wagtail.wagtailcore.blocks.StructBlock([(b'text', wagtail.wagtailcore.blocks.TextBlock()), (b'attribute_name', wagtail.wagtailcore.blocks.CharBlock(blank=True, label=b'e.g. Guy Picciotto', required=False))])), (b'embed_block', wagtail.wagtailembeds.blocks.EmbedBlock(help_text=b'Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks', icon=b'fa-s15', template=b'blocks/embed_block.html'))], blank=True, verbose_name='Home page detail'),
+        ),
+    ]

+ 29 - 0
bakerydemo/blog/migrations/0002_auto_20170210_1556.py

@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-10 15:56
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import wagtail.wagtailcore.blocks
+import wagtail.wagtailcore.fields
+import wagtail.wagtailembeds.blocks
+import wagtail.wagtailimages.blocks
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('blog', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='blogpage',
+            name='subtitle',
+            field=models.CharField(blank=True, max_length=255),
+        ),
+        migrations.AlterField(
+            model_name='blogpage',
+            name='body',
+            field=wagtail.wagtailcore.fields.StreamField([(b'intro_block', wagtail.wagtailcore.blocks.TextBlock()), (b'heading_block', wagtail.wagtailcore.blocks.StructBlock([(b'heading_text', wagtail.wagtailcore.blocks.CharBlock(classname=b'title', required=True)), (b'size', wagtail.wagtailcore.blocks.ChoiceBlock(blank=True, choices=[(b'', b'Select a header size'), (b'h2', b'H2'), (b'h3', b'H3'), (b'h4', b'H4')], required=False))])), (b'paragraph_block', wagtail.wagtailcore.blocks.RichTextBlock(icon=b'fa-paragraph', template=b'blocks/paragraph_block.html')), (b'image_block', wagtail.wagtailcore.blocks.StructBlock([(b'image', wagtail.wagtailimages.blocks.ImageChooserBlock(required=True)), (b'caption', wagtail.wagtailcore.blocks.CharBlock(required=False)), (b'attribution', wagtail.wagtailcore.blocks.CharBlock(required=False))])), (b'block_quote', wagtail.wagtailcore.blocks.StructBlock([(b'text', wagtail.wagtailcore.blocks.TextBlock()), (b'attribute_name', wagtail.wagtailcore.blocks.CharBlock(blank=True, label=b'e.g. Guy Picciotto', required=False))])), (b'embed_block', wagtail.wagtailembeds.blocks.EmbedBlock(help_text=b'Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks', icon=b'fa-s15', template=b'blocks/embed_block.html'))], blank=True, verbose_name='Blog post'),
+        ),
+    ]

+ 2 - 0
bakerydemo/blog/models.py

@@ -46,6 +46,7 @@ class BlogPage(Page):
     """
     A Blog Page (Post)
     """
+    subtitle = models.CharField(blank=True, max_length=255)
     image = models.ForeignKey(
         'wagtailimages.Image',
         null=True,
@@ -64,6 +65,7 @@ class BlogPage(Page):
     )
 
     content_panels = Page.content_panels + [
+        FieldPanel('subtitle'),
         ImageChooserPanel('image'),
         StreamFieldPanel('body'),
         FieldPanel('date_published'),

+ 3 - 4
bakerydemo/heroku_wsgi.py

@@ -1,6 +1,5 @@
+from django.core.wsgi import get_wsgi_application
 from whitenoise.django import DjangoWhiteNoise
 
-from .wsgi import application as _application
-
-
-application = DjangoWhiteNoise(_application)
+application = get_wsgi_application()
+application = DjangoWhiteNoise(application)

+ 6 - 1
bakerydemo/settings/heroku.py

@@ -15,8 +15,13 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 # BASE_URL required for notification emails
 BASE_URL = 'http://localhost:8000'
 
-DATABASES = {'default': dj_database_url.config(default='postgres://postgres@localhost:5432/wagtaildemo')}
+db_from_env = dj_database_url.config(conn_max_age=500)
+DATABASES['default'].update(db_from_env)
 
+# Simplified static file serving.
+# https://warehouse.python.org/project/whitenoise/
+
+STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
 
 try:
     from .local import *

+ 5 - 0
bakerydemo/static/css/main2.css

@@ -0,0 +1,5 @@
+.hero{
+	height: 600px;
+	background-size: cover;
+	background-position: center;
+}

+ 4 - 9
bakerydemo/templates/base.html

@@ -32,6 +32,8 @@
         <!-- Theme CSS -->
         {# <link href="css/clean-blog.min.css" rel="stylesheet">#}
         <link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
+        <link rel="stylesheet" type="text/css" href="{% static 'css/main2.css' %}">
+
 
         <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
         <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
@@ -90,15 +92,8 @@
     {% endblock %}
 
     <content> 
-        <div class="container">
-            <div class="row">
-                <div class="col-lg-2"></div>
-                <div class="col-lg-7">
-                    {% block content %}
-                    {% endblock %}
-                </div>
-            </div>
-        </div>
+        {% block content %}
+        {% endblock %}
     </content>
 
     <hr>

+ 1 - 0
bakerydemo/templates/blocks/intro_block.htm

@@ -0,0 +1 @@
+intro_block.html

+ 14 - 16
bakerydemo/templates/blog/blog_page.html

@@ -2,20 +2,18 @@
 {% load wagtailimages_tags %}
 
 {% block content %}
-    <h1>{{ page.title }}</h1>
-    <figure>
-      {% image self.image fill-600x600 %}
-    </figure>
-
-    {% for tag in page.get_tags  %}
-        <a href="{{ tag.url }}">{{ tag }}</a>
-    {% endfor %}
-
-    <date>{{ page.date_published }}</date>
-
-    {% for author in page.authors %}
-        <li>{{ author }}</li>
-    {% endfor %}
-
-    {{ page.body }}
+{% image self.image fill-1920x600 as hero_img %}
+<div class="container-fluid hero" style="background-image:url('{{ hero_img.url }}')">
+    <div class="container">
+        <h1>{{ page.title }}</h1>
+        <h2>{{ page.subtitle }}</h2>
+    </div>
+</div>
+<div class="container">
+    <div class="row">
+        <div class="col-md-7 col-md-offset-2">
+            {{ page.body }}
+        </div>
+    </div>
+</div>
 {% endblock content %}

+ 4 - 3
requirements.txt

@@ -5,6 +5,7 @@ wagtailfontawesome
 Pillow
 
 # Dependencies for Heroku deployment
-dj-database-url==0.3.0
-whitenoise>=3.1,<4.0
-uwsgi>=2.0,<2.1
+dj-database-url==0.4.1
+whitenoise==3.2.2
+gunicorn==19.6.0
+psycopg2==2.6.2