1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/project/common/blocks.py

44 lines
1.6 KiB
Python
Raw Normal View History

2016-11-28 22:20:42 +00:00
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore import blocks
2016-12-03 22:56:49 +00:00
from wagtail.wagtailimages.blocks import ImageChooserBlock
from wagtail.wagtaildocs.blocks import DocumentChooserBlock
2016-12-05 14:23:11 +00:00
from wagtailmarkdown.blocks import MarkdownBlock
2016-12-15 22:00:42 +00:00
from wagtail.wagtailembeds.blocks import EmbedBlock
2016-11-28 22:20:42 +00:00
2016-12-15 22:00:42 +00:00
HEADING_CHOICES = [('h' + str(i), 'H' + str(i)) for i in range(1, 6)]
2016-12-03 20:49:24 +00:00
2016-12-15 22:00:42 +00:00
class HeadingBlock(blocks.StructBlock):
size = blocks.ChoiceBlock(choices=HEADING_CHOICES)
value = blocks.CharBlock()
class Meta:
icon = 'title'
template = 'blocks/heading.html'
class VideoBlock(blocks.StructBlock):
video = EmbedBlock()
caption = blocks.CharBlock()
class Meta:
template = 'blocks/video.html'
def build_stream_field():
return StreamField([
2016-12-03 22:56:49 +00:00
('ansi', blocks.TextBlock(template="blocks/ansi.html")),
('document', DocumentChooserBlock()),
2016-12-05 14:23:11 +00:00
('gist', blocks.CharBlock(icon="code", template="blocks/gist.html")),
2016-12-15 22:00:42 +00:00
('heading', HeadingBlock()),
2016-12-03 22:56:49 +00:00
('image', ImageChooserBlock()),
2016-12-05 14:23:11 +00:00
('markdown', MarkdownBlock()),
('ol', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ol", label="Ordered List", template='blocks/ordered-list.html')),
2016-11-28 22:20:42 +00:00
('paragraph', blocks.RichTextBlock()),
('raw_html', blocks.RawHTMLBlock(label="Raw HTML")),
2016-12-03 20:49:24 +00:00
('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')),
2016-12-05 14:23:11 +00:00
('ul', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ul", label="Unordered List")),
2016-12-15 22:00:42 +00:00
('video', VideoBlock())
])