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:

  • Python 3 (3.9, 3.10, 3.11, 3.12, 3.13)
  • Django (4.2 LTS, 5.2 LTS)
  • Wagtail (6.2 LTS - 7.0 LTS)

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.blocks import StreamBlock
from wagtail.fields import StreamField
from wagtail.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 --editable ".[dev]" "tox>=4.11"
    

To run the test app interactively, use tox -e interactive, visit http://127.0.0.1:8020/admin and log in with admin / changeme.

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 ruff. You can check the code with make lint and try to fix the reported issues with make format.

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.5.2.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtail_cblocks-0.5.2-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wagtail_cblocks-0.5.2.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for wagtail_cblocks-0.5.2.tar.gz
Algorithm Hash digest
SHA256 b6fdeeadb1e424778ca8cca91f274413974874f949f0d1d21988412d96f133f3
MD5 2180dfc47da7a85ee22c5d7dc5a57bf3
BLAKE2b-256 32e92f296c428b0f5326c54f8447836055f68f5e797109eb16dcd705dc577c21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wagtail_cblocks-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 92daa7e10301f85a1a3c62433490765fb29353a57e80992f105bfd336035f18d
MD5 e224f2ce2a3dd29e5f66771466c0c5ab
BLAKE2b-256 48ca764cc2651102752413d1dfcae0fb2d4f96fb709969024f9e116fcc513946

See more details on using hashes here.

Supported by

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