From aa811c15aca297dd4c982c53755e6ab70f484908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sat, 13 Jun 2015 11:40:45 +0200 Subject: [PATCH] add view to embed a sound in another site --- panikweb/paniktags/templatetags/paniktags.py | 3 +- panikweb/urls.py | 5 ++ panikweb/views.py | 33 ++++++++ panikweb_templates/static/css/specifics.css | 75 +++++++++++++++++++ panikweb_templates/static/css/type.css | 6 +- panikweb_templates/static/js/specifics.js | 20 +++++ panikweb_templates/templates/base.html | 2 +- .../templates/includes/audio.html | 17 ++++- .../templates/soundfiles/dialog-embed.html | 15 ++++ .../templates/soundfiles/embed.html | 36 +++++++++ 10 files changed, 206 insertions(+), 6 deletions(-) create mode 100644 panikweb_templates/templates/soundfiles/dialog-embed.html create mode 100644 panikweb_templates/templates/soundfiles/embed.html diff --git a/panikweb/paniktags/templatetags/paniktags.py b/panikweb/paniktags/templatetags/paniktags.py index 881623a..81d15d7 100644 --- a/panikweb/paniktags/templatetags/paniktags.py +++ b/panikweb/paniktags/templatetags/paniktags.py @@ -26,11 +26,12 @@ def zip_lists(a, b): return zip(a, b) @register.inclusion_tag('includes/audio.html', takes_context=True) -def audio(context, sound=None, display_fragment_name=False): +def audio(context, sound=None, embed=False, display_fragment_name=False): return { 'episode': context.get('episode'), 'sound': sound, 'display_fragment_name': display_fragment_name, + 'embed': embed, } @register.inclusion_tag('listen/nav.html', takes_context=True) diff --git a/panikweb/urls.py b/panikweb/urls.py index 1008afe..ef1e3ea 100644 --- a/panikweb/urls.py +++ b/panikweb/urls.py @@ -15,6 +15,11 @@ urlpatterns = patterns('', url(r'^emissions/$', 'panikweb.views.emissions', name='emissions'), url(r'^emissions/(?P[\w,-]+)/episodes/$', 'panikweb.views.emissionEpisodes', name='emissionEpisodes'), url(r'^emissions/(?P[\w,-]+)/(?P[\w,-]+)/$', 'panikweb.views.episode', name='episode-view'), + url(r'^emissions/(?P[\w,-]+)/(?P[\w,-]+)/$', 'panikweb.views.episode', name='episode-view'), + url(r'^emissions/(?P[\w,-]+)/(?P[\w,-]+)/embed/(?P\d+)/$', + 'panikweb.views.soundfile_embed', name='soundfile-embed-view'), + url(r'^emissions/(?P[\w,-]+)/(?P[\w,-]+)/dlg-embed/(?P\d+)/$', + 'panikweb.views.soundfile_dlg_embed', name='soundfile-dialog-embed-view'), url(r'^emissions/(?P[\w,-]+)/$', 'panikweb.views.emission', name='emission-view'), url(r'^ckeditor/', include('ckeditor.urls')), url(r'^emissions/archives$', 'panikweb.views.emissionsArchives', name='emissionsArchives'), diff --git a/panikweb/views.py b/panikweb/views.py index 11b28ed..8167a50 100644 --- a/panikweb/views.py +++ b/panikweb/views.py @@ -147,6 +147,39 @@ class EmissionEpisodesDetailView(DetailView, EmissionMixin): return context emissionEpisodes = EmissionEpisodesDetailView.as_view() + +class SoundFileEmbedView(DetailView): + model = SoundFile + template_name = 'soundfiles/embed.html' + + def get_context_data(self, **kwargs): + context = super(SoundFileEmbedView, self).get_context_data(**kwargs) + if self.kwargs.get('episode_slug') != self.object.episode.slug: + raise Http404() + if self.kwargs.get('emission_slug') != self.object.episode.emission.slug: + raise Http404() + context['episode'] = self.object.episode + return context +soundfile_embed = SoundFileEmbedView.as_view() + + +class SoundFileDialogEmbedView(DetailView): + model = SoundFile + template_name = 'soundfiles/dialog-embed.html' + + def get_context_data(self, **kwargs): + context = super(SoundFileDialogEmbedView, self).get_context_data(**kwargs) + if self.kwargs.get('episode_slug') != self.object.episode.slug: + raise Http404() + if self.kwargs.get('emission_slug') != self.object.episode.emission.slug: + raise Http404() + context['episode'] = self.object.episode + context['site_url'] = self.request.build_absolute_uri('/').strip('/') + return context +soundfile_dlg_embed = SoundFileDialogEmbedView.as_view() + + + class ProgramView(TemplateView): template_name = 'program.html' diff --git a/panikweb_templates/static/css/specifics.css b/panikweb_templates/static/css/specifics.css index 519e0c6..418a719 100644 --- a/panikweb_templates/static/css/specifics.css +++ b/panikweb_templates/static/css/specifics.css @@ -904,6 +904,14 @@ h1.top#frequence { .episode.resume .sound.right .icon-download{ display:block; } + +.big.icon-pause, +.big.icon-stop, +.big.icon-share { + display: inline-block; + vertical-align: middle; +} + .episode.detail .logo.right{ max-width:50%; } @@ -1630,6 +1638,7 @@ div.gallery img { border: 1px solid #333; } +div#dialog-background, div.gallery div.first { position: fixed; top: 0; @@ -1731,3 +1740,69 @@ div.topikcellcontent h2 { .program-week img.smooth { padding-bottom: 0; } + +div#dialog-background { + display: flex; +} +div#dialog-embed { + position: relative; + background: white; + width: 50%; + margin: auto; + text-align: left; + padding: 1ex; +} + +div#dialog-embed textarea { + width: 100%; + max-width: none; +} + +div#dialog-embed #close-button { + position: absolute; + right: 1ex; +} + +body#embed { + min-height: auto !important; + margin: 0; + background: white 0 10px no-repeat url(../img/logoPanikBW.png); +} + +body#embed #Main { + background: transparent; +} + +body#embed #Commons, +body#embed #metaNav, +body#embed #Footer, +body#embed #userLog, +body#embed #Player { + display: none; +} + +body#embed #Changing { + float: none; + width: auto; +} + +body#embed #Main > .wrapper { + padding: 0; +} + +body#embed .logo { + padding-top: 4px; +} + +body#embed ul.custom { + display: inline-block; + width: calc(100% - 70px); +} + +body#embed ul.custom .soundfile-info { + padding: 1ex; +} + +body#embed span.fragment-title { + font-weight: normal; +} diff --git a/panikweb_templates/static/css/type.css b/panikweb_templates/static/css/type.css index 789d851..5a4e581 100644 --- a/panikweb_templates/static/css/type.css +++ b/panikweb_templates/static/css/type.css @@ -86,9 +86,9 @@ /*font-size:1.3em;*/ } .resymbol{ - vertical-align:middle !important; - display:inline-block !important; - font-family: 'Symbols' !important; + vertical-align: middle; + display: inline-block; + font-family: 'Symbols'; } .resymbol.big, .icons.big{ font-size:2em; diff --git a/panikweb_templates/static/js/specifics.js b/panikweb_templates/static/js/specifics.js index 2ecc01c..d80db51 100644 --- a/panikweb_templates/static/js/specifics.js +++ b/panikweb_templates/static/js/specifics.js @@ -355,6 +355,16 @@ $(function() { }else if($(this).attr('data-player-action') == "playAudio"){ $localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' will play soon.','ok')); $localList.playlist("playSoundId", sound_id); + if ($(this).parent().find('.icon-pause').length) { + $(this).hide(); + $(this).parent().find('.icon-pause').show(); + } + }else if ($(this).attr('data-player-action') == "pauseSounds") { + if ($(this).parent().find('.icon-play-sign').length) { + $(this).hide(); + $(this).parent().find('.icon-play-sign').show(); + } + $localList.playlist($(this).attr('data-player-action')); }else{ $localList.playlist($(this).attr('data-player-action')); } @@ -412,6 +422,16 @@ $(function() { } }); + $('[data-popup-href]').on('click', function() { + $.ajax({ + url: $(this).data('popup-href'), + success: function (html, textStatus, jqXhr) { + $(html).appendTo($('body')); + } + }); + return false; + }); + if ($('input#id_q').val() == '') { $('input#id_q').focus(); } diff --git a/panikweb_templates/templates/base.html b/panikweb_templates/templates/base.html index 5a93abb..7642e08 100644 --- a/panikweb_templates/templates/base.html +++ b/panikweb_templates/templates/base.html @@ -36,7 +36,7 @@ {% block extrascripts %}{% endblock %} - +
{% block meta %}
{% metanav active=sectionName %}
{% endblock %}
diff --git a/panikweb_templates/templates/includes/audio.html b/panikweb_templates/templates/includes/audio.html index 342b716..bd08c81 100644 --- a/panikweb_templates/templates/includes/audio.html +++ b/panikweb_templates/templates/includes/audio.html @@ -1,18 +1,27 @@ {% load soundfiles paniktags %} {% if sound|is_format_available:'mp3' or sound|is_format_available:'ogg' %}
+ {% if not embed %} + {% endif %} - + {% if embed %} + + {% endif %}
+ {% if not embed %} + + {% endif %}
{% if display_fragment_name %}
diff --git a/panikweb_templates/templates/soundfiles/dialog-embed.html b/panikweb_templates/templates/soundfiles/dialog-embed.html new file mode 100644 index 0000000..68343b1 --- /dev/null +++ b/panikweb_templates/templates/soundfiles/dialog-embed.html @@ -0,0 +1,15 @@ +{% load i18n %} +
+
+ +

{% trans 'Embed '%}

+

+Copier/coller le code ci-dessousĀ : +

+ + + +

Preview

+ +
+
diff --git a/panikweb_templates/templates/soundfiles/embed.html b/panikweb_templates/templates/soundfiles/embed.html new file mode 100644 index 0000000..a476583 --- /dev/null +++ b/panikweb_templates/templates/soundfiles/embed.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} +{% load thumbnail paniktags static %} + +{% block bodyattr %}id="embed"{% endblock %} +{% block title %}{{ episode.emission.title }}{% endblock %} + +{% block main %} + +
+ + +
+{% endblock %} + -- GitLab