Merge branch dev-dc
authorThierry Florac <thierry.florac@onf.fr>
Fri, 12 Oct 2018 10:28:46 +0200
changeset 181 97e8610cbabd
parent 177 610811d72a10 (diff)
parent 180 e5d91569642f (current diff)
child 182 f419b942f7f4
Merge branch dev-dc
src/pyams_default_theme/component/association/__init__.py
src/pyams_default_theme/component/association/templates/association-default.pt
src/pyams_default_theme/component/association/templates/association-viewlet.pt
src/pyams_default_theme/component/association/viewlet.py
src/pyams_default_theme/component/paragraph/templates/html-default.pt
--- a/src/pyams_default_theme/component/association/__init__.py	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/association/__init__.py	Fri Oct 12 10:28:46 2018 +0200
@@ -12,29 +12,25 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
-
-# import packages
 from persistent import Persistent
 from zope.interface import implementer
 from zope.location import Location
 from zope.schema.fieldproperty import FieldProperty
 
-# import interfaces
-from pyams_content.component.association.interfaces import IAssociationParagraph, IAssociationInfo, \
-    IAssociationContainer
+from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationInfo, \
+    IAssociationParagraph
 from pyams_content.component.extfile import IExtFile
-from pyams_content.component.links.interfaces import IInternalLink, IBaseLink
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.links.interfaces import IBaseLink, IInternalLink
+from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget
 from pyams_content.features.renderer.interfaces import IContentRenderer
 from pyams_content.features.renderer.skin import BaseContentRenderer
-from pyams_default_theme import _
 from pyams_default_theme.component.association.interfaces import IAssociationParagraphRemoteContentRendererSettings
 from pyams_skin.layer import IPyAMSLayer
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config, get_annotation_adapter
 
+from pyams_default_theme import _
+
 
 #
 # Associations paragraph default renderer
@@ -46,16 +42,11 @@
     """Associations paragraph default renderer"""
 
     label = _("Default associations renderer")
-    i18n_context_attrs = ('title', )
+    i18n_context_attrs = ('title',)
 
     links = None
     attachments = None
 
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
-        self.attachments = []
-        self.links = []
-
     def get_associations(self):
         yield from IAssociationContainer(self.context).get_visible_items(self.request)
 
@@ -65,12 +56,15 @@
 
     def update(self):
         super().update()
+        self.attachments = []
+        self.links = []
         for item in self.get_associations():
             if IExtFile.providedBy(item):
                 self.attachments.append(item)
             elif IBaseLink.providedBy(item):
                 self.links.append(item)
 
+
 #
 # Associations paragraph remote content renderer
 #
@@ -101,8 +95,9 @@
     """Associations container remote content renderer"""
 
     label = _("Include remote content")
+    weight = 10
 
-    i18n_context_attrs = ('title', )
+    i18n_context_attrs = ('title',)
     links = ()
 
     settings_interface = IAssociationParagraphRemoteContentRendererSettings
--- a/src/pyams_default_theme/component/association/templates/association-default.pt	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/association/templates/association-default.pt	Fri Oct 12 10:28:46 2018 +0200
@@ -1,4 +1,2 @@
-<i18n:var domain="pyams_default_theme">
-	<h3 tal:content="view.title">§ title</h3>
-		${structure:provider:pyams.association}
-</i18n:var>
+<h3 tal:content="view.title">§ title</h3>
+${structure:provider:pyams.associations}
--- a/src/pyams_default_theme/component/association/templates/association-viewlet.pt	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/association/templates/association-viewlet.pt	Fri Oct 12 10:28:46 2018 +0200
@@ -1,21 +1,33 @@
-<ul>
+<ul class="associations">
 	<li tal:repeat="link view.links">
-		<tal:var tal:define="link_info view.get_link_info(link);
-							 description i18n:link.description;">
-			<p>${structure:tales:html(description)}<br tal:condition="description">
+		<tal:var define="link_info view.get_link_info(link);
+						 description i18n:link.description;">
+			<p>
+				<tal:if condition="description">
+					${structure:tales:html(description)}
+					<br />
+				</tal:if
 				<a tal:define="href link.get_url(request);
 							   target None if href.startswith(request.application_url) else '_blank'"
-						       href="${href}" target="${target}">${link_info.user_title}</a>
+				   href="${href}" target="${target}">
+					${link_info.user_title}
+				</a>
 			</p>
 		</tal:var>
 	</li>
 	<li tal:repeat="item view.attachments">
-		<tal:var tal:define="item_info view.get_link_info(item);
-							 description i18n:item.description;
-							 data i18n:item.data">
-			<p>${structure:tales:html(description)}<br tal:condition="description">
+		<tal:var define="item_info view.get_link_info(item);
+						 description i18n:item.description;
+						 data i18n:item.data">
+			<p>
+				<tal:if condition="description">
+					${structure:tales:html(description)}
+					<br />
+				</tal:if>
 				<a tal:define="href_data tales:absolute_url(data);"
-						href="${href_data}">${item_info.user_title}</a>
+				   href="${href_data}" target="_blank">
+					${item_info.user_title}
+				</a>
 			</p>
 		</tal:var>
 	</li>
--- a/src/pyams_default_theme/component/association/viewlet.py	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/association/viewlet.py	Fri Oct 12 10:28:46 2018 +0200
@@ -22,7 +22,7 @@
 from pyams_viewlet.viewlet import ViewContentProvider, contentprovider_config
 
 
-@contentprovider_config(name='pyams.association', layer=IPyAMSUserLayer, view=Interface)
+@contentprovider_config(name='pyams.associations', layer=IPyAMSUserLayer, view=Interface)
 @template_config(template='templates/association-viewlet.pt', layer=IPyAMSUserLayer)
 class AssociationContentProvider(ViewContentProvider):
     """Association default content provider"""
--- a/src/pyams_default_theme/component/gallery/templates/renderer-default.pt	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/gallery/templates/renderer-default.pt	Fri Oct 12 10:28:46 2018 +0200
@@ -2,33 +2,19 @@
 	<tal:loop repeat="image context.get_visible_medias()">
 		<picture tal:define="image_data i18n:image.data;
 							 image_url tales:absolute_url(image_data);
-							 timestamp tales:timestamp(image);
-							 base_width 100 / 12;">
-			<!-- lg source -->
-			<source media="(min-width: 1200px)" sizes="12vw, 25vw, 50vw, 100vw"
-					tal:attributes="srcset string:${image_url}/++thumb++lg:w128?_=${timestamp} 128w,
-												  ${image_url}/++thumb++lg:w256?_=${timestamp} 256w,
-												  ${image_url}/++thumb++lg:w512?_=${timestamp} 512w,
-												  ${image_url}/++thumb++lg:w1200?_=${timestamp} 1200w" />
+							 timestamp tales:timestamp(image);">
+			<!-- xs source -->
+			<source media="(max-width: 767px)"
+					srcset="${image_url}/++thumb++w768?_=${timestamp}" />
+			<!-- sm source -->
+			<source media="(max-width: 991px)"
+					srcset="${image_url}/++thumb++w992?_=${timestamp}" />
 			<!-- md source -->
-			<source media="(min-width: 992px)" sizes="12vw, 25vw, 50vw, 100vw"
-					tal:attributes="srcset string:${image_url}/++thumb++md:w128?_=${timestamp} 128w,
-												  ${image_url}/++thumb++md:w256?_=${timestamp} 256w,
-												  ${image_url}/++thumb++md:w512?_=${timestamp} 512w,
-												  ${image_url}/++thumb++md:w992?_=${timestamp} 992w" />
-			<!-- sm source -->
-			<source media="(min-width: 768px)" sizes="12vw, 25vw, 50vw, 100vw"
-					tal:attributes="srcset string:${image_url}/++thumb++sm:w128?_=${timestamp} 128w,
-												  ${image_url}/++thumb++sm:w256?_=${timestamp} 256w,
-												  ${image_url}/++thumb++sm:w512?_=${timestamp} 512w,
-												  ${image_url}/++thumb++sm:w768?_=${timestamp} 768w,
-												  " />
-			<!-- xs source -->
-			<source media="(max-width: 767px)" sizes="12vw, 25vw, 50vw, 100vw"
-					tal:attributes="srcset string:${image_url}/++thumb++xs:w128?_=${timestamp} 128w,
-												  ${image_url}/++thumb++xs:w256?_=${timestamp} 256w,
-												  ${image_url}/++thumb++xs:w512?_=${timestamp} 512w,
-												  ${image_url}/++thumb++xs:w768?_=${timestamp} 768w" />
+			<source media="(max-width: 1199px)"
+					srcset="${image_url}/++thumb++w1200?_=${timestamp}" />
+			<!-- lg source -->
+			<source media="(min-width: 1200px)"
+					srcset="${image_url}/++thumb++w1600?_=${timestamp}" />
 			<!-- fallback image -->
 			<img style="width: 100%;"
 				 tal:attributes="alt i18n:image.alt_title; src image_url" />
--- a/src/pyams_default_theme/component/illustration/templates/illustration-default.pt	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/illustration/templates/illustration-default.pt	Fri Oct 12 10:28:46 2018 +0200
@@ -1,36 +1,7 @@
 <div class="text-center margin-y-5">
-	<picture tal:define="image view.data;
-						 image_url tales:absolute_url(image);
-						 timestamp tales:timestamp(image);
-						 base_width 100 / 12;">
-		<!-- lg source -->
-		<source media="(min-width: 1200px)" sizes="12vw, 25vw, 50vw, 100vw"
-				tal:attributes="srcset string:${image_url}/++thumb++lg:w128?_=${timestamp} 128w,
-											  ${image_url}/++thumb++lg:w256?_=${timestamp} 256w,
-											  ${image_url}/++thumb++lg:w512?_=${timestamp} 512w,
-											  ${image_url}/++thumb++lg:w1200?_=${timestamp} 1200w" />
-		<!-- md source -->
-		<source media="(min-width: 992px)" sizes="12vw, 25vw, 50vw, 100vw"
-				tal:attributes="srcset string:${image_url}/++thumb++md:w128?_=${timestamp} 128w,
-											  ${image_url}/++thumb++md:w256?_=${timestamp} 256w,
-											  ${image_url}/++thumb++md:w512?_=${timestamp} 512w,
-											  ${image_url}/++thumb++md:w992?_=${timestamp} 992w" />
-		<!-- sm source -->
-		<source media="(min-width: 768px)" sizes="12vw, 25vw, 50vw, 100vw"
-				tal:attributes="srcset string:${image_url}/++thumb++sm:w128?_=${timestamp} 128w,
-											  ${image_url}/++thumb++sm:w256?_=${timestamp} 256w,
-											  ${image_url}/++thumb++sm:w512?_=${timestamp} 512w,
-											  ${image_url}/++thumb++sm:w768?_=${timestamp} 768w,
-											  " />
-		<!-- xs source -->
-		<source media="(max-width: 767px)" sizes="12vw, 25vw, 50vw, 100vw"
-				tal:attributes="srcset string:${image_url}/++thumb++xs:w128?_=${timestamp} 128w,
-											  ${image_url}/++thumb++xs:w256?_=${timestamp} 256w,
-											  ${image_url}/++thumb++xs:w512?_=${timestamp} 512w,
-											  ${image_url}/++thumb++xs:w768?_=${timestamp} 768w" />
-		<!-- fallback image -->
-		<img style="width: 100%;"
-			 tal:attributes="alt alt; src image_url" />
-	</picture>
+	<tal:var define="image view.data"
+			 condition="image">
+		${structure:tales:picture(image, alt=view.alt_title)}
+	</tal:var>
 	<span tal:content="view.title">legend</span>
 </div>
--- a/src/pyams_default_theme/component/illustration/templates/illustration-left.pt	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/illustration/templates/illustration-left.pt	Fri Oct 12 10:28:46 2018 +0200
@@ -1,13 +1,15 @@
-<div class="pull-left margin-10" tal:condition="view.data">
+<div class="pull-left col-sm-12 col-md-6 col-lg-5 margin-10"
+	 tal:condition="view.data">
 	<a class="fancybox" data-toggle
 	   data-ams-fancybox-type="image"
 	   tal:omit-tag="not:view.settings.zoom_on_click"
-	   tal:define="thumbnails tales:thumbnails(view.data);
-				   target thumbnails.get_thumbnail('800x600');
-				   thumb thumbnails.get_thumbnail('300x200');"
+	   tal:define="image view.data;
+				   thumbnails tales:thumbnails(image);
+				   target thumbnails.get_thumbnail('800x600');"
 	   tal:attributes="href tales:absolute_url(target)">
-		<img tal:attributes="src tales:absolute_url(thumb);
-							 alt view.alt_title;" /><br />
+		<tal:if condition="image">
+			${structure:tales:picture(image, md_width=6, lg_width=5, alt=view.alt_title)}
+		</tal:if>
 		<span tal:content="view.title">legend</span>
 	</a><br />
 </div>
--- a/src/pyams_default_theme/component/illustration/templates/illustration-right.pt	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/illustration/templates/illustration-right.pt	Fri Oct 12 10:28:46 2018 +0200
@@ -1,13 +1,14 @@
-<div class="pull-right margin-10" tal:condition="view.data">
+<div class="pull-right col-sm-12 col-md-6 col-lg-5 margin-10" tal:condition="view.data">
 	<a class="fancybox" data-toggle
 	   data-ams-fancybox-type="image"
 	   tal:omit-tag="not:view.settings.zoom_on_click"
-	   tal:define="thumbnails tales:thumbnails(view.data);
-				   target thumbnails.get_thumbnail('800x600');
-				   thumb thumbnails.get_thumbnail('300x200');"
+	   tal:define="image view.data;
+				   thumbnails tales:thumbnails(view.data);
+				   target thumbnails.get_thumbnail('800x600');"
 	   tal:attributes="href tales:absolute_url(target)">
-		<img tal:attributes="src tales:absolute_url(thumb);
-							 alt view.alt_title" /><br />
+		<tal:if condition="image">
+			${structure:tales:picture(image, md_width=6, lg_width=5, alt=view.alt_title)}
+		</tal:if>
 		<span tal:content="view.title">legend</span>
 	</a><br />
 </div>
--- a/src/pyams_default_theme/component/paragraph/frame.py	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/paragraph/frame.py	Fri Oct 12 10:28:46 2018 +0200
@@ -12,31 +12,26 @@
 
 __docformat__ = 'restructuredtext'
 
+from persistent import Persistent
+from zope.interface import implementer
+from zope.location import Location
+from zope.schema.fieldproperty import FieldProperty
 
-# import standard library
-from persistent import Persistent
-
-# import interfaces
 from pyams_content.component.association.interfaces import IAssociationContainer
 from pyams_content.component.illustration.interfaces import IIllustration
 from pyams_content.component.paragraph.interfaces.frame import IFrameParagraph
 from pyams_content.features.renderer.interfaces import IContentRenderer
+from pyams_content.features.renderer.skin import BaseContentRenderer
 from pyams_content.reference.pictograms.interfaces import IPictogramTable
-from pyams_default_theme.component.paragraph.interfaces.frame import IFrameParagraphRendererSettings, \
-    ILateralFrameParagraphRendererSettings, IDefaultFrameParagraphRendererSettings, ILeftFrameParagraphRendererSettings, \
+from pyams_default_theme.component.paragraph.interfaces.frame import IDefaultFrameParagraphRendererSettings, \
+    IFrameParagraphRendererSettings, ILateralFrameParagraphRendererSettings, ILeftFrameParagraphRendererSettings, \
     IRightFrameParagraphRendererSettings
 from pyams_i18n.interfaces import II18n
 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, get_annotation_adapter
 from pyams_utils.registry import query_utility
 from pyams_utils.zodb import volatile_property
-from zope.interface import implementer
-from zope.location import Location
-from zope.schema.fieldproperty import FieldProperty
 
 from pyams_default_theme import _
 
@@ -146,15 +141,6 @@
     i18n_context_attrs = ('title', 'body')
     illustration_renderer = None
 
-    def update(self):
-        super(BaseFrameParagraphRenderer, self).update()
-        if self.settings.can_display_illustration():
-            illustration = IIllustration(self.context, None)
-            renderer = illustration.get_renderer(self.request)
-            if renderer is not None:
-                renderer.update()
-                self.illustration_renderer = renderer
-
 
 @adapter_config(name='default', context=(IFrameParagraph, IPyAMSLayer), provides=IContentRenderer)
 @template_config(template='templates/frame-default.pt', layer=IPyAMSLayer)
--- a/src/pyams_default_theme/component/paragraph/templates/html-default.pt	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/paragraph/templates/html-default.pt	Fri Oct 12 10:28:46 2018 +0200
@@ -7,5 +7,5 @@
 	<div>${structure:tales:html(view.body, 'oid_to_href')}</div>
 	<tal:var case="'after-body'">${structure:view.render_illustration()}</tal:var>
 	<div class="clearfix"></div>
-	<br>${structure:provider:pyams.association}
+	${structure:provider:pyams.associations}
 </tal:var>
--- a/src/pyams_default_theme/component/paragraph/verbatim.py	Tue Oct 09 17:51:18 2018 +0200
+++ b/src/pyams_default_theme/component/paragraph/verbatim.py	Fri Oct 12 10:28:46 2018 +0200
@@ -12,27 +12,25 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 from persistent import Persistent
 from zope.interface import implementer
 from zope.location import Location
 from zope.schema.fieldproperty import FieldProperty
 
-# import interfaces
 from pyams_content.component.illustration.interfaces import IIllustration
 from pyams_content.component.paragraph.interfaces.verbatim import IVerbatimParagraph
 from pyams_content.features.renderer.interfaces import IContentRenderer
-# import packages
 from pyams_content.features.renderer.skin import BaseContentRenderer
-from pyams_default_theme import _
-from pyams_default_theme.component.paragraph.interfaces.verbatim import IVerbatimParagraphRendererSettings, \
-    ILateralVerbatimParagraphRendererSettings, IDefaultVerbatimParagraphRendererSettings
+from pyams_default_theme.component.paragraph.interfaces.verbatim import IDefaultVerbatimParagraphRendererSettings, \
+    ILateralVerbatimParagraphRendererSettings, IVerbatimParagraphRendererSettings
 from pyams_i18n.interfaces import II18n
 from pyams_skin.layer import IPyAMSLayer
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config, get_annotation_adapter
 
+from pyams_default_theme import _
+
+
 #
 # Verbatim paragraph default renderer settings
 #
@@ -90,7 +88,7 @@
 class BaseVerbatimParagraphRenderer(BaseContentRenderer):
     """Base frame paragraph renderer"""
 
-    context_attrs = ('author', )
+    context_attrs = ('author',)
     i18n_context_attrs = ('title', 'quote', 'charge')
     illustration_renderer = None