diff --git a/project/common/fields.py b/project/common/fields.py index 7f508d1..332a7ec 100644 --- a/project/common/fields.py +++ b/project/common/fields.py @@ -2,11 +2,27 @@ from wagtail.wagtailcore.fields import StreamField from wagtail.wagtailcore import blocks -def build_stream_field(): - return StreamField([ - ('h1', blocks.CharBlock(classname="h1", label="H1")), - ('h2', blocks.CharBlock(classname="h2", label="H2")), +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 [ + ('list', blocks.ListBlock(blocks.CharBlock(label="List Item"), label="list-ul")), ('paragraph', blocks.RichTextBlock()), ('raw_html', blocks.RawHTMLBlock(label="Raw HTML")), - ('list', blocks.ListBlock(blocks.CharBlock(label="List Item"))) - ]) + ('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')), + ] + + +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) diff --git a/project/settings.py b/project/settings.py index 3b369fa..fd55db5 100755 --- a/project/settings.py +++ b/project/settings.py @@ -31,7 +31,7 @@ INSTALLED_APPS = [ 'wagtail.contrib.settings', "wagtail.contrib.table_block", - + 'wagtail.contrib.wagtailstyleguide', 'modelcluster', 'taggit', diff --git a/templates/blocks/secret.html b/templates/blocks/secret.html new file mode 100644 index 0000000..ab27714 --- /dev/null +++ b/templates/blocks/secret.html @@ -0,0 +1,10 @@ +{% load wagtailcore_tags %} + + +
+
+ {{ value }} +
+
diff --git a/templates/projects/project_page.html b/templates/projects/project_page.html index 00674f0..a29422e 100644 --- a/templates/projects/project_page.html +++ b/templates/projects/project_page.html @@ -9,9 +9,9 @@

- Updated: {{ page.date|datetime }} + Updated: {{ page.date }}

- {{ page.body|richtext }} + {% include_block page.body %}