a batteries-included, reusable Wagtail project skeleton to serve as a starting point for a CMS-based website project.
Contents generated with DocToc
- Features β¨
- Dev Setup π»
- TODO β
- Contributing π€
- Show your support
- Credits π
- Reference π
- Author
- License π
- An opinionated starting point for a CMS-based website project, with so many batteries included:
- a homepage and "About" section, which includes addition of key personnel (with position, bio, social profiles, etc.)
- a minimal functional blog with simplified categories and tags,
- a contact page with contact form and location map. Includes SMS support powered by Vonage (formerly Nexmo)
- Tests written using pytest in conjunction with pytest-django (plus other pytest plugins), factory_boy and wagtail-factories. Test coverage currently stands at about 85%.
- Custom Bootstrap 4 Compilation using Sass.
- Font Awesome 5 (free) icons.
- shufflejs β Categorize, sort, and filter a responsive grid of items
- Live reload courtesy of BrowserSync.
- Gulp based workflow, with defined tasks for:
- copying minified (dist) files of modules listed in package.json "dependencies" field to the
static/vendors
directory, - deleting files and directories in the
static/vendors
directory, - transpiling ES6 code to ES5 using babel, and uglifying the resulting JS files,
- compiling SCSS to CSS and minifying css files
- watching for file changes (in conjunction with BrowserSync)
- copying minified (dist) files of modules listed in package.json "dependencies" field to the
- django-environ β allows you to utilize 12factor inspired environment variables to configure your Django application.
- django-extensions β global custom management extensions for the Django Framework. I especially like
runserver_plus
(the standard runserver stuff but with the Werkzeug debugger baked in) andshell_plus
(Django shell with autoloading of the apps database models and subclasses of user-defined classes). - django-recaptcha
- django-debug-toolbar for use during development
- django-maintenancemode-2 β makes it easy to put your Django site into "maintenance mode", or more technically, return an HTTP 503 response. This project differs slightly from other implementations in that the maintenance mode flag is stored in your database versus settings or an environment variable. If your site is deployed to multiple servers, the centralized database-based maintenance flag makes it a snap to bring them all up or down at once.
- Automatic dependency management via Renovate
- Task execution and automation using
invoke
. - Linting using Black, Flake8 and isort
- Celery ready
- Documentation on setting up the project (This README and the generated project's README!)
- A ready to use VSCode configuration, just update the path to your python executable in the generated
.vscode/settings.json
. - The project comes with three Continuous Integration configurations (Simply choose one of the three and delete the others. If you don't like any of these three, feel free to use other options such as Travis CI, Jenkins, etc.):
- A *nix environment is highly recommended. Although you can possibly develop on Windows too (if you do, and you're using Powershell or CMD, you'll probably have to adapt some commands to suit a Windows Environment, because these docs assume you're running in a *nix environment)
- Node.js with the following packages installed globally:
- concurrently:
npm install -g concurrently
- Browsersync:
npm install -g browser-sync
- Gulp:
npm install -g gulp-cli
- commitizen:
npm install commitizen -g
- prettier:
npm install prettier -g
- Sass:
npm install -g sass
- MailDev:
npm install -g maildev
- DocToc:
npm install -g doctoc
- concurrently:
- yarn: See installation instructions
- Python3 (3.6 and above) with virtualenvwrapper, pyenv and pip-tools.
- The project uses the PostgreSQL Backend for the wagtail search interface. Therefore, please ensure that Postgres (or PostGIS) are setup on your machine.
- ensure that you have cookiecutter installed on your computer
- run
cookiecutter https://github.com/engineervix/cookiecutter-wagtail-vix.git
in your favourite shell. Youβll be prompted for some values, such as project_name, , project_slug, email, wagtail_user_email etc. A new wagtail project will be created in a folder named according to the project_slug at your current location. - create a virtual environment for your project and and
pip install --upgrade pip
. Thereafter,cd
into the project folder created above and install python dependencies: First, install pip-tools:pip install pip-tools
, then runpip-compile requirements.in
followed bypip-sync
. - Now would be a good time to setup your postgres/postgis database and ensure that you update
DATABASE_URL
and the other environment variables in your.env
files. The essential ones for starters areRECAPTCHA_PUBLIC_KEY
,RECAPTCHA_PRIVATE_KEY
andMAPBOX_ACCESS_TOKEN
. export ENV_PATH=.envs/.dev.env
./manage.py makemigrations
followed by./manage.py migrate
./manage.py createsuperuser
. When prompted for an email address, please use the wagtail_user_email you specified in step 2. This is important to ensure that you don't have issues when populating the database with initial data, which is tied to the email address provided in step 2../manage.py load_initial_data
yarn
gulp cp
- Prior to running tests, check
package.json
to ensure that you have the correct postgres/postgis settings. Once you're all set, go ahead and run tests:yarn test
. - Start the development server:
yarn dev
. Your site should be accessible athttp://127.0.0.1:3000
orhttp://localhost:3000
.
- setup version control (git) for your generated project
- setup pre-commit:
pre-commit install
pre-commit install --hook-type commit-msg
pre-commit run --all-files
β If you are using pyenv, see pre-commit/pre-commit#810. In particular, I found this explanation from @thomasfowler and this comment from @asottile to be very helpful.
β οΈ First, ensure that, before you make any changes, you have pulled the latest changes from remote.- Add the file(s) you wanna commit:
git add whatever
git commit
-- this will run Commitizen; you'll be prompted to fill in any required fields and your commit messages will be formatted according to cz-conventional-changelog β a Commitizen adapter which prompts for conventional changelog standard.- If there are no issues, push your changes accordingly, otherwise, repeat steps 1 and 2 above until all issues are resolved.
β If you encounter
stylelint
errors, you might wanna runyarn css-fix
to try and fix such errors. This is likely to happen on first commit!
β If you make any changes to the structure of your README.md or other markdown files, do
yarn toc
before committing, so that the TOC is updated
- Run
invoke lint
to runflake8
,black
,isort
on the code. - If you get any errors from
black
and/orisort
, runinvoke lint --fix
orinvoke lint -f
so that black and isort can format your files. If this still doesn't work, don't worry, there's a bunch of pre-commit hooks that that have been set up to deal with this. Take a look at .pre-commit-config.yaml.
- Automate Steps 1 to 10 by adding these in the
post_gen_project
hook or incorporating them in invoke'stasks.py
- Improve test coverage for the generated wagtail project
- Setup integrated tests / e2e tests (Cypress / Selenium ?)
- Improve on code style (This is already in progress)
- Add docker support
- Improve the CI/CD pipelines for the generated wagtail project, to handle automatic deployments
- Generate RSS Feeds from Blog
- Add custom
sitemap.xml
androbots.txt
-
Make theI've removed theMakefile
functionalMakefile
and replaced it with invoke. - Write tests and setup CI for this cookiecutter package
- Possibly add support for other popular CI options (added CircleCI and GitHub Actions)
- Add
Gulp
support (No longer usingGrunt
) - Add some more badges if need be π
- Add better production-level features to make it easy to move from development to production (serving static assets, mail, caching, performance, task queues, Nginx and uWsgi/Gunicorn configuration, etc.) (This is always a work in progress, will continue updating as necessary)
-
Add support for different Databases right from the beginning. Even though this cookiecuter generates an SQLiteDATABASE_URL
for you, some of the generated project's features (like search) depend on using Postgres, so you should use Postgres/PostGIS. -
The cookiecutter prompt asks if you wanna use bootswatch themes. If you say "n", it shouldn't prompt you with another question on which bootswatch theme to use! See this and that. Since we're customizing bootstrap using Sass, no need to use bootswatch.
Contributions, issues and feature requests are most welcome! A good place to start is by helping out with the unchecked items in the TODO section above!
Feel free to check the issues page and take a look at the contributing guide before you get started. In addition, please note the following:
- if you're making code contributions, please try and write some tests to accompany your code, and ensure that the tests pass. Also, where necessary, update the docs so that they reflect your changes.
- commit your changes via
cz commit
. Follow the prompts. When you're done,pre-commit
will be invoked to ensure that your contributions and commits follow defined conventions. Seepre-commit-config.yaml
for more details. - your commit messages should follow the conventions described here. Write your commit message in the imperative: "Fix bug" and not "Fixed bug" or "Fixes bug." This convention matches up with commit messages generated by commands like
git merge
andgit revert
. Once you are done, please create a pull request.
Please give a βοΈ if this project helped you!
.gitignore
generated using https://www.gitignore.io/- favicon created using http://realfavicongenerator.net/
- Images courtesy of Unsplash and Pixabay
- Placeholder logo courtesy of https://github.com/pigment/fake-logos
- https://loremipsum.io/ for placeholder text
- HTML template based on https://startbootstrap.com/templates/business-frontpage/
- Team Section on About Page based on https://startbootstrap.com/snippets/about-team/
The data was dumped as follows:
./manage.py dumpdata --natural-foreign --indent 2 \
-e contenttypes -e auth \
-e wagtailcore.groupcollectionpermission \
-e wagtailcore.grouppagepermission -e wagtailimages.rendition \
-e postgres_search.indexentry -e users.user \
-e sessions > data.json
π€ Victor Miti
- Blog: https://importthis.tech
- Twitter:
- Github: @engineervix
Copyright Β© 2021 Victor Miti.
This project is licensed under the terms of the MIT license.