Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9b705c9
Remove temporary containers
mgax Apr 15, 2025
e56ecfa
Fix `delete_local_renditions`
mgax Apr 15, 2025
44f9aa5
Fix newsletter index template
mgax Apr 15, 2025
6ba9de1
Add `wagtail-newsletter` dependency
mgax Apr 15, 2025
287329a
Set up NewsletterPage with NewsletterPageMixin
mgax Apr 15, 2025
c6d7cae
New page fields
mgax Apr 16, 2025
3f06a77
Remove old newsletter page template
mgax Apr 16, 2025
b61d610
Migrate the existing pages and delete old fields
mgax Apr 16, 2025
d345e4f
Newsletter MJML
mgax Apr 28, 2025
d8f8523
Import archival newsletter editions
mgax Apr 28, 2025
5cea0cb
Split migration into two files
mgax May 1, 2025
dcd056d
Split off another migration
mgax May 1, 2025
f541765
Fix migration of images in the body
mgax May 1, 2025
e4b19a3
fixup! Fix migration of images in the body
Stormheg May 9, 2025
d00d9b0
MR fixes
mgax May 26, 2025
c65e242
Include content inline with shadowrootmode=open
mgax May 26, 2025
bec1ad0
Hide irrelevant content when rendering for web
mgax May 26, 2025
c1f1577
Single command to import newer editions
mgax May 26, 2025
c96ea2d
Fix import script to work for all issues
mgax May 26, 2025
d924532
Merge branch 'main' into newsletter
mgax Jun 3, 2025
efb3377
Merge branch 'main' into newsletter
mgax Sep 4, 2025
7b3548a
Bump `wagtail-newsletter` to version 0.2.3
mgax Sep 4, 2025
8e4fd65
Change button to select a page or enter a URL
mgax Sep 4, 2025
90293af
No space around paragraphs in accented text block
mgax Sep 4, 2025
5cdb68e
Add Mastodon and Bluesky social icons
mgax Sep 4, 2025
53e2404
Add some spacing before the footer
mgax Sep 4, 2025
4c670fb
Add links to recent TWiW editions
mgax Sep 4, 2025
adf364d
Remove workaround for injecting context
mgax Sep 4, 2025
ebc8471
Add 2025-09-05 TWiW edition
mgax Sep 5, 2025
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
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ help: ## ⁉️ - Display help comments for each make command
| sort

setup: build ## 🔨 - Set instance up
docker-compose run web django-admin migrate
docker-compose run web django-admin createcachetable
docker-compose run --rm web django-admin migrate
docker-compose run --rm web django-admin createcachetable

build: ## 🔨 - Build Docker container
bash -c "docker-compose build --build-arg UID=$$(id -u) --build-arg GID=$$(id -g)"
Expand All @@ -28,10 +28,10 @@ runserver: ## 🏃 - Run Django server
docker-compose exec web django-admin runserver 0.0.0.0:8000

superuser: ## 🔒 - Create superuser
docker-compose run web django-admin createsuperuser
docker-compose run --rm web django-admin createsuperuser

migrations: ## 🧳 - Make migrations
docker-compose run web django-admin makemigrations
docker-compose run --rm web django-admin makemigrations

migrate: ## 🧳 - Migrate
docker-compose run web django-admin migrate
docker-compose run --rm web django-admin migrate
2 changes: 1 addition & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def import_data(


def delete_local_renditions(c, local_database_name=LOCAL_DATABASE_NAME):
psql(c, "DELETE FROM images_rendition;")
psql(c, "DELETE FROM wagtailimages_rendition;")


#########
Expand Down
147 changes: 145 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ wagtail-font-awesome-svg = "~1.1"
wagtailmedia = "~0.16"
whitenoise = "~6.9"
django-redis = "~6.0"
wagtail-newsletter = {extras = ["mailchimp", "mrml"], version = "^0.2.3"}

[tool.poetry.group.dev.dependencies]
pre-commit = "4.3.0"
Expand Down
89 changes: 89 additions & 0 deletions wagtailio/newsletter/blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from django.core.exceptions import ValidationError

from wagtail.blocks import (
CharBlock,
PageChooserBlock,
StreamBlock,
StructBlock,
StructValue,
URLBlock,
)
from wagtail.blocks import RichTextBlock as WagtailRichTextBlock
from wagtail.images.blocks import ImageChooserBlock


NEWSLETTER_RICHTEXT_FEATURES = ["h2", "bold", "italic", "ol", "ul", "hr", "link"]


class HeadingBlock(CharBlock):
class Meta:
icon = "title"
form_classname = "title"
template = "newsletter/blocks/heading.mjml"
label = "Heading"


class RichTextBlock(WagtailRichTextBlock):
class Meta:
icon = "pilcrow"
template = "newsletter/blocks/rich_text.mjml"
label = "Rich Text"


class AccentRichTextBlock(WagtailRichTextBlock):
class Meta:
icon = "pilcrow"
template = "newsletter/blocks/accent_rich_text.mjml"
label = "Accent Rich Text"


class ImageBlock(ImageChooserBlock):
class Meta:
icon = "image"
template = "newsletter/blocks/image.mjml"
label = "Image"


class ButtonValue(StructValue):
@property
def link_url(self):
if self.get("url"):
return self.get("url")
elif self.get("page"):
return self.get("page").url
return None


class ButtonBlock(StructBlock):
text = CharBlock(required=True)
url = URLBlock(required=False, help_text="External URL to link to")
page = PageChooserBlock(required=False, help_text="Internal page to link to")

def clean(self, value):
cleaned_data = super().clean(value)
url = cleaned_data.get("url")
page = cleaned_data.get("page")

if not url and not page:
raise ValidationError(
"Please provide either a URL or select a page to link to."
)

if url and page:
raise ValidationError("Please provide either a URL or a page, not both.")

return cleaned_data

class Meta:
icon = "link"
template = "newsletter/blocks/button.mjml"
label = "Button"
value_class = ButtonValue


class NewsletterContentBlock(StreamBlock):
heading = HeadingBlock()
rich_text = RichTextBlock(features=NEWSLETTER_RICHTEXT_FEATURES)
accent_rich_text = AccentRichTextBlock(features=NEWSLETTER_RICHTEXT_FEATURES)
image = ImageBlock()
button = ButtonBlock()
Empty file.
Empty file.
Loading