Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements #173

Merged
merged 17 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 62 additions & 4 deletions home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@


class HeadingBlock(blocks.StructBlock):
size = blocks.ChoiceBlock(
choices=[
("text-5xl", "h1"),
("text-4xl", "h2"),
("text-3xl", "h3"),
("text-2xl", "h4"),
("text-xl", "h5"),
("text-lg", "h6"),
],
icon="title",
)
heading = blocks.CharBlock(max_length=255, class_name="heading-blog")

def __str__(self):
Expand All @@ -40,6 +51,23 @@ class Meta:
template = "blocks/heading.html"


class ListBlock(blocks.StructBlock):
size = blocks.ChoiceBlock(
choices=[
("circle", "unordered list"),
("decimal", "ordered list"),
("none", "unstyled"),
]
)
text = blocks.RichTextBlock(features=["ul"], icon="list-ol")

def __str__(self):
return self.text

class Meta:
template = "blocks/list.html"


class TextWithHeadingBlock(blocks.StructBlock):
heading = blocks.CharBlock(max_length=255, class_name="heading-blog")
text = blocks.TextBlock()
Expand Down Expand Up @@ -169,18 +197,48 @@ class Meta:
template = "blocks/text-image-heading.html"


class CustomTableBlock(TableBlock):
class Meta:
template = "blocks/table.html"


class CustomCaption(blocks.StructBlock):
text = blocks.TextBlock()

class Meta:
template = "blocks/caption.html"


class BaseStreamBlock(StreamBlock):
heading = HeadingBlock()
paragraph = blocks.CharBlock(max_length=255)
heading = HeadingBlock(label="Heading", icon="h1")
richtext = blocks.RichTextBlock(
max_length=10000,
features=[
"embed",
"bold",
"italic",
"link",
"superscript",
"subscript",
"strikethrough",
"code",
"hr",
],
label="Rich Text",
icon="title",
)
list = ListBlock(label="List", icon="list-ol")
paragraph = blocks.TextBlock(max_length=10000)
html = blocks.RawHTMLBlock(icon="code", label="Raw HTML")
image = ImageChooserBlock()
caption = CustomCaption()
text_with_heading = TextHeadingImageBlock()
text_with_heading_and_right_image = TextWithHeadingWithRightImageBlock()
text_with_heading_and_left_image = TextWithHeadingWithLeftImageBlock()
right_image_left_text = RightImageLeftTextBlock()
left_image_right_text = LeftImageRightTextBlock()
left_quote_right_image = QuoteLeftImageBlock()
left_quote_right_image = QuoteLeftImageBlock(icon="openquote")
video_embed = VideoEmbed()
table = TableBlock()
table = CustomTableBlock()
code_block = CodeBlock()
rich_text = RichTextBlock()
182 changes: 182 additions & 0 deletions home/migrations/0018_alter_generalpage_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Generated by Django 4.1.13 on 2023-12-29 06:35

from django.db import migrations
import wagtail.blocks
import wagtail.contrib.table_block.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):
dependencies = [
("home", "0017_generalpage_generaltag_generalpage_tags"),
]

operations = [
migrations.AlterField(
model_name="generalpage",
name="content",
field=wagtail.fields.StreamField(
[
(
"heading",
wagtail.blocks.StructBlock(
[
(
"size",
wagtail.blocks.ChoiceBlock(
choices=[
("text-5xl", "h1"),
("text-4xl", "h2"),
("text-3xl", "h3"),
("text-2xl", "h4"),
("text-xl", "h5"),
("text-lg", "h6"),
],
icon="title",
),
),
(
"heading",
wagtail.blocks.CharBlock(
class_name="heading-blog", max_length=255
),
),
],
class_name="full",
),
),
("subheading", wagtail.blocks.CharBlock(class_name="full")),
("paragraph", wagtail.blocks.RichTextBlock(class_name="full")),
("HTML", wagtail.blocks.RawHTMLBlock(class_name="full")),
("image", wagtail.images.blocks.ImageChooserBlock()),
(
"text_with_heading",
wagtail.blocks.StructBlock(
[
(
"size",
wagtail.blocks.ChoiceBlock(
choices=[
("text-5xl", "h1"),
("text-4xl", "h2"),
("text-3xl", "h3"),
("text-2xl", "h4"),
("text-xl", "h5"),
("text-lg", "h6"),
],
icon="title",
),
),
(
"heading",
wagtail.blocks.CharBlock(
class_name="heading-blog", max_length=255
),
),
],
class_name="full",
),
),
(
"text_heading_image",
wagtail.blocks.StructBlock(
[
("heading", wagtail.blocks.CharBlock(max_length=255)),
("text", wagtail.blocks.TextBlock()),
("image", wagtail.images.blocks.ImageChooserBlock()),
],
class_name="full",
),
),
(
"video_embed",
wagtail.blocks.StructBlock(
[
("heading", wagtail.blocks.CharBlock(max_length=255)),
("text", wagtail.blocks.TextBlock()),
],
class_name="full",
),
),
(
"table",
wagtail.contrib.table_block.blocks.TableBlock(
class_name="full"
),
),
(
"code_block",
wagtail.blocks.StructBlock(
[
(
"language",
wagtail.blocks.ChoiceBlock(
choices=[
("Python", "python"),
("Markup", "html"),
("CSS", "css"),
("Clojure", "clojure"),
("Bash", "shell"),
("Django", "django"),
("Jinja2", "jinja2"),
("Docker", "dockerfile"),
("Git", "git"),
("GraphQL", "graphql"),
("Handlebars", "handlebars"),
(".ignore", "gitignore"),
("JSON", "json"),
("JSON5", "json5"),
("Markdown", "md"),
("Markdown", "md"),
("React JSX", "jsx"),
("React TSX", "tsx"),
("SASS", "sass"),
("SCSS", "scss"),
("TypeScript", "ts"),
("vim", "vim"),
]
),
),
(
"caption",
wagtail.blocks.CharBlock(
blank=True, max_length=255
),
),
(
"page",
wagtail.blocks.CharBlock(
blank=True, max_length=255
),
),
(
"code",
wagtail.blocks.TextBlock(
blank=True, max_length=1000
),
),
],
class_name="full",
),
),
(
"quote_block",
wagtail.blocks.StructBlock(
[
("text", wagtail.blocks.CharBlock(max_length=255)),
(
"attribution",
wagtail.blocks.CharBlock(max_length=255),
),
],
class_name="full",
),
),
],
blank=True,
null=True,
use_json_field=None,
),
),
]
1 change: 0 additions & 1 deletion home/puput_migrations/0003_alter_entrypage_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Migration(migrations.Migration):

dependencies = [
('puput', '0002_entrypage_markdown_body'),
]
Expand Down
Loading
Loading