adds resume and streaming block
This commit is contained in:
parent
b6554fbf83
commit
b2001195fc
18 changed files with 223 additions and 0 deletions
47
base/blocks.py
Normal file
47
base/blocks.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
from wagtail.blocks import (
|
||||
CharBlock,
|
||||
ChoiceBlock,
|
||||
RichTextBlock,
|
||||
StreamBlock,
|
||||
StructBlock,
|
||||
)
|
||||
from wagtail.embeds.blocks import EmbedBlock
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
|
||||
class ImageBlock(StructBlock):
|
||||
image = ImageChooserBlock(required=True)
|
||||
caption = CharBlock(required=False)
|
||||
attribution = CharBlock(required=False)
|
||||
|
||||
class Meta:
|
||||
icon = "image"
|
||||
template = "base/blocks/image_block.html"
|
||||
|
||||
|
||||
class HeadingBlock(StructBlock):
|
||||
heading_text = CharBlock(classname="title", required=True)
|
||||
size = ChoiceBlock(
|
||||
choices=[
|
||||
("", "Select a heading size"),
|
||||
("h2", "H2"),
|
||||
("h3", "H3"),
|
||||
("h4", "H4"),
|
||||
],
|
||||
blank=True,
|
||||
required=False,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
icon = "title"
|
||||
template = "base/blocks/heading_block.html"
|
||||
|
||||
|
||||
class BaseStreamBlock(StreamBlock):
|
||||
heading_block = HeadingBlock()
|
||||
paragraph_block = RichTextBlock(icon="pilcrow")
|
||||
image_block = ImageBlock()
|
||||
embed_block = EmbedBlock(
|
||||
help_text="Insert a URL to embed. For example, https://www.youtube.com/watch?v=SGJFWirQ3ks",
|
||||
icon="media",
|
||||
)
|
7
base/templates/base/blocks/heading_block.html
Normal file
7
base/templates/base/blocks/heading_block.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
{% if self.size == 'h2' %}
|
||||
<h2>{{ self.heading_text }}</h2>
|
||||
{% elif self.size == 'h3' %}
|
||||
<h3>{{ self.heading_text }}</h3>
|
||||
{% elif self.size == 'h4' %}
|
||||
<h4>{{ self.heading_text }}</h4>
|
||||
{% endif %}
|
6
base/templates/base/blocks/image_block.html
Normal file
6
base/templates/base/blocks/image_block.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% load wagtailimages_tags %}
|
||||
|
||||
<figure>
|
||||
{% image self.image fill-600x338 loading="lazy" %}
|
||||
<figcaption>{{ self.caption }} - {{ self.attribution }}</figcaption>
|
||||
</figure>
|
Loading…
Add table
Add a link
Reference in a new issue