Skip to main content

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, 2.16)
  • Django (3.2, 4.0)
  • Python 3 (3.7, 3.8, 3.9, 3.10)

Installation

  1. Install using pip:
    $ pip install wagtail-cblocks
    
  2. 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 Python 3 is installed on your system. Then:

  1. Clone this repository
  2. Create a virtual environment and activate it:
    $ python3 -m venv venv
    $ source venv/bin/activate
    
  3. 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 coverage
  • make 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_cblocks-0.3.2.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

wagtail_cblocks-0.3.2-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file wagtail_cblocks-0.3.2.tar.gz.

File metadata

  • Download URL: wagtail_cblocks-0.3.2.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for wagtail_cblocks-0.3.2.tar.gz
Algorithm Hash digest
SHA256 742f5c78b6f09a32c757272e936f2839ba4e5aaa502935af61112bae4d8640a0
MD5 7bac82a7ab79b2ee484d275d73b8e51d
BLAKE2b-256 3207cdaba3db92d3173612d24465a808dff8fe5417df408e28fb04371157193c

See more details on using hashes here.

File details

Details for the file wagtail_cblocks-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: wagtail_cblocks-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for wagtail_cblocks-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc7ae9311d592cd7fb858133d512c8caaae9be0a53c5f28c205eb5891104aaf
MD5 109df92e234729d58545418efc6dbf05
BLAKE2b-256 dd8629b5717a029ceae8433048a0d7070470d6781e9d33e245b7a4357e5f81ae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page