From 9b78a1917f8d0d3b456ca56410c60719b3ed1f26 Mon Sep 17 00:00:00 2001 From: Christophe Boulanger Date: Fri, 17 Feb 2023 11:01:17 +0100 Subject: [PATCH 1/2] MWEBTUBA : Add new section : imio.smartweb.SectionExternalContent (Manage embeded contents) --- CHANGES.rst | 1 + src/imio/smartweb/core/contents/__init__.py | 4 +++ .../core/contents/sections/configure.zcml | 1 + .../sections/external_content/__init__.py | 0 .../sections/external_content/configure.zcml | 14 ++++++++ .../sections/external_content/content.py | 32 +++++++++++++++++ .../sections/external_content/view.pt | 31 ++++++++++++++++ .../sections/external_content/views.py | 31 ++++++++++++++++ src/imio/smartweb/core/permissions.zcml | 6 ++++ .../core/profiles/default/metadata.xml | 2 +- .../core/profiles/default/rolemap.xml | 6 ++++ .../smartweb/core/profiles/default/types.xml | 1 + .../default/types/imio.smartweb.Page.xml | 1 + .../types/imio.smartweb.PortalPage.xml | 1 + .../default/types/imio.smartweb.Procedure.xml | 1 + .../imio.smartweb.SectionExternalContent.xml | 36 +++++++++++++++++++ .../core/profiles/default/workflows.xml | 1 + src/imio/smartweb/core/tests/test_sections.py | 34 ++++++++++++++++++ .../smartweb/core/upgrades/configure.zcml | 18 ++++++++++ .../profiles/1037_to_1038/rolemap.xml | 12 +++++++ .../upgrades/profiles/1037_to_1038/types.xml | 4 +++ .../1037_to_1038/types/imio.smartweb.Page.xml | 11 ++++++ .../types/imio.smartweb.PortalPage.xml | 11 ++++++ .../types/imio.smartweb.Procedure.xml | 11 ++++++ .../imio.smartweb.SectionExternalContent.xml | 36 +++++++++++++++++++ .../profiles/1037_to_1038/workflows.xml | 6 ++++ 26 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 src/imio/smartweb/core/contents/sections/external_content/__init__.py create mode 100644 src/imio/smartweb/core/contents/sections/external_content/configure.zcml create mode 100644 src/imio/smartweb/core/contents/sections/external_content/content.py create mode 100644 src/imio/smartweb/core/contents/sections/external_content/view.pt create mode 100644 src/imio/smartweb/core/contents/sections/external_content/views.py create mode 100644 src/imio/smartweb/core/profiles/default/types/imio.smartweb.SectionExternalContent.xml create mode 100644 src/imio/smartweb/core/upgrades/profiles/1037_to_1038/rolemap.xml create mode 100644 src/imio/smartweb/core/upgrades/profiles/1037_to_1038/types.xml create mode 100644 src/imio/smartweb/core/upgrades/profiles/1037_to_1038/types/imio.smartweb.Page.xml create mode 100644 src/imio/smartweb/core/upgrades/profiles/1037_to_1038/types/imio.smartweb.PortalPage.xml create mode 100644 src/imio/smartweb/core/upgrades/profiles/1037_to_1038/types/imio.smartweb.Procedure.xml create mode 100644 src/imio/smartweb/core/upgrades/profiles/1037_to_1038/types/imio.smartweb.SectionExternalContent.xml create mode 100644 src/imio/smartweb/core/upgrades/profiles/1037_to_1038/workflows.xml diff --git a/CHANGES.rst b/CHANGES.rst index 01dee714..a2fbfec2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -168,6 +168,7 @@ Changelog [thomlamb] - Fixed faceted map +- MWEBTUBA : Add new section : imio.smartweb.SectionExternalContent (Manage embeded contents) [boulch] - WEB-3837 : Can define specific news to get (instead of all news from news folders) diff --git a/src/imio/smartweb/core/contents/__init__.py b/src/imio/smartweb/core/contents/__init__.py index f0fcb11d..1ad3257e 100644 --- a/src/imio/smartweb/core/contents/__init__.py +++ b/src/imio/smartweb/core/contents/__init__.py @@ -14,6 +14,10 @@ from .sections.collection.content import ISectionCollection, SectionCollection # NOQA from .sections.contact.content import ISectionContact, SectionContact # NOQA from .sections.events.content import ISectionEvents, SectionEvents # NOQA +from .sections.external_content.content import ( + ISectionExternalContent, + SectionExternalContent, +) # NOQA from .sections.files.content import ISectionFiles, SectionFiles # NOQA from .sections.gallery.content import ISectionGallery, SectionGallery # NOQA from .sections.html.content import ISectionHTML, SectionHTML # NOQA diff --git a/src/imio/smartweb/core/contents/sections/configure.zcml b/src/imio/smartweb/core/contents/sections/configure.zcml index 8a28b492..c6fb2ed6 100644 --- a/src/imio/smartweb/core/contents/sections/configure.zcml +++ b/src/imio/smartweb/core/contents/sections/configure.zcml @@ -5,6 +5,7 @@ + diff --git a/src/imio/smartweb/core/contents/sections/external_content/__init__.py b/src/imio/smartweb/core/contents/sections/external_content/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/imio/smartweb/core/contents/sections/external_content/configure.zcml b/src/imio/smartweb/core/contents/sections/external_content/configure.zcml new file mode 100644 index 00000000..f8b714d8 --- /dev/null +++ b/src/imio/smartweb/core/contents/sections/external_content/configure.zcml @@ -0,0 +1,14 @@ + + + + + diff --git a/src/imio/smartweb/core/contents/sections/external_content/content.py b/src/imio/smartweb/core/contents/sections/external_content/content.py new file mode 100644 index 00000000..cd831bf9 --- /dev/null +++ b/src/imio/smartweb/core/contents/sections/external_content/content.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +from imio.smartweb.common.config import DESCRIPTION_MAX_LENGTH +from imio.smartweb.core.contents.sections.base import ISection +from imio.smartweb.core.contents.sections.base import Section +from imio.smartweb.locales import SmartwebMessageFactory as _ +from zope.interface import implementer +from zope import schema + + +class ISectionExternalContent(ISection): + """Marker interface and Dexterity Python Schema for SectionVideo""" + + description = schema.Text( + title=_("Description"), + description=_( + "Use **text** to set text in bold. Limited to ${max} characters.", + mapping={"max": DESCRIPTION_MAX_LENGTH}, + ), + max_length=DESCRIPTION_MAX_LENGTH, + required=False, + ) + + external_content_url = schema.URI( + title=_("External content url"), + required=True, + ) + + +@implementer(ISectionExternalContent) +class SectionExternalContent(Section): + """SectionVideo class""" diff --git a/src/imio/smartweb/core/contents/sections/external_content/view.pt b/src/imio/smartweb/core/contents/sections/external_content/view.pt new file mode 100644 index 00000000..cea0469e --- /dev/null +++ b/src/imio/smartweb/core/contents/sections/external_content/view.pt @@ -0,0 +1,31 @@ + + + + + + +
+ + + +

+ +

+ +
+ + + + + diff --git a/src/imio/smartweb/core/contents/sections/external_content/views.py b/src/imio/smartweb/core/contents/sections/external_content/views.py new file mode 100644 index 00000000..d7a4c100 --- /dev/null +++ b/src/imio/smartweb/core/contents/sections/external_content/views.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from embeddify import Embedder +from embeddify import Plugin +from imio.smartweb.core.contents.sections.views import SectionView +from imio.smartweb.locales import SmartwebMessageFactory as _ + + +class ExternalContentView(SectionView): + def get_embed_external_content(self, width="100%", height=600): + plugins = [EaglebePlugin(), UnknowServicePlugin()] + plugin_config = { + "eaglebeplugin": {"width": width}, + "unknowserviceplugin": {"width": width}, + } + embedder = Embedder(plugins=plugins, plugin_config=plugin_config) + url = self.context.external_content_url + return embedder(url, config={"width": width}) + + +class EaglebePlugin(Plugin): + def __call__(self, parts, config={}): + if "app.eaglebe.com" in parts.netloc: + return f'