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

372 Add Image Card Blocks #381

Merged
merged 2 commits into from
Apr 3, 2024
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
20 changes: 20 additions & 0 deletions home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,25 @@ class Meta:
template = "blocks/caption.html"


class VerticalImageCardBlock(blocks.StreamBlock):
images = blocks.StructBlock(
[
("image", ImageChooserBlock(required=True, help_text="size: 800X450px")),
("caption", CustomCaption()),
(
"description",
blocks.CharBlock(
max_length=300, required=False, help_text="300 characters limit"
),
),
("link", blocks.URLBlock(required=False)),
]
)

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


class RichTextBlock(blocks.StructBlock):
text = blocks.RichTextBlock(
max_length=10000,
Expand Down Expand Up @@ -224,3 +243,4 @@ class BaseStreamBlock(blocks.StreamBlock):
video_embed = VideoEmbed()
table = CustomTableBlock()
code_block = CodeBlock()
vertical_image_cards = VerticalImageCardBlock()
304 changes: 304 additions & 0 deletions home/migrations/0028_alter_generalpage_content_vert_image_card.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
# Generated by Django 4.1.13 on 2024-04-03 21:30
from __future__ import annotations

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

import home.blocks


class Migration(migrations.Migration):
dependencies = [
("home", "0027_alter_generalpage_content_optional_fields"),
]

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
),
),
],
icon="h1",
label="Heading",
),
),
(
"rich_text",
wagtail.blocks.StructBlock(
[
(
"text",
wagtail.blocks.RichTextBlock(
features=[
"embed",
"bold",
"italic",
"link",
"superscript",
"subscript",
"strikethrough",
"code",
"hr",
],
icon="title",
label="Rich Text",
max_length=10000,
),
)
]
),
),
(
"list",
wagtail.blocks.StructBlock(
[
(
"size",
wagtail.blocks.ChoiceBlock(
choices=[
("circle", "unordered list"),
("decimal", "ordered list"),
("none", "unstyled"),
]
),
),
(
"text",
wagtail.blocks.RichTextBlock(
features=["ul"], icon="list-ol"
),
),
],
icon="list-ol",
label="List",
),
),
("paragraph", wagtail.blocks.TextBlock(max_length=10000)),
(
"html",
wagtail.blocks.RawHTMLBlock(icon="code", label="Raw HTML"),
),
("image", wagtail.images.blocks.ImageChooserBlock()),
(
"caption",
wagtail.blocks.StructBlock(
[("text", wagtail.blocks.TextBlock())]
),
),
(
"text_with_heading",
wagtail.blocks.StructBlock(
[
(
"heading",
wagtail.blocks.CharBlock(
class_name="heading-blog", max_length=255
),
),
("text", wagtail.blocks.TextBlock()),
]
),
),
(
"text_with_heading_and_image",
wagtail.blocks.StructBlock(
[
(
"heading",
wagtail.blocks.CharBlock(
max_length=255, required=False
),
),
("text", wagtail.blocks.TextBlock(required=False)),
("image", wagtail.images.blocks.ImageChooserBlock()),
]
),
),
(
"text_with_heading_and_right_image",
wagtail.blocks.StructBlock(
[
(
"heading",
wagtail.blocks.CharBlock(
class_name="heading-blog",
max_length=255,
required=False,
),
),
("text", wagtail.blocks.TextBlock()),
("image", wagtail.images.blocks.ImageChooserBlock()),
]
),
),
(
"text_with_heading_and_left_image",
wagtail.blocks.StructBlock(
[
(
"heading",
wagtail.blocks.CharBlock(
class_name="blog",
max_length=255,
required=False,
),
),
("text", wagtail.blocks.TextBlock()),
("image", wagtail.images.blocks.ImageChooserBlock()),
]
),
),
(
"left_quote_right_image",
wagtail.blocks.StructBlock(
[
("quote", wagtail.blocks.TextBlock()),
("byline", wagtail.blocks.CharBlock(max_length=255)),
("image", wagtail.images.blocks.ImageChooserBlock()),
],
icon="openquote",
),
),
(
"video_embed",
wagtail.blocks.StructBlock(
[
("heading", wagtail.blocks.CharBlock(max_length=255)),
("text", wagtail.blocks.TextBlock()),
]
),
),
("table", home.blocks.CustomTableBlock()),
(
"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
),
),
]
),
),
(
"vertical_image_cards",
wagtail.blocks.StreamBlock(
[
(
"images",
wagtail.blocks.StructBlock(
[
(
"image",
wagtail.images.blocks.ImageChooserBlock(
help_text="size: 800X450px",
required=True,
),
),
(
"caption",
wagtail.blocks.StructBlock(
[
(
"text",
wagtail.blocks.TextBlock(),
)
]
),
),
(
"description",
wagtail.blocks.CharBlock(
help_text="300 characters limit",
max_length=300,
required=False,
),
),
(
"link",
wagtail.blocks.URLBlock(required=False),
),
]
),
)
]
),
),
],
blank=True,
null=True,
use_json_field=True,
verbose_name="StreamField Body",
),
),
]
Loading