Skip to content

Commit

Permalink
Fixed AllPublishedPagesView return specific pages to fix correct temp…
Browse files Browse the repository at this point in the history
…late name

Fixed get method in WagtailBakeryView to serve wagtail compatible response
Update example site with fixtures, templates, custom pages and styling
  • Loading branch information
robmoorman committed Nov 22, 2016
1 parent 71c9ff5 commit e4c3ff3
Show file tree
Hide file tree
Showing 18 changed files with 399 additions and 28 deletions.
8 changes: 4 additions & 4 deletions examples/site/Makefile
Expand Up @@ -2,7 +2,7 @@ all: clean install migrate loaddata runserver

clean:
find . -name '*.pyc' | xargs rm
rm -rf build/ example/db.sqlite3
rm -rf build/ example/public/ example/db.sqlite3

install:
pip install -r requirements.txt
Expand All @@ -16,9 +16,9 @@ loaddata:
python manage.py loaddata fixtures/sites.json

dumpdata:
python manage.py dumpdata auth.User --indent=2 > fixtures/users.json
python manage.py dumpdata wagtailcore.Page --indent=2 > fixtures/pages.json
python manage.py dumpdata wagtailcore.Site --indent=2 > fixtures/sites.json
python manage.py dumpdata auth.User --indent=2 --natural-foreign > fixtures/users.json
python manage.py dumpdata example wagtailcore.Page --indent=2 --natural-foreign > fixtures/pages.json
python manage.py dumpdata wagtailcore.Site --indent=2 --natural-foreign > fixtures/sites.json

runserver:
python manage.py runserver
64 changes: 64 additions & 0 deletions examples/site/example/migrations/0001_initial.py
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-22 14:31
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import wagtail.wagtailcore.blocks
import wagtail.wagtailcore.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailcore', '0030_index_on_pagerevision_created_at'),
]

operations = [
migrations.CreateModel(
name='BlogListPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('body', wagtail.wagtailcore.fields.StreamField([(b'paragraph', wagtail.wagtailcore.blocks.RichTextBlock())])),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='BlogPostPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('body', wagtail.wagtailcore.fields.StreamField([(b'paragraph', wagtail.wagtailcore.blocks.RichTextBlock())])),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='GenericPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('body', wagtail.wagtailcore.fields.StreamField([(b'paragraph', wagtail.wagtailcore.blocks.RichTextBlock())])),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='HomePage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('body', wagtail.wagtailcore.fields.StreamField([(b'paragraph', wagtail.wagtailcore.blocks.RichTextBlock())])),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
Empty file.
33 changes: 33 additions & 0 deletions examples/site/example/models.py
@@ -0,0 +1,33 @@
from wagtail.wagtailcore import blocks
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore.models import Page
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel


class AbstractExamplePage(Page):
body = StreamField([
('paragraph', blocks.RichTextBlock())
])

content_panels = [
FieldPanel('title'),
StreamFieldPanel('body')
]

class Meta:
abstract = True

class HomePage(AbstractExamplePage):
pass


class GenericPage(AbstractExamplePage):
pass


class BlogListPage(AbstractExamplePage):
pass


class BlogPostPage(AbstractExamplePage):
pass
15 changes: 9 additions & 6 deletions examples/site/example/settings.py
Expand Up @@ -57,6 +57,8 @@

'bakery',
'wagtailbakery',

'example',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -132,8 +134,15 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'public/media')

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'public/static')

STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]

# Wagtail
# http://docs.wagtail.io/en/v1.6.2/getting_started/integrating_into_django.html
Expand All @@ -144,12 +153,6 @@
# Wagtail bakery
# https://github.com/moorinteractive/wagtail-bakery

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'public/media')

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'public/static')

BUILD_DIR = os.path.join(BASE_DIR, '../build')

BAKERY_VIEWS = (
Expand Down
31 changes: 31 additions & 0 deletions examples/site/example/static/example/css/main.css
@@ -0,0 +1,31 @@
body {
background-color: #333333;
color: #ffffff;
margin: 0;
padding: 100px;
}

ul.navigation {
list-style-type: none;
margin: 0;
padding: 0;
}

ul.navigation > li {
display: inline-block;
}

ul.navigation > li > a {
border: 1px solid #ff574a;
border-radius: 4px;
padding: 5px 10px;
}

h1 {
color: #43b1b0;
}

a,a:active,a:link,a:visited {
color: #ff574a;
text-decoration: none;
}
24 changes: 24 additions & 0 deletions examples/site/example/templates/base.html
@@ -0,0 +1,24 @@
{% load static %}

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="{% static "example/css/main.css" %}">
<title>{{ self.title }}</title>
</head>
<body>
{% block navigation %}
<ul class="navigation">
{% for item in page.get_site.root_page.get_children %}
<li>
<a href="{{ item.url }}">{{ item.title }}</a>
</li>
{% endfor %}
</ul>
{% endblock %}
{% block title %}
<h1>{{ self.title }}</h1>
{% endblock %}
{% block content %}{% endblock %}
</body>
</html>
12 changes: 12 additions & 0 deletions examples/site/example/templates/example/blog_list_page.html
@@ -0,0 +1,12 @@
{% extends "base.html" %}

{% block content %}
{{ self.body }}
<ul>
{% for item in page.get_children %}
<li>
<a href="{{ item.url }}">{{ item.title }}</a>
</li>
{% endfor %}
</ul>
{% endblock %}
8 changes: 8 additions & 0 deletions examples/site/example/templates/example/blog_post_page.html
@@ -0,0 +1,8 @@
{% extends "base.html" %}

{% block content %}
{{ self.body }}
<p>
<a href="{{ page.get_parent.url }}">Go back to blog overview</a>
</p>
{% endblock %}
5 changes: 5 additions & 0 deletions examples/site/example/templates/example/generic_page.html
@@ -0,0 +1,5 @@
{% extends "base.html" %}

{% block content %}
{{ self.body }}
{% endblock %}
5 changes: 5 additions & 0 deletions examples/site/example/templates/example/home_page.html
@@ -0,0 +1,5 @@
{% extends "base.html" %}

{% block content %}
{{ self.body }}
{% endblock %}
11 changes: 11 additions & 0 deletions examples/site/example/urls.py
Expand Up @@ -13,6 +13,9 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
import os

from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from wagtail.wagtailadmin import urls as wagtailadmin_urls
Expand All @@ -26,3 +29,11 @@
url(r'^pages/', include(wagtail_urls)),
url(r'', include(wagtail_urls)),
]

if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(
settings.MEDIA_URL, document_root=os.path.join(settings.MEDIA_ROOT))

0 comments on commit e4c3ff3

Please sign in to comment.