From 2d8732c77bf5e321fb447cb507be8df4c3052dd2 Mon Sep 17 00:00:00 2001 From: Jonathan DeMasi Date: Thu, 12 Mar 2020 22:24:37 -0600 Subject: additional rtf formatting options' --- blog/migrations/0011_auto_20200313_0421.py | 24 ++++++++++++++++++++++++ blog/models.py | 9 ++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 blog/migrations/0011_auto_20200313_0421.py diff --git a/blog/migrations/0011_auto_20200313_0421.py b/blog/migrations/0011_auto_20200313_0421.py new file mode 100644 index 0000000..99e0540 --- /dev/null +++ b/blog/migrations/0011_auto_20200313_0421.py @@ -0,0 +1,24 @@ +# Generated by Django 3.0.3 on 2020-03-13 04:21 + +from django.db import migrations +import wagtail.contrib.table_block.blocks +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.documents.blocks +import wagtail.embeds.blocks +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0010_auto_20200310_1719'), + ] + + operations = [ + migrations.AlterField( + model_name='blogpost', + name='body', + field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock(features=['bold', 'italic', 'code', 'strikethrough', 'superscript', 'subscript', 'h2', 'h3', 'h4', 'h5', 'ol', 'ul', 'blockquote', 'hr', 'embed', 'link', 'document-link', 'image'])), ('image', wagtail.images.blocks.ImageChooserBlock()), ('page', wagtail.core.blocks.PageChooserBlock()), ('document', wagtail.documents.blocks.DocumentChooserBlock()), ('media', wagtail.embeds.blocks.EmbedBlock()), ('html', wagtail.core.blocks.RawHTMLBlock(label='Raw HTML')), ('code', wagtail.core.blocks.StructBlock([('language', wagtail.core.blocks.ChoiceBlock(choices=[('bash', 'Bash/Shell'), ('css', 'CSS'), ('diff', 'diff'), ('html', 'HTML'), ('javascript', 'Javascript'), ('json', 'JSON'), ('python', 'Python'), ('scss', 'SCSS'), ('yaml', 'YAML')], help_text='Coding language', identifier='language', label='Language')), ('code', wagtail.core.blocks.TextBlock(identifier='code', label='Code'))], label='Code')), ('table', wagtail.contrib.table_block.blocks.TableBlock(template='blog/table_template.html'))]), + ), + ] diff --git a/blog/models.py b/blog/models.py index 03667c5..973d69b 100644 --- a/blog/models.py +++ b/blog/models.py @@ -18,6 +18,13 @@ from wagtail.contrib.table_block.blocks import TableBlock from taggit.models import TaggedItemBase from wagtail.snippets.models import register_snippet +# RTF formatting options. Thanks, Ethan! :-) +features = [ + 'bold', 'italic', 'code', 'strikethrough', 'superscript', 'subscript', + 'h2', 'h3', 'h4', 'h5', 'ol', 'ul', 'blockquote', 'hr', 'embed', 'link', + 'document-link', 'image' +] + class BlogIndexPage(Page): intro = models.CharField(max_length=500) @@ -62,7 +69,7 @@ class BlogPost(Page): body = StreamField( [ ('heading', blocks.CharBlock(classname="full title")), - ('paragraph', blocks.RichTextBlock()), + ('paragraph', blocks.RichTextBlock(features=features)), ('image', ImageChooserBlock()), ('page', blocks.PageChooserBlock()), ('document', DocumentChooserBlock()), -- cgit v1.2.3