Collection of StreamField blocks for Wagtail
Project description
wagtail-cblocks
A collection of StreamField blocks to use in Wagtail CMS.
Warning! This project is still early on in its development lifecycle. It is possible for breaking changes to occur between versions until reaching a stable 1.0. Feedback and pull requests are welcome.
Requirements
wagtail-cblocks requires the following:
- Python (3.7, 3.8, 3.9)
- Django (2.11, 3.0, 3.1)
- Wagtail (2.11, 2.12)
Older versions of Wagtail could work too but they are not tested. The efforts are focused in LTS and recent versions.
Installation
Install using pip
:
pip install wagtail-cblocks
Add wagtail_cblocks
to your INSTALLED_APPS
setting:
INSTALLED_APPS = [
# ...
'wagtail_cblocks',
# ...
]
Usage
Each block comes with a template made for Bootstrap 5 which is not shipped by this plugin. If you plan to use them as is, you must have at least the Bootstrap stylesheet loaded in your base template - refer as needed to the Bootstrap documentation.
In waiting for the documentation, here is a sample usage:
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.core.blocks import StreamBlock
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
from wagtail_cblocks.blocks import (
ButtonBlock,
ColumnsBlock,
HeadingBlock,
ImageBlock,
ParagraphBlock,
)
class BaseBlock(StreamBlock):
title_block = HeadingBlock()
paragraph_block = ParagraphBlock()
button_block = ButtonBlock()
image_block = ImageBlock()
class BodyBlock(BaseBlock):
columns_block = ColumnsBlock(BaseBlock())
class StandardPage(Page):
body = StreamField(BodyBlock())
content_panels = Page.content_panels + [
StreamFieldPanel('body'),
]
Factories are also provided for some of the blocks to ease tests - see
wagtail_cblocks/factories.py
. To make use of
them, install the extra factories requirements:
pip install wagtail-cblocks[factories]
Development
Quick start
To set up a development environment, ensure that virtualenv
is installed on your system. Then:
- Clone this repository
- Create a virtual environment and activate it:
virtualenv -p python3 venv source venv/bin/activate
- Install this package in develop mode with extra requirements:
pip install -e .[test]
Finally, if you want to run the test application to preview the blocks, you will have to create the database before running a development server:
./tests/manage.py migrate
DEBUG=1 ./tests/manage.py runserver
Note that DEBUG=1
is required since tests are run without the debug mode. All the media will be stored in tests/var
.
Contributing
The Python code is formatted and linted thanks to flake8, isort and black. To ease the use of this tools, the following commands are available:
make lint
: check the Python code syntax and imports ordermake format
: fix the Python code syntax and imports order
The tests are written with pytest and code coverage is measured with coverage.py. You can use the following commands for that:
make test
: run the tests and output a quick report of code coveragemake coverage
: run the tests and produce an HTML report of code coverage
When submitting a pull-request, please ensure that the code is well formatted and covered, and that all the other tests pass.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wagtail_cblocks-0.2.1.tar.gz
.
File metadata
- Download URL: wagtail_cblocks-0.2.1.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.1+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19bb4d233d76631602ce5722622574ebe2d3d3af3b34eb7d7c6e576413ed67c9 |
|
MD5 | 3a22c4634d0a5178ffbf7cc21d88e065 |
|
BLAKE2b-256 | 553cf5b13ae2930e9a41d9f64ed0c1fb3e5b26bff88abed4745577c6ead09138 |
File details
Details for the file wagtail_cblocks-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: wagtail_cblocks-0.2.1-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.1+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 684c35aea70cefc2852d92fa79bcf96ef949f571420a98c23e2eaf8bdc847cd5 |
|
MD5 | e1092baa9e7eb5f3e7a1e4bc592050e6 |
|
BLAKE2b-256 | fab4377b98a1226b6eff830c86c1469404ba46c540a2cfe48592cd1a496da917 |