Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flipperpa/wagtailcontentstream
An abstract Django model with a Wagtail StreamField named body with multiple blocks I use on a regular basis. It's opinioned: very little HTML is allowed in the text block, forcing authors to create structured data.
https://github.com/flipperpa/wagtailcontentstream
django python wagtail wagtail-page wagtail-plugin
Last synced: 3 months ago
JSON representation
An abstract Django model with a Wagtail StreamField named body with multiple blocks I use on a regular basis. It's opinioned: very little HTML is allowed in the text block, forcing authors to create structured data.
- Host: GitHub
- URL: https://github.com/flipperpa/wagtailcontentstream
- Owner: FlipperPA
- License: bsd-3-clause
- Created: 2017-08-05T14:39:46.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2022-10-24T14:39:09.000Z (about 2 years ago)
- Last Synced: 2024-10-15T04:33:04.964Z (3 months ago)
- Topics: django, python, wagtail, wagtail-page, wagtail-plugin
- Language: Python
- Homepage:
- Size: 36.1 KB
- Stars: 20
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wagtail Content Stream
An abstract Django model with a Wagtail StreamField named `body` with multiple blocks I use on a regular basis. This is geared towards developers who need to write examples with code in them. It's opinionated: very little HTML is allowed in the text block, forcing authors to create structured data. The following blocks are included in `ContentStreamBlock`:
* Heading
* Paragraph
* Captioned Image
* Embed
* Table
* Code BlockA secondary StreamBlock, `ContentStreamBlockWithRawCode`, also provides an additional block for injecting HTML, JS, and CSS code. Use with care, as this can really blow up your markup and is a potential code injection point!
Three pages types are provided out-of-the-box.
## Example Usage
You will need to add `wagtailcodeblock` to your `INSTALLED_APPS` Django setting.
#### Basic Usage: a Title Field and Content Stream
First, create a page type in your `models.py`:
```python
from wagtailcontentstream.models import ContentStreamPage, SectionContentStreamPage, ContentStreamPageWithRawCodeclass StandardPage(ContentStreamPage):
passclass SectionStandardPage(SectionContentStreamPage):
passclass StandardPageWithRawCode(ContentStreamPageWithRawCode):
pass
```Then in your template:
```django
{% load wagtailcore_tags %}{{ page.title }}
{% include_block page.body %}
```#### Extended Usage: Adding More Fields
```python
from django.conf import settings
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel
from wagtailcontentstream.models import ContentStreamPageclass StandardPage(ContentStreamPage):
date = models.DateField("Post Date")
authors = models.ManyToManyField(settings.AUTH_USER_MODEL)content_panels = [
FieldPanel('date'),
FieldPanel('authors'),
] + ContentStreamPage.content_panels
```# Release Notes & Contributors
* Thank you to our [wonderful contributors](https://github.com/FlipperPA/wagtailcontentstream/graphs/contributors)!
* Release notes are [available on GitHub](https://github.com/FlipperPA/wagtailcontentstream/releases).# Project Maintainer
* Timothy Allen (https://github.com/FlipperPA)