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:
- Wagtail (2.15 LTS, 3.0, 4.0)
- Django (3.2, 4.0, 4.1)
- Python 3 (3.7, 3.8, 3.9, 3.10)
Installation
- Install using
pip
:$ pip install wagtail-cblocks
- Add
wagtail_cblocks
to yourINSTALLED_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 Python 3 is installed on your system. Then:
- Clone this repository
- Create a virtual environment and activate it:
$ python3 -m venv venv $ source venv/bin/activate
- Install this package and its requirements:
(venv)$ pip install -r requirements-dev.txt
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:
(venv)$ ./tests/manage.py migrate
(venv)$ ./tests/manage.py runserver
Contributing
The tests are written with pytest and code coverage is measured with coverage. You can use the following commands while developing:
make test
: run the tests and output a quick report of code coveragemake test-wip
: only run the tests marked as 'wip'make test-all
: run the tests on all supported versions of Django and Wagtail with nox
The Python code is formatted and linted thanks to flake8, isort and black. All of these tools are configured in pre-commit and you should consider to install its git hook scripts by running:
(venv)$ pre-commit install
When submitting a pull-request, please ensure that the code is well formatted and covered, and that all the tests pass.
License
This extension is mainly developed by Cliss XXI and licensed under the AGPLv3+. Any contribution is welcome!
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.3.5.tar.gz
.
File metadata
- Download URL: wagtail_cblocks-0.3.5.tar.gz
- Upload date:
- Size: 33.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | effc81297cd04e283b81d5b5b0e88407d5cd025113da25f8b61eb5fb3c35a0bc |
|
MD5 | 006081ef7e1d2f665b198fd1a479540f |
|
BLAKE2b-256 | 02fc474e0a996267d33947e4516d02be6152664d0241549fd15d1f5bf944dba7 |
File details
Details for the file wagtail_cblocks-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: wagtail_cblocks-0.3.5-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91c89e443c4dce8cd700e4fdffb7cc8fc453b36ee2cf563dc3d6b51c740ae613 |
|
MD5 | 5709f17aa15b79d78eebb0438a251c69 |
|
BLAKE2b-256 | 46c77851b2ea6fc795d9eb7cb56eb3d70a37fe8b26c44a9406f2d12f692d753d |