-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrap demo from Wagtail BakeryDemo
- Loading branch information
0 parents
commit fcc377e
Showing
143 changed files
with
8,659 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Dockerfile | ||
docker-compose.yml | ||
Procfile | ||
Vagrantfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.DS_Store | ||
*.pyc | ||
*.log | ||
*.swp | ||
*.retry | ||
.env | ||
*~ | ||
/logs | ||
/data | ||
.~* | ||
common/CACHE | ||
bakerydemo/media/images/* | ||
bakerydemo/settings/local.py | ||
bakerydemodb | ||
__pycache__ | ||
.vagrant/ | ||
/.vagrant/ | ||
/Vagrantfile.local | ||
!.gitignore | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
sudo: required | ||
services: | ||
- docker | ||
|
||
env: | ||
global: | ||
- GREP_TIMEOUT=360 | ||
|
||
before_install: | ||
- sudo apt-get update | ||
- sudo apt-get install -qy -o Dpkg::Options::="--force-confold" docker-ce coreutils | ||
- sudo apt-get install -y zlib1g-dev | ||
|
||
script: | ||
# Bring up the postgres, redis, and app containers | ||
- docker-compose up --build -d | ||
|
||
- timeout $GREP_TIMEOUT grep -m 1 'Running migrations' <(docker-compose logs --follow app 2>&1) | ||
- timeout $GREP_TIMEOUT grep -m 1 'spawned uWSGI http 1' <(docker-compose logs --follow app 2>&1) | ||
- docker-compose run app /venv/bin/python /code/manage.py check | ||
|
||
after_script: | ||
- docker-compose logs | ||
- docker images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
FROM python:3.5-alpine | ||
|
||
ADD requirements/ /requirements/ | ||
RUN set -ex \ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
gcc \ | ||
g++ \ | ||
make \ | ||
libc-dev \ | ||
musl-dev \ | ||
linux-headers \ | ||
pcre-dev \ | ||
postgresql-dev \ | ||
libjpeg-turbo-dev \ | ||
zlib-dev \ | ||
git \ | ||
&& pyvenv /venv \ | ||
&& /venv/bin/pip install -U pip \ | ||
&& LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "/venv/bin/pip install -r /requirements/production.txt" \ | ||
&& runDeps="$( \ | ||
scanelf --needed --nobanner --recursive /venv \ | ||
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ | ||
| sort -u \ | ||
| xargs -r apk info --installed \ | ||
| sort -u \ | ||
)" \ | ||
&& apk add --virtual .python-rundeps $runDeps \ | ||
&& apk del .build-deps \ | ||
&& apk add libjpeg-turbo pcre | ||
RUN apk add --no-cache postgresql-client | ||
RUN mkdir /code/ | ||
WORKDIR /code/ | ||
ADD . /code/ | ||
EXPOSE 8000 | ||
|
||
# Add custom environment variables needed by Django or your settings file here: | ||
ENV DJANGO_SETTINGS_MODULE=bakerydemo.settings.production DJANGO_DEBUG=off | ||
|
||
# uWSGI configuration (customize as needed): | ||
ENV UWSGI_VIRTUALENV=/venv UWSGI_WSGI_FILE=bakerydemo/wsgi_production.py UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_WORKERS=2 UWSGI_THREADS=8 UWSGI_UID=1000 UWSGI_GID=2000 | ||
|
||
# Call collectstatic with dummy environment variables: | ||
RUN DATABASE_URL=postgres://none REDIS_URL=none /venv/bin/python manage.py collectstatic --noinput | ||
|
||
# make sure static files are writable by uWSGI process | ||
RUN chown -R 1000:2000 /code/bakerydemo/media | ||
|
||
# start uWSGI, using a wrapper script to allow us to easily add more commands to container startup: | ||
ENTRYPOINT ["/code/docker-entrypoint.sh"] | ||
CMD ["/venv/bin/uwsgi", "--http-auto-chunked", "--http-keepalive", "--static-map", "/media/=/code/bakerydemo/media/"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
release: yes "yes" | python manage.py migrate | ||
web: uwsgi --http-socket=:$PORT --master --workers=2 --threads=8 --die-on-term --wsgi-file=bakerydemo/wsgi_production.py --static-map /media/=/app/bakerydemo/media/ --offload-threads 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# All Vagrant configuration is done below. The "2" in Vagrant.configure | ||
# configures the configuration version (we support older styles for | ||
# backwards compatibility). Please don't change it unless you know what | ||
# you're doing. | ||
Vagrant.configure(2) do |config| | ||
# The most common configuration options are documented and commented below. | ||
# For a complete reference, please see the online documentation at | ||
# https://docs.vagrantup.com. | ||
|
||
# Every Vagrant development environment requires a box. You can search for | ||
# boxes at https://atlas.hashicorp.com/search. | ||
config.vm.box = "torchbox/wagtail-jessie64" | ||
config.vm.box_version = "~> 2.0" | ||
|
||
# Disable automatic box update checking. If you disable this, then | ||
# boxes will only be checked for updates when the user runs | ||
# `vagrant box outdated`. This is not recommended. | ||
# config.vm.box_check_update = false | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine. In the example below, | ||
# accessing "localhost:8000" will access port 8000 on the guest machine. | ||
config.vm.network "forwarded_port", guest: 8000, host: 8000 | ||
|
||
# Create a private network, which allows host-only access to the machine | ||
# using a specific IP. | ||
# config.vm.network "private_network", ip: "192.168.33.10" | ||
|
||
# Create a public network, which generally matched to bridged network. | ||
# Bridged networks make the machine appear as another physical device on | ||
# your network. | ||
# config.vm.network "public_network" | ||
|
||
# Share an additional folder to the guest VM. The first argument is | ||
# the path on the host to the actual folder. The second argument is | ||
# the path on the guest to mount the folder. And the optional third | ||
# argument is a set of non-required options. | ||
# config.vm.synced_folder "../data", "/vagrant_data" | ||
|
||
# Provider-specific configuration so you can fine-tune various | ||
# backing providers for Vagrant. These expose provider-specific options. | ||
# Example for VirtualBox: | ||
# | ||
# config.vm.provider "virtualbox" do |vb| | ||
# # Display the VirtualBox GUI when booting the machine | ||
# vb.gui = true | ||
# | ||
# # Customize the amount of memory on the VM: | ||
# vb.memory = "1024" | ||
# end | ||
# | ||
# View the documentation for the provider you are using for more | ||
# information on available options. | ||
|
||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies | ||
# such as FTP and Heroku are also available. See the documentation at | ||
# https://docs.vagrantup.com/v2/push/atlas.html for more information. | ||
# config.push.define "atlas" do |push| | ||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" | ||
# end | ||
|
||
# Enable provisioning with a shell script. Additional provisioners such as | ||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
# config.vm.provision "shell", inline: <<-SHELL | ||
# sudo apt-get update | ||
# sudo apt-get install -y apache2 | ||
# SHELL | ||
config.vm.provision :shell, :path => "vagrant/provision.sh", :args => "bakerydemo" | ||
|
||
# Enable agent forwarding over SSH connections. | ||
config.ssh.forward_agent = true | ||
|
||
if File.exist? "Vagrantfile.local" | ||
instance_eval File.read("Vagrantfile.local"), "Vagrantfile.local" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "WagtailBakeryDemo", | ||
"description": "WagtailBakeryDemo", | ||
"repository": "https://github.com/wagtail/bakerydemo", | ||
"keywords": ["wagtail", "django"], | ||
"env": { | ||
"DJANGO_DEBUG": "off", | ||
"DJANGO_SETTINGS_MODULE": "bakerydemo.settings.production", | ||
"DJANGO_SECURE_SSL_REDIRECT": "on" | ||
}, | ||
"scripts": { | ||
"postdeploy": "django-admin.py migrate && django-admin.py load_initial_data && echo 'from wagtail.images.models import Rendition; Rendition.objects.all().delete()' | django-admin.py shell" | ||
}, | ||
"addons": [ | ||
"heroku-postgresql:hobby-dev" | ||
] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from wagtail.api.v2.endpoints import PagesAPIEndpoint | ||
from wagtail.api.v2.router import WagtailAPIRouter | ||
from wagtail.images.api.v2.endpoints import ImagesAPIEndpoint | ||
from wagtail.documents.api.v2.endpoints import DocumentsAPIEndpoint | ||
|
||
# Create the router. "wagtailapi" is the URL namespace | ||
api_router = WagtailAPIRouter('wagtailapi') | ||
|
||
# Add the three endpoints using the "register_endpoint" method. | ||
# The first parameter is the name of the endpoint (eg. pages, images). This | ||
# is used in the URL of the endpoint | ||
# The second parameter is the endpoint class that handles the requests | ||
api_router.register_endpoint('pages', PagesAPIEndpoint) | ||
api_router.register_endpoint('images', ImagesAPIEndpoint) | ||
api_router.register_endpoint('documents', DocumentsAPIEndpoint) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from wagtail.images.blocks import ImageChooserBlock | ||
from wagtail.embeds.blocks import EmbedBlock | ||
from wagtail.core.blocks import ( | ||
CharBlock, ChoiceBlock, RichTextBlock, StreamBlock, StructBlock, TextBlock, | ||
) | ||
|
||
|
||
class ImageBlock(StructBlock): | ||
""" | ||
Custom `StructBlock` for utilizing images with associated caption and | ||
attribution data | ||
""" | ||
image = ImageChooserBlock(required=True) | ||
caption = CharBlock(required=False) | ||
attribution = CharBlock(required=False) | ||
|
||
class Meta: | ||
icon = 'image' | ||
template = "blocks/image_block.html" | ||
|
||
|
||
class HeadingBlock(StructBlock): | ||
""" | ||
Custom `StructBlock` that allows the user to select h2 - h4 sizes for headers | ||
""" | ||
heading_text = CharBlock(classname="title", required=True) | ||
size = ChoiceBlock(choices=[ | ||
('', 'Select a header size'), | ||
('h2', 'H2'), | ||
('h3', 'H3'), | ||
('h4', 'H4') | ||
], blank=True, required=False) | ||
|
||
class Meta: | ||
icon = "title" | ||
template = "blocks/heading_block.html" | ||
|
||
|
||
class BlockQuote(StructBlock): | ||
""" | ||
Custom `StructBlock` that allows the user to attribute a quote to the author | ||
""" | ||
text = TextBlock() | ||
attribute_name = CharBlock( | ||
blank=True, required=False, label='e.g. Mary Berry') | ||
|
||
class Meta: | ||
icon = "fa-quote-left" | ||
template = "blocks/blockquote.html" | ||
|
||
|
||
# StreamBlocks | ||
class BaseStreamBlock(StreamBlock): | ||
""" | ||
Define the custom blocks that `StreamField` will utilize | ||
""" | ||
heading_block = HeadingBlock() | ||
paragraph_block = RichTextBlock( | ||
icon="fa-paragraph", | ||
template="blocks/paragraph_block.html" | ||
) | ||
image_block = ImageBlock() | ||
block_quote = BlockQuote() | ||
embed_block = EmbedBlock( | ||
help_text='Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks', | ||
icon="fa-s15", | ||
template="blocks/embed_block.html") |
Oops, something went wrong.