# HG changeset patch # User Thierry Florac # Date 1527228367 -7200 # Node ID 566d98116bf2f89f459249b8d04c3017db50f0f8 # Parent bca2dd39ef7f1c4a30d9279771afd873e87f0ad2 Add renderers to video paragraphs diff -r bca2dd39ef7f -r 566d98116bf2 src/pyams_default_theme/component/video/__init__.py --- a/src/pyams_default_theme/component/video/__init__.py Fri May 25 08:05:52 2018 +0200 +++ b/src/pyams_default_theme/component/video/__init__.py Fri May 25 08:06:07 2018 +0200 @@ -16,5 +16,49 @@ # import standard library # import interfaces +from pyams_content.component.video.interfaces import IExternalVideoParagraph, IExternalVideoRenderer +from pyams_content.features.renderer.interfaces import IContentRenderer +from pyams_skin.layer import IPyAMSLayer # import packages +from pyams_content.features.renderer.skin import BaseContentRenderer +from pyams_template.template import template_config +from pyams_utils.adapter import adapter_config +from pyams_utils.registry import get_current_registry + +from pyams_default_theme import _ + + +# +# External video paragraph default renderer +# + +@adapter_config(name='default', context=(IExternalVideoParagraph, IPyAMSLayer), provides=IContentRenderer) +@template_config(template='templates/video-default.pt', layer=IPyAMSLayer) +class ExternalVideoParagraphDefaultRenderer(BaseContentRenderer): + """external video paragraph default renderer""" + + label = _("Default video renderer") + + i18n_context_attrs = ('title', 'body', 'description') + + video_renderer = None + + def __init__(self, context, request): + super(ExternalVideoParagraphDefaultRenderer, self).__init__(context, request) + provider = context.get_provider() + if provider is not None: + registry = get_current_registry() + self.video_renderer = registry.queryMultiAdapter((context.settings, request), IExternalVideoRenderer) + + def update(self): + super(ExternalVideoParagraphDefaultRenderer, self).update() + renderer = self.video_renderer + if renderer is not None: + renderer.update() + + def render_video(self): + renderer = self.video_renderer + if not renderer: + return '' + return renderer.render() diff -r bca2dd39ef7f -r 566d98116bf2 src/pyams_default_theme/component/video/templates/video-default.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/video/templates/video-default.pt Fri May 25 08:06:07 2018 +0200 @@ -0,0 +1,7 @@ +

title

+
body
+
Description
+