Updated default audio paragraph renderer
authorThierry Florac <thierry.florac@onf.fr>
Fri, 28 Dec 2018 10:26:31 +0100
changeset 306 23daa39df50b
parent 305 8f606992afed
child 307 a0f84efc3348
Updated default audio paragraph renderer
src/pyams_default_theme/component/paragraph/audio.py
src/pyams_default_theme/component/paragraph/templates/audio-default.pt
--- a/src/pyams_default_theme/component/paragraph/audio.py	Fri Dec 28 10:26:10 2018 +0100
+++ b/src/pyams_default_theme/component/paragraph/audio.py	Fri Dec 28 10:26:31 2018 +0100
@@ -10,7 +10,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-
 __docformat__ = 'restructuredtext'
 
 from pyams_content.component.paragraph.interfaces.audio import IAudioParagraph
@@ -34,3 +33,6 @@
 
     label = _("Default audio renderer")
     weight = 1
+
+    context_attrs = ('author', 'data', )
+    i18n_context_attrs = ('title', 'description', )
--- a/src/pyams_default_theme/component/paragraph/templates/audio-default.pt	Fri Dec 28 10:26:10 2018 +0100
+++ b/src/pyams_default_theme/component/paragraph/templates/audio-default.pt	Fri Dec 28 10:26:31 2018 +0100
@@ -1,1 +1,30 @@
-
+<section class="wrapper audio-wrapper"
+		 tal:define="audio view.data;
+					 conversions tales:conversions(audio);"
+	 i18n:domain="pyams_default_theme">
+	<h3 tal:condition="view.title"
+		tal:content="view.title">title</h3>
+	<div tal:condition="view.description"
+		 tal:content="structure tales:html(view.description)">Description</div>
+	<div tal:define="illustration tales:pyams_illustration(context);">
+		<tal:if condition="illustration">
+			<div tal:define="image i18n:illustration.data"
+				 tal:condition="image"
+				 class="thumbnail photo col-lg-3 col-md-3 col-sm-4 sol-xs-4 pull-left">
+				${structure:tales:picture(image, lg_width=2, md_width=2, sm_width=3, xs_width=3)}
+			</div>
+		</tal:if>
+		<div class="${'col-lg-9 col-md-9 col-sm-8 col-xs-8' if illustration else ''}">
+			<audio controls preload="metadata" style="width: 100%;">
+				<tal:loop repeat="conversion conversions.get_conversions(order=('audio/aac','audio/mpeg', 'audio/ogg', 'audio/x-wav'))">
+					<tal:if define="audio_type tales:audio_type(conversion);"
+							condition="audio_type">
+						<source type="${audio_type}" src="${tales:absolute_url(conversion)}" />
+					</tal:if>
+				</tal:loop>
+				<i18n:var translate="">Your browser can not play audio files</i18n:var>
+			</audio>
+			<div class="author">${view.author}</div>
+		</div>
+	</div>
+</section>
\ No newline at end of file