# HG changeset patch # User ymh # Date 1428502452 -7200 # Node ID ddcabeae57b5a0f966f529bfa5fc1ceb3131a6b6 # Parent 1f88f5cb7a73a0eeac19ae8460ac36737cacca23 really add annotation creation to div mode for embed diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/iframe_base.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/iframe_base.html Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/iframe_base.html Wed Apr 08 16:14:12 2015 +0200 @@ -7,18 +7,18 @@ - - - - - - - Ligne de Temps - IRI - Metadata Player - - - -
- -
-
- - -
-
- {% if social %} -
-
- {% endif %} - {% if slideshare %} + + + +
+ +
+
+ + +
+
+ {% if social %} +
+
+ {% endif %} + {% if slideshare %}
-
+ {% endif %} - {% if annotations_list %} + {% if annotations_list %}
{% endif %} {% analytics %} - + diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/mdplayer_config_base.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/mdplayer_config_base.html Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/mdplayer_config_base.html Wed Apr 08 16:14:12 2015 +0200 @@ -36,6 +36,7 @@ var configCss='{% static "ldt/metadataplayer/LdtPlayer-core.css" %}'; var default_thumbnail='{% static "ldt/css/imgs/video_sequence.png" %}'; var segment_api="{% absurl 'segment_api_empty' resource_name='segments' api_name='1.0' %}{% templatetag openvariable %}media{% templatetag closevariable %}/{% templatetag openvariable %}begin{% templatetag closevariable %}/{% templatetag openvariable %}end{% templatetag closevariable %}"; + var annotation_api = "{% absurl 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}"; var LdtPlayer_core='{% static "ldt/metadataplayer/LdtPlayer-core.js" %}'; var creator_name='{{request.user.username}}'; diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v1/iframe.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v1/iframe.html Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v1/iframe.html Wed Apr 08 16:14:12 2015 +0200 @@ -128,7 +128,7 @@ close_after_send: false, slice_annotation_type: ["chap","découpage"], creator_name: '{{request.user.username}}', - creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png", + creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png", {% if not createannotation_polemics %}polemics: []{% endif %} }{% endif %} {% if slideshare %},{ diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v2/iframe.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v2/iframe.html Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v2/iframe.html Wed Apr 08 16:14:12 2015 +0200 @@ -5,178 +5,186 @@ {% load absurl %} {% load analytics %} {% block mdplayer_config %} - var _config = { - width: '{{ player_width }}', - container: '{{ player_id }}_embed', - css: '{% static "ldt/metadataplayer/LdtPlayer-core.css" %}', - default_options: { - metadata: _metadata - }, - widgets: [ - { - type: "AutoPlayer", - {% if external_url %} - video: "{{ external_url }}", - {% else %} - streamer: function(_url) { - var _matches = _url.match(/^[^\/]+\/\/[^\/]+\/[^\/]+\//); - if (_matches) { - return _matches[0]; - } else { - return _url; - } - }, - {% endif %} - height: '{{ player_height }}', - url_transform: function(url) { - // Adaptation to jwplayer 6 - if(url.substr(url.length - 4).toLowerCase()=='.flv'){ - return url.replace('/ddc_player/video/','/ddc_player/flv:video/'); - } - return url.replace('/ddc_player/video/','/ddc_player/mp4:video/'); - }, - autostart: {% if autostart %} true {% else %} false {% endif %} - } - {% if polemic %} - ,{ - type: "Polemic", - {% if polemic == 'all' %} - annotation_type: false, - {% else %} - annotation_type: [ - {% for type in polemic_annotation_types %} - {% if type == polemic_annotation_types|last %} - "{{type}}" - {% else %} - "{{type}}", - {% endif %} - {% endfor %}], - {% endif %} - max_elements: {{ polemic__max_elements }}, - defaultcolor: "#{{ polemic_defaultColor }}", - foundcolor: "#{{ polemic_foundColor }}", - {% if polemics_list %} - polemics : {{ polemics_list|safe }} - {% else %} - polemics : [ - { - "name" : "OK", - "keywords" : [ "++" ], - "color" : "#{{ polemic_okColor }}" - }, - { - "name" : "KO", - "keywords" : [ "--" ], - "color" : "#{{ polemic_koColor }}" - }, - { - "name" : "REF", - "keywords" : [ "==", "http://" ], - "color" : "#{{ polemic_refColor }}" - }, - { - "name" : "Q", - "keywords" : [ "?" ], - "color" : "#{{ polemic_qColor }}" - } - ] - {% endif %} - } - {% endif %} - {% if sparkline %} - ,{ - type: "Sparkline", - lineColor: "#{{ sparkline_lineColor }}", - fillColor: "#{{ sparkline_fillColor }}", - } - {% endif %} - ,{ - type: "Slider" - } - - {% if annotations_list %},{ - type: "AnnotationsList", - container: "AnnotationsList_ext", - ajax_url: "{% absurl 'segment_api_empty' resource_name='segments' api_name='1.0' %}{% templatetag openvariable %}media{% templatetag closevariable %}/{% templatetag openvariable %}begin{% templatetag closevariable %}/{% templatetag openvariable %}end{% templatetag closevariable %}", - ajax_granularity : 300000, - default_thumbnail : '{% static "ldt/css/imgs/video_sequence.png" %}', - show_audio: true, - rtmp_streamer: "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/" - }{% endif %},{ - type: "Controller" - } - {% if segments %},{ - type: "Segments", - annotation_type: [ - {% for type in segments_annotation_types %} - {% if type == segments_annotation_types|last %} - "{{type}}" - {% else %} - "{{type}}", - {% endif %} - {% endfor %}] - } - {% endif %} - {% if multisegments %},{ - type: "MultiSegments" - } - {% endif %} - {% if annotation %},{ - type: "Annotation", - start_minimized: true, - site_name : "Lignes de Temps", - annotation_type: ["chap","découpage"] - } - {% endif %} - {% if tweet %},{ - type: "Tweet", - hide_timeout: 5000 - } - {% endif %} - {% if createannotation %},{ - type: "CreateAnnotation", - api_endpoint_template: "{% absurl 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}", - after_send_timeout: 8000, - {% if tag_titles or tag_titles == "" %} - tag_titles : tag_titles_array, - {% else %} - tag_titles : false, - {% endif %} - show_mic_record: {% if show_mic_record %}true{% else %}false{% endif %}, - close_after_send: false, - slice_annotation_type: ["chap","découpage"], - creator_name: '{{request.user.username}}', - creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{WEB_URL}}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png", - {% if not createannotation_polemics %}polemics: []{% endif %} - }{% endif %} - {% if slideshare %},{ - type: "Slideshare", - container: "Slideshare_ext", - embed_width: 400, - embed_height: 334, - annotation_type: "slide" - } - {% endif %},{ - type: "Mediafragment" - } - {% if social %},{ - type: "Social", - container: "Social_ext", - show_url: {% if show_url %}true{% else %}false{% endif %}, - show_twitter: {% if show_twitter %}true{% else %}false{% endif %}, - show_fb: {% if show_fb %}true{% else %}false{% endif %}, - show_gplus: {% if show_gplus %}true{% else %}false{% endif %}, - show_mail: {% if show_mail %}true{% else %}false{% endif %}, - url: document.location.href.replace(/#.*$/,""), - text: document.title - } - {% endif %} - - {% if tagcloud %},{ - type: "Tagcloud" - } - {% endif %} - ] - }; + var _config = { + width: '{{ player_width }}', + container: '{{ player_id }}_embed', + css: '{% static "ldt/metadataplayer/LdtPlayer-core.css" %}', + default_options: { + metadata: _metadata + }, + widgets: [ + { + type: "AutoPlayer", + {% if external_url %} + video: "{{ external_url }}", + {% else %} + streamer: function(_url) { + var _matches = _url.match(/^[^\/]+\/\/[^\/]+\/[^\/]+\//); + if (_matches) { + return _matches[0]; + } else { + return _url; + } + }, + {% endif %} + height: '{{ player_height }}', + url_transform: function(url) { + // Adaptation to jwplayer 6 + if(url.substr(url.length - 4).toLowerCase()=='.flv'){ + return url.replace('/ddc_player/video/','/ddc_player/flv:video/'); + } + return url.replace('/ddc_player/video/','/ddc_player/mp4:video/'); + }, + autostart: {% if autostart %} true {% else %} false {% endif %} + } + {% if polemic %} + ,{ + type: "Polemic", + {% if polemic == 'all' %} + annotation_type: false, + {% else %} + annotation_type: [ + {% for type in polemic_annotation_types %} + {% if type == polemic_annotation_types|last %} + "{{type}}" + {% else %} + "{{type}}", + {% endif %} + {% endfor %}], + {% endif %} + max_elements: {{ polemic__max_elements }}, + defaultcolor: "#{{ polemic_defaultColor }}", + foundcolor: "#{{ polemic_foundColor }}", + {% if polemics_list %} + polemics : {{ polemics_list|safe }} + {% else %} + polemics : [ + { + "name" : "OK", + "keywords" : [ "++" ], + "color" : "#{{ polemic_okColor }}" + }, + { + "name" : "KO", + "keywords" : [ "--" ], + "color" : "#{{ polemic_koColor }}" + }, + { + "name" : "REF", + "keywords" : [ "==", "http://" ], + "color" : "#{{ polemic_refColor }}" + }, + { + "name" : "Q", + "keywords" : [ "?" ], + "color" : "#{{ polemic_qColor }}" + } + ] + {% endif %} + } + {% endif %} + {% if sparkline %} + ,{ + type: "Sparkline", + lineColor: "#{{ sparkline_lineColor }}", + fillColor: "#{{ sparkline_fillColor }}", + } + {% endif %} + ,{ + type: "Slider" + } + + {% if annotations_list %},{ + type: "AnnotationsList", + container: "AnnotationsList_ext", + ajax_url: "{% absurl 'segment_api_empty' resource_name='segments' api_name='1.0' %}{% templatetag openvariable %}media{% templatetag closevariable %}/{% templatetag openvariable %}begin{% templatetag closevariable %}/{% templatetag openvariable %}end{% templatetag closevariable %}", + ajax_granularity : 300000, + default_thumbnail : '{% static "ldt/css/imgs/video_sequence.png" %}', + show_audio: true, + rtmp_streamer: "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/" + }{% endif %},{ + type: "Controller" + } + {% if segments %},{ + type: "Segments", + annotation_type: [ + {% for type in segments_annotation_types %} + {% if type == segments_annotation_types|last %} + "{{type}}" + {% else %} + "{{type}}", + {% endif %} + {% endfor %}] + } + {% endif %} + {% if multisegments %},{ + type: "MultiSegments" + } + {% endif %} + {% if annotation %},{ + type: "Annotation", + start_minimized: true, + site_name : "Lignes de Temps", + annotation_type: ["chap","découpage"] + } + {% endif %} + {% if tweet %},{ + type: "Tweet", + hide_timeout: 5000 + } + {% endif %} + {% if createannotation %},{ + type: "CreateAnnotation", + api_endpoint_template: "{% absurl 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}", + after_send_timeout: 8000, + {% if tag_titles or tag_titles == "" %} + tag_titles : tag_titles_array, + {% else %} + tag_titles : false, + {% endif %} + show_mic_record: {% if show_mic_record %}true{% else %}false{% endif %}, + close_after_send: false, + slice_annotation_type: {% if createannotation_annotation_types %} + [{% for type in createannotation_annotation_types %} + {% if forloop.last %} "{{type}}" + {% else %} "{{type}}", + {% endif %} + {% endfor %}] + {% else %} + ["chap","découpage"] + {% endif %}, + creator_name: '{{request.user.username}}', + creator_avatar: '{% thumbnail request.user.image "48x48" format="PNG" crop="center" as im %}{{ im.url }}{% endthumbnail %}' || "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png", + {% if not createannotation_polemics %}polemics: []{% endif %} + }{% endif %} + {% if slideshare %},{ + type: "Slideshare", + container: "Slideshare_ext", + embed_width: 400, + embed_height: 334, + annotation_type: "slide" + } + {% endif %},{ + type: "Mediafragment" + } + {% if social %},{ + type: "Social", + container: "Social_ext", + show_url: {% if show_url %}true{% else %}false{% endif %}, + show_twitter: {% if show_twitter %}true{% else %}false{% endif %}, + show_fb: {% if show_fb %}true{% else %}false{% endif %}, + show_gplus: {% if show_gplus %}true{% else %}false{% endif %}, + show_mail: {% if show_mail %}true{% else %}false{% endif %}, + url: document.location.href.replace(/#.*$/,""), + text: document.title + } + {% endif %} + + {% if tagcloud %},{ + type: "Tagcloud" + } + {% endif %} + ] + }; {% endblock mdplayer_config %} {% analytics %} diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v2/mdplayer_config.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v2/mdplayer_config.html Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed/v2/mdplayer_config.html Wed Apr 08 16:14:12 2015 +0200 @@ -25,15 +25,19 @@
{% trans 'Audio annotation' %} -
- {% trans 'Use most used tags ' %} - - {%trans 'Set your own tags : ' %} - -
- - {% trans '4 polemics buttons' %} ++/--/??/== - +
+
+ {% trans 'Display annotation types: (annotation types must be separated by commas, leave blank to display everything) '%}
+
+
+ {% trans 'Use most used tags ' %} + + {%trans 'Set your own tags : ' %} + +
+ + {% trans '4 polemics buttons' %} ++/--/??/== +
diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/ldt_utils/views/embed/utils.py --- a/src/ldt/ldt/ldt_utils/views/embed/utils.py Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/views/embed/utils.py Wed Apr 08 16:14:12 2015 +0200 @@ -1,12 +1,14 @@ from django.conf import settings from django.utils.safestring import mark_safe -from django.core.urlresolvers import reverse import ldt.auth as ldt_auth -from ldt.ldt_utils.models import Content, Project, Segment from ldt.ldt_utils.projectserializer import ProjectJsonSerializer +from ldt.utils.web_url_management import get_web_url -from ldt.utils.web_url_management import get_web_url + +from ldt.ldt_utils.models import Project +from urlparse import urljoin + def get_datas_for_embed(request, json_url, player_id, ldt_id, iframe_base_url): @@ -14,7 +16,7 @@ project_contents = project.contents.all() content = project_contents[0] WEB_URL = get_web_url(request) - iframe_url = mark_safe(WEB_URL+settings.SRC_BASE_URL+str(iframe_base_url)[1:]+"?content_id="+content.iri_id+"&project_id="+ldt_id) + iframe_url = mark_safe(urljoin(WEB_URL,str(iframe_base_url)+"?content_id="+content.iri_id+"&project_id="+ldt_id)) external_url = None if content.src is not None: for external_src in settings.EXTERNAL_STREAM_SRC: diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/ldt_utils/views/embed/v2/views.py --- a/src/ldt/ldt/ldt_utils/views/embed/v2/views.py Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/views/embed/v2/views.py Wed Apr 08 16:14:12 2015 +0200 @@ -1,18 +1,14 @@ import logging from django.core.urlresolvers import reverse_lazy, reverse -from django.http import (HttpResponseForbidden, HttpResponseNotFound, - HttpResponseRedirect) +from django.http import HttpResponseForbidden from django.shortcuts import render_to_response from django.template import RequestContext -from django.template.loader import render_to_string -from django.utils.html import escape from django.utils.translation import ugettext as _ -from django.views.generic import View +from ldt.ldt_utils.models import Content from ldt.ldt_utils.views.embed.meta import ConfigView, IframeView from ldt.ldt_utils.views.embed.utils import get_datas_for_embed -from ldt.utils.web_url_management import get_web_url logger = logging.getLogger(__name__) @@ -64,9 +60,8 @@ rend_dict["player_width"]=550 if request.GET.has_key("polemic"): rend_dict["polemic"] = True - polemic_annotation_types_str = "" if request.GET.get("polemic") == "all": - polemic_annotation_types_str = "false" + rend_dict["polemic_annotation_types"] = [] else: polemic_annotation_types_list = request.GET.get("polemic").split(",") rend_dict["polemic_annotation_types"] = polemic_annotation_types_list @@ -123,6 +118,11 @@ rend_dict["show_mic_record"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("show_mic_record").lower()) if rend_dict["show_mic_record"]: rend_dict["createannotation"]=True + if request.GET.has_key("createannotation_annotation_types"): + segments_annotation_types_list = request.GET.get("createannotation_annotation_types").split(",") + rend_dict["createannotation_annotation_types"] = segments_annotation_types_list + else: + rend_dict["createannotation_annotation_types"] = False rend_dict["createannotation_polemics"] = True if request.GET.has_key("createannotation_polemics"): rend_dict["createannotation_polemics"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("createannotation_polemics").lower()) diff -r 1f88f5cb7a73 -r ddcabeae57b5 src/ldt/ldt/static/ldt/js/embed/v2/embed.js --- a/src/ldt/ldt/static/ldt/js/embed/v2/embed.js Tue Apr 07 18:36:07 2015 +0200 +++ b/src/ldt/ldt/static/ldt/js/embed/v2/embed.js Wed Apr 08 16:14:12 2015 +0200 @@ -202,6 +202,7 @@ var tagcloud_val=document.getElementById('tagcloud_checkbox'); var player_height_val=$j('#player_height').val(); var autostart_val=document.getElementById('autostart_checkbox'); + var createannotation_val=document.getElementById('createannotation_checkbox'); var widget_code='\ widgets: [\n\ {\n\ @@ -219,6 +220,8 @@ else { widget_code+='autostart: false\n\}'; } + + if (polemic_val.checked){ defaultcolor= $j("#polemic_default_color").val(); foundcolor=$j("#polemic_found_color").val(); @@ -319,6 +322,27 @@ },{\n\ type: "Mediafragment"\n\ }'; + if(createannotation_val.checked) { + + var tag_titles = ($j('input[name=annotation_tag]:checked').attr('id') === 'set_tags') ? $j('#tag_list').val() : false; + var show_mic_record = $j("#show_mic_record_checkbox").prop('checked'); + var createannotation_polemics = $j('#createannotation_polemics_checkbox').prop('checked'); + var createannotation_annotation_types = $j('#createannotation_annotation_types').val(); + + widget_code += + ',\n{\n' + + ' type: "CreateAnnotation",\n' + + ' api_endpoint_template: "'+ annotation_api +'",\n' + + ' after_send_timeout: 8000,\n' + + ' tag_titles : ' + ( (tag_titles || tag_titles === "") ? JSON.stringify(tag_titles.split(',')) : 'false') + ',\n' + + ' show_mic_record : ' + (show_mic_record ? 'true' : 'false') + ',\n' + + ' close_after_send: false,\n' + + ' slice_annotation_type: ' + (createannotation_annotation_types ? JSON.stringify(createannotation_annotation_types.split(',')) : '["chap","découpage"]') + ',\n' + + ' creator_avatar: "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png",\n' + + ((!createannotation_polemics) ? ' polemics: []' : '') + '\n' + + '}\n'; + } + if(slideshare_val.checked){ widget_code+='\ ,{\n\ @@ -673,7 +697,6 @@ } function iframe_event() { var wrapper="wrapper_"+player_id; - //$j("#createannotation_block").toggle(true); $j("#createannotation_options").toggle(true); var element = document.getElementById(wrapper); var createannotation_val=document.getElementById('createannotation_checkbox'); @@ -713,6 +736,7 @@ iframeUrl+="&createannotation=True"; var show_mic_record_val = document.getElementById('show_mic_record_checkbox'); var set_tags_val=document.getElementById('set_tags'); + var createannotation_annotation_types = $j('#createannotation_annotation_types').val(); if(show_mic_record_val.checked){ iframeUrl+="&show_mic_record=True"; } @@ -722,6 +746,9 @@ if(!createannotation_polemics_val.checked){ iframeUrl+="&createannotation_polemics=False"; } + if(createannotation_annotation_types) { + iframeUrl += "&createannotation_annotation_types="+createannotation_annotation_types; + } } if (polemic_val.checked){ var polemic_annotation_types_val=document.getElementById("polemic_annotation_types");