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-11-28 22:20:42 +00:00
|
|
|
|
|
|
|
|
2016-12-03 20:49:24 +00:00
|
|
|
def build_header_fields():
|
|
|
|
for i in range(6):
|
|
|
|
h_tag = "h" + str(i + 1)
|
|
|
|
yield (h_tag, blocks.CharBlock(classname=h_tag, label=h_tag.upper(), icon="title"))
|
|
|
|
|
|
|
|
|
|
|
|
def build_fixed_fields():
|
|
|
|
return [
|
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-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-03 20:49:24 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def build_stream_field():
|
|
|
|
fields = []
|
|
|
|
for field_builder in [
|
|
|
|
build_header_fields,
|
|
|
|
build_fixed_fields
|
|
|
|
]:
|
|
|
|
for field in field_builder():
|
|
|
|
fields.append(field)
|
|
|
|
return StreamField(fields)
|