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

Ajout/Amélioration de composants : Mise en avant, Mise en exergue #147

Merged
merged 10 commits into from
Jun 17, 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
18,414 changes: 18,414 additions & 0 deletions blog/migrations/0017_alter_blogentrypage_body_alter_blogindexpage_body_and_more.py

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""

import os
import sys
from pathlib import Path

import dj_database_url
Expand All @@ -39,6 +40,12 @@

HOST_URL = os.getenv("HOST_URL", "localhost")

INTERNAL_IPS = [
"127.0.0.1",
]

TESTING = "test" in sys.argv

# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -72,11 +79,12 @@
"blog",
]

# Only add these on a dev machine
if DEBUG and "localhost" in HOST_URL:
# Only add these on a dev machine, outside of tests
if not TESTING and DEBUG and "localhost" in HOST_URL:
INSTALLED_APPS += [
"django_extensions",
"wagtail.contrib.styleguide",
"debug_toolbar",
]

MIDDLEWARE = [
Expand All @@ -91,6 +99,24 @@
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
]

# Only add this on a dev machine, outside of tests
if not TESTING and DEBUG and "localhost" in HOST_URL:
MIDDLEWARE += [
"debug_toolbar.middleware.DebugToolbarMiddleware",
]

# Don't show the toolbar on admin previews
def show_toolbar(request):
request.META["wsgi.multithread"] = True
request.META["wsgi.multiprocess"] = True
excluded_urls = ["/pages/preview/", "/pages/preview_loading/", "/edit/preview/"]
excluded = any(request.path.endswith(url) for url in excluded_urls)
return DEBUG and not excluded

DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": show_toolbar,
}

ROOT_URLCONF = "config.urls"

TEMPLATES = [
Expand Down
4 changes: 4 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
path("", include("content_manager.urls")),
prefix_default_language=False,
)

# Only add this on a dev machine, outside of tests
if not settings.TESTING and settings.DEBUG and "localhost" in settings.HOST_URL:
urlpatterns += (path("__debug__/", include("debug_toolbar.urls")),)
43 changes: 39 additions & 4 deletions content_manager/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
HEADING_CHOICES,
HORIZONTAL_CARD_IMAGE_RATIOS,
LEVEL_CHOICES,
LIMITED_RICHTEXTFIELD_FEATURES,
LINK_ICON_CHOICES,
LINK_SIZE_CHOICES,
MEDIA_WIDTH_CHOICES,
TEXT_SIZE_CHOICES,
)
from content_manager.widgets import DsfrIconPickerWidget

Expand Down Expand Up @@ -254,7 +256,7 @@ class CardBlock(blocks.StructBlock):
default="h3",
help_text=_("Adapt to the page layout. Defaults to heading 3."),
)
description = blocks.TextBlock(label=_("Content"), help_text=_("Can contain HTML."), required=False)
description = blocks.RichTextBlock(label=_("Content"), features=LIMITED_RICHTEXTFIELD_FEATURES, required=False)
image = ImageChooserBlock(label=_("Image"), required=False)
image_ratio = blocks.ChoiceBlock(
label=_("Image ratio"),
Expand Down Expand Up @@ -360,7 +362,7 @@ class TileBlock(blocks.StructBlock):
default="h3",
help_text=_("Adapt to the page layout. Defaults to heading 3."),
)
description = blocks.TextBlock(label=_("Content"), help_text=_("Can contain HTML."), required=False)
description = blocks.RichTextBlock(label=_("Content"), features=LIMITED_RICHTEXTFIELD_FEATURES, required=False)
image = ImageChooserBlock(label=_("Image"), help_text=_("Prefer SVG files."), required=False)
link = LinkWithoutLabelBlock(
label=_("Link"),
Expand Down Expand Up @@ -421,14 +423,44 @@ class Meta:


class CalloutBlock(blocks.StructBlock):
title = blocks.CharBlock(label=_("Callout title"), required=False)
text = blocks.TextBlock(label=_("Callout text"), required=False)
title = blocks.CharBlock(label=_("Title"), required=False)
heading_tag = blocks.ChoiceBlock(
label=_("Heading level"),
choices=HEADING_CHOICES,
default="h3",
help_text=_("Adapt to the page layout. Defaults to heading 3."),
)
icon_class = IconPickerBlock(label=_("Icon"), required=False)

text = blocks.RichTextBlock(label=_("Content"), features=LIMITED_RICHTEXTFIELD_FEATURES, required=False)
button = ButtonBlock(label=_("Button"), required=False)
color = blocks.ChoiceBlock(
label=_("Color"),
choices=COLOR_CHOICES_ILLUSTRATION,
required=False,
)

class Meta:
icon = "info-circle"
template = "content_manager/blocks/callout.html"


class HighlightBlock(blocks.StructBlock):
text = blocks.RichTextBlock(label=_("Content"), features=LIMITED_RICHTEXTFIELD_FEATURES)
color = blocks.ChoiceBlock(
label=_("Color"),
choices=COLOR_CHOICES_ILLUSTRATION,
required=False,
)
size = blocks.ChoiceBlock(
label=_("Size"),
choices=TEXT_SIZE_CHOICES,
required=False,
)

class Meta:
icon = "info-circle"
template = "content_manager/blocks/highlight.html"


class IframeBlock(blocks.StructBlock):
Expand Down Expand Up @@ -633,6 +665,8 @@ class CommonStreamBlock(blocks.StreamBlock):
image = ImageBlock(label=_("Image"))
video = VideoBlock(label=_("Video"))
transcription = TranscriptionBlock(label=_("Transcription"))
callout = CalloutBlock(label=_("Callout"), group=_("DSFR components"))
highlight = HighlightBlock(label=_("Highlight"), group=_("DSFR components"))
quote = QuoteBlock(label=_("Quote"), group=_("DSFR components"))
text_cta = TextAndCTA(label=_("Text and call to action"))
link = SingleLinkBlock(label=_("Single link"))
Expand Down Expand Up @@ -735,6 +769,7 @@ class Meta:
("imageandtext", ImageAndTextBlock(label=_("Image and text"))),
("alert", AlertBlock(label=_("Alert message"))),
("callout", CalloutBlock(label=_("Callout"), group=_("DSFR components"))),
("highlight", HighlightBlock(label=_("Highlight"), group=_("DSFR components"))),
("quote", QuoteBlock(label=_("Quote"), group=_("DSFR components"))),
("video", VideoBlock(label=_("Video"))),
("transcription", TranscriptionBlock(label=_("Transcription"))),
Expand Down
6 changes: 6 additions & 0 deletions content_manager/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@
("", _("Medium")),
("fr-content-media--lg", _("Large")),
]

TEXT_SIZE_CHOICES = [
("fr-text--sm", _("Small")),
("", _("Medium")),
("fr-text--lg", _("Large")),
]
Binary file modified content_manager/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Loading
Loading