Embed code corrections : jsonp problem solved, complete adresses in embed_player, display metadataplayer on click when needed, select code on button click, iframe code available in the embed popup
authorgrandjoncl
Mon, 08 Oct 2012 12:34:11 +0200
changeset 833 20acf3b3b2f0
parent 826 cfa5e38dfc07
child 834 6e9b69ffb8a4
Embed code corrections : jsonp problem solved, complete adresses in embed_player, display metadataplayer on click when needed, select code on button click, iframe code available in the embed popup
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed_popup.html
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/iframe_embed_player.html
src/ldt/ldt/ldt_utils/views/front.py
src/ldt/ldt/ldt_utils/views/workspace.py
src/ldt/ldt/locale/fr/LC_MESSAGES/django.mo
src/ldt/ldt/locale/fr/LC_MESSAGES/django.po
src/ldt/ldt/static/ldt/css/workspace.css
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed_popup.html	Thu Oct 04 19:07:33 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/embed_popup.html	Mon Oct 08 12:34:11 2012 +0200
@@ -21,6 +21,7 @@
 		<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/workspace.css" type="text/css"/>
 		<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/embed_popup.css" type="text/css"/>
 		<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/jq-css/jquery.qtip.css" type="text/css"/>
+
 		<script type="text/javascript">
 			$j(document).ready(function(){
 	            $j("#project_id_select").click(function(){
@@ -29,6 +30,41 @@
 	            });
 	        });
         </script>
+        <script type="text/javascript">
+			$j(document).ready(function(){
+		        $j("#player_button").click(function(){
+		        	$j("#player_id_code").focus();
+			       	$j("#player_id_code").select();
+			       	$j("#iframe_player_id_code").focus();
+			       	$j("#iframe_player_id_code").select();
+			       	
+			    });
+		    	
+		        $j("#seo_body_button").click(function(){
+		        	$j("#seo_body_id_code").focus();
+			       	$j("#seo_body_id_code").select();
+			    });
+		        $j("#seo_meta_button").click(function(){
+		        	$j("#seo_meta_id_code").focus();
+			       	$j("#seo_meta_id_code").select();
+			    });
+			});
+		</script>
+		
+		<script type="text/javascript"> 
+			function toggle() {
+				var element = document.getElementById("wrapper_{{player_id}}");
+				var text = document.getElementById("displayPlayer");
+				if(element.style.display==="none") {
+			    	element.style.display="block";
+					text.innerHTML = "{% trans 'Hide Player' %}";
+			  	}
+				else {
+			    	element.style.display="none";
+					text.innerHTML = "{% trans 'Show Player' %}";
+				}
+			} 
+		</script> 
 		
 	</head>
 
@@ -37,26 +73,30 @@
 		<div id='ldt_id'>
 			<div id='ldt_id_title'>{% trans 'project id' %} <span id="project_id_select">({% trans 'Select' %})</span> : <input id="project_id_input" value="{{ldt_id}}"/></div>
         </div>
-		<div class="ldt_player" id="wrapper_{{player_id}}">
-		{% include "ldt/ldt_utils/partial/embed_player.html" %}  
+        
+        <a id="displayPlayer" href="javascript:toggle();">{% trans 'Show Player' %}</a>
+		<div class="ldt_player" id="wrapper_{{player_id}}" style="display:none">
+			{% include "ldt/ldt_utils/partial/embed_player.html" %}  
 		</div>
-
 		<div id="button_row">
 		    <div id="display_select">
 		    	<input type="button" value="{% trans 'popup_player'%}" id="player_button"/><input id="seo_body_button" type="button" value="{% trans 'popup_seo_body' %}"/><input id="seo_meta_button" type="button" value="{% trans 'popup_seo_meta' %}"/><input id="links_button" type="button" value="{% trans 'popup_links' %}"/>
 		    </div>
 		</div>
 		
-		<div class="ldt_player_code">
+		<div>
 			<code id ="code_{{player_id}}" >		
-				<div  id="player_code"><pre>{{ embed_rendered.player }}</pre></div>
-				<div id="seo_body_code"><pre>{{ embed_rendered.seo_body }}</pre></div>
-				<div id="seo_meta_code"><pre>{{ embed_rendered.seo_meta }}</pre></div>			
+				<div  id="player_code">
+					<textarea id="player_id_code" readonly="readonly" class="ldt_player_code">{{ embed_rendered.player }}</textarea>
+					<textarea id="iframe_player_id_code" readonly="readonly" class="ldt_player_code">{{ iframe }}</textarea>
+				</div>
+				<div id="seo_body_code"><textarea id="seo_body_id_code" readonly="readonly" class="ldt_player_code" >{{ embed_rendered.seo_body }}</textarea></div>
+				<div id="seo_meta_code"><textarea id="seo_meta_id_code" readonly="readonly" class="ldt_player_code">{{ embed_rendered.seo_meta }}</textarea></div>		
 			</code>
-	
-			<div id="links_code">{% include "ldt/ldt_utils/partial/embed_links.html" %}</div>
+			
+			<div id="links_code" class="ldt_player_code">{% include "ldt/ldt_utils/partial/embed_links.html" %}</div>
 		</div>
-						
+			
 		<a href="{{json_url}}?escape=true&mimetype=text/plain" class="ldt_json_link" >{% trans 'clik here to see the project content' %}</a>		
 {% analytics %}		
 	</body>
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html	Thu Oct 04 19:07:33 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html	Mon Oct 08 12:34:11 2012 +0200
@@ -6,7 +6,13 @@
 </div>
 <script type="text/javascript" src="{{WEB_URL}}{{LDT_MEDIA_PREFIX}}metadataplayer/LdtPlayer-core.js"></script>
 <script type="text/javascript">
-  
+
+if (typeof jQuery == "undefined") {
+	jQuery = IriSP.jQuery;
+}
+	var metadatas = {metadata: {url: '{{json_url}}'}};
+	var metadata_key = "metadata";
+
 IriSP.libFiles.defaultDir = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}js/";
 IriSP.libFiles.locations.jwPlayerSWF = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}swf/player.swf";
 IriSP.libFiles.locations.recordMicSwf = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}swf/record_mic.swf";
@@ -16,9 +22,10 @@
 
 IriSP.widgetsDir = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}metadataplayer";
 var _metadata = {
-    url: '{{ json_url }}',
+    url: metadatas[metadata_key].url + '?callback=?',
     format: 'ldt'
 };
+
 var _config = {
     width: '{{ player_width }}',
     container: '{{ player_id }}_embed',
@@ -49,16 +56,9 @@
         },
         {
             type: "Polemic"
-    {% if polemic == 'all' %}
-            ,annotation_type: false
-    {% endif %}
-        },
-    {% if polemic != 'all' %}
-        {
+        },{
             type: "Sparkline"
-        },
-    {% endif %}
-        {
+        },{
             type: "Slider"
         },{
             type: "AnnotationsList",
@@ -81,18 +81,18 @@
         },{
             type: "Tweet",
             hide_timeout: 5000
-        },{
+        },{% if annotation_block %}{
             type: "CreateAnnotation",
-            api_endpoint_template: "{{WEB_URL}}{% url annotation_api_empty %}{% templatetag openvariable %}id{% templatetag closevariable %}.json",
+            api_endpoint_template: "{% url annotation_api_empty %}{% templatetag openvariable %}id{% templatetag closevariable %}.json",
             api_method: "PUT",
             after_send_timeout: 8000,
-            show_mic_record: {% if show_mic_record %}true{% else %}false{% endif %},
+            show_mic_record: false,             
             close_after_send: false,
             slice_annotation_type: ["chap","découpage"],
             tag_titles: ["#amateur", "#digital-humanities"],
             creator_name: '{{request.user.username}}',
             creator_avatar: '{% thumbnail request.user.get_profile.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"
-        },{
+        },{% endif %}{
             type: "Slideshare",
             container: "Slideshare_ext",
             embed_width: 400,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/iframe_embed_player.html	Mon Oct 08 12:34:11 2012 +0200
@@ -0,0 +1,6 @@
+{% spaceless %}
+{% load i18n %}
+{% load thumbnail %}
+
+<iframe src="{{WEB_URL}}{{BASE_URL}}ldtplatform/ldt/embediframe/?content_id={{iri_id}}&polemic={{polemic}}&show_mic_record={{show_mic_record}}&annotations_list={{annotations_list}}" seamless="seamless" width='800' height='1000'></iframe> 
+{% endspaceless %}
\ No newline at end of file
--- a/src/ldt/ldt/ldt_utils/views/front.py	Thu Oct 04 19:07:33 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/views/front.py	Mon Oct 08 12:34:11 2012 +0200
@@ -99,6 +99,7 @@
     # Get the wanted content
     content = Content.objects.get(iri_id=content_iri_id)
     # Get the content src to see if it is a youtube/dailymotion video
+    annotation_block = True
     external_url = None
     if content.src is not None:
         for external_src in settings.EXTERNAL_STREAM_SRC:
@@ -131,7 +132,7 @@
     return render_to_response("front/front_player.html",
                               {'content': content, 'project':proj, 'player_id': player_id, 
                               'json_url': json_url, 'player_width':player_width, 'player_height':player_height, 'stream_mode':stream_mode, 'external_url':external_url,
-                               'is_gecko': is_gecko},
+                               'is_gecko': is_gecko, 'annotation_block':annotation_block},
                               context_instance=RequestContext(request))
 
 
--- a/src/ldt/ldt/ldt_utils/views/workspace.py	Thu Oct 04 19:07:33 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/views/workspace.py	Mon Oct 08 12:34:11 2012 +0200
@@ -108,7 +108,9 @@
                            (lambda s:escape(render_to_string("ldt/ldt_utils/partial/embed_%s.html" % (s), rend_dict, context_instance=RequestContext(request))))(typestr))
                            for typestr in ('player', 'seo_body', 'seo_meta', 'links'))
     rend_dict['embed_rendered'] = embed_rendered
-
+    iframe=render_to_string("ldt/ldt_utils/partial/iframe_embed_player.html", rend_dict, context_instance=RequestContext(request))
+    rend_dict['iframe']=iframe
+    logging.debug("louiseredhotpeppers iframe : "+str(iframe)+" bla")
     return render_to_response("ldt/ldt_utils/embed_popup.html", rend_dict, context_instance=RequestContext(request))
 
 
@@ -140,6 +142,8 @@
         rend_dict["annotations_list"] = {'true': True, 'false': False, "0": False, "1": True}.get(request.GET.get("annotations_list").lower())
         rend_dict["player_width"] = 550
     
+    rend_dict["annotation_block"]= True
+    
 
     return render_to_response("ldt/ldt_utils/embed_iframe.html", rend_dict, context_instance=RequestContext(request))
 
@@ -149,6 +153,7 @@
     project = Project.safe_objects.get(ldt_id=ldt_id); #@UndefinedVariable
     project_contents = project.contents.all()
     content=project_contents[0]
+    iri_id=content.iri_id
     external_url = None
     if content.src is not None:
         for external_src in settings.EXTERNAL_STREAM_SRC:
@@ -173,7 +178,7 @@
     annotations = ps.get_annotations(first_cutting=True)
     rend_dict = {'json_url':json_url, 'player_id':player_id, 'annotations':annotations, 'ldt_id': ldt_id, 'stream_mode': stream_mode, 
                  'player_width': player_width, 'player_height': player_height, 'external_url': external_url,
-                 'polemic':False, 'show_mic_record':False, 'annotations_list':False}
+                 'polemic':False, 'show_mic_record':False, 'annotations_list':False, 'iri_id': iri_id}
     
     return rend_dict
 
Binary file src/ldt/ldt/locale/fr/LC_MESSAGES/django.mo has changed
--- a/src/ldt/ldt/locale/fr/LC_MESSAGES/django.po	Thu Oct 04 19:07:33 2012 +0200
+++ b/src/ldt/ldt/locale/fr/LC_MESSAGES/django.po	Mon Oct 08 12:34:11 2012 +0200
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-10-01 11:26+0200\n"
+"POT-Creation-Date: 2012-10-08 11:10+0200\n"
 "PO-Revision-Date: 2010-03-09 15:52+0100\n"
 "Last-Translator: Yves-Marie Haussonne <ymh.work@gmail.com>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,6 +16,10 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Language: \n"
 
+#: .\forms\fields.py:17
+msgid "Enter a valid duration format"
+msgstr ""
+
 #: .\forms\widgets.py:21
 msgid "Date"
 msgstr "Date"
@@ -309,7 +313,7 @@
 msgstr "<b>Lignes</b> de temps"
 
 #: .\ldt_utils\templates\front\front_base.html.py:59
-#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:68
+#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:67
 msgid "My projects"
 msgstr "Mes projets"
 
@@ -408,8 +412,8 @@
 #: .\ldt_utils\templates\ldt\ldt_utils\groups.html.py:113
 #: .\ldt_utils\templates\ldt\ldt_utils\ldt_list.html.py:80
 #: .\ldt_utils\templates\ldt\ldt_utils\published_projects.html.py:70
-#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:56
-#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:71
+#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:55
+#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:70
 #: .\ldt_utils\templates\ldt\ldt_utils\partial\permissions.html.py:129
 #: .\templates\ldt\ldt_base.html.py:127
 msgid "search"
@@ -533,7 +537,7 @@
 "resoumettre le formulaire media après avoir fait les changements suivants:"
 
 #: .\ldt_utils\templates\ldt\ldt_utils\create_content.html.py:85
-#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:53
+#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:52
 msgid "Create content"
 msgstr "Créer un contenu"
 
@@ -543,7 +547,8 @@
 
 #: .\ldt_utils\templates\ldt\ldt_utils\create_content.html.py:127
 #: .\ldt_utils\templates\ldt\ldt_utils\create_ldt.html.py:141
-#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:54
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:39
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm_popup.html.py:54
 msgid "reset_front_project"
 msgstr "Réinitialiser"
 
@@ -556,7 +561,8 @@
 #: .\ldt_utils\templates\ldt\ldt_utils\create_ldt.html.py:137
 #: .\ldt_utils\templates\ldt\ldt_utils\error_confirm.html.py:37
 #: .\ldt_utils\templates\ldt\ldt_utils\error_confirm_popup.html.py:53
-#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:53
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:38
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm_popup.html.py:53
 msgid "close_cancel"
 msgstr "Fermer"
 
@@ -648,42 +654,53 @@
 msgid "create_project"
 msgstr "Créer un nouveau projet Ligne de Temps"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:38
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:57
+msgid "Hide Player"
+msgstr "Masquer le Lecteur métadata "
+
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:61
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:74
+msgid "Show Player"
+msgstr "Afficher le Lecteur métadata"
+
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:71
 msgid "project id"
 msgstr "Identifiant du projet "
 
-#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:38
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:71
 msgid "Select"
 msgstr "Sélectionner"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:46
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:80
 msgid "popup_player"
 msgstr "Code Lecteur métadata"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:46
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:80
 msgid "popup_seo_body"
 msgstr "Code SEO"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:46
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:80
 msgid "popup_seo_meta"
 msgstr "Code balise meta en-tête"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:46
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:80
 msgid "popup_links"
 msgstr "Liste de liens"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:60
+#: .\ldt_utils\templates\ldt\ldt_utils\embed_popup.html.py:100
 msgid "clik here to see the project content"
 msgstr "cliquer ici pour voir le contenu du projet"
 
 #: .\ldt_utils\templates\ldt\ldt_utils\error_confirm.html.py:21
 #: .\ldt_utils\templates\ldt\ldt_utils\error_confirm_popup.html.py:34
-#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:34
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:22
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm_popup.html.py:34
 msgid "error"
 msgstr "Erreur"
 
 #: .\ldt_utils\templates\ldt\ldt_utils\error_confirm.html.py:21
 #: .\ldt_utils\templates\ldt\ldt_utils\error_confirm_popup.html.py:34
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm_popup.html.py:34
 msgid "confirm"
 msgstr "Confirmation d'effacement"
 
@@ -693,7 +710,7 @@
 msgstr "Effacer"
 
 #: .\ldt_utils\templates\ldt\ldt_utils\error_confirm_popup.html.py:49
-#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:49
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm_popup.html.py:49
 msgid "close_error"
 msgstr "Fermer"
 
@@ -736,11 +753,11 @@
 msgstr "Projets publiés"
 
 #: .\ldt_utils\templates\ldt\ldt_utils\published_projects.html.py:68
-#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:69
+#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:68
 msgid "Create project"
 msgstr "Créer un nouveau projet d'indexation"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:34
+#: .\ldt_utils\templates\ldt\ldt_utils\reset_confirm.html.py:22
 msgid "confirm_reset"
 msgstr "Confirmation de réinitialisation"
 
@@ -771,7 +788,7 @@
 msgid "Page %(number)s of  %(num_pages)s"
 msgstr "Page %(number)s de  %(num_pages)s"
 
-#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:52
+#: .\ldt_utils\templates\ldt\ldt_utils\workspace_base.html.py:51
 msgid "content list"
 msgstr "Liste des contenus"
 
@@ -969,7 +986,7 @@
 "(project_titles)s'.Veuillez les effacer préalablement."
 
 #: .\ldt_utils\views\json.py:40 .\ldt_utils\views\rdf.py:15
-#: .\ldt_utils\views\workspace.py:127
+#: .\ldt_utils\views\workspace.py:173
 msgid "You can not access this project"
 msgstr "vous n'avez pas l'autorisation d'accéder à ce projet"
 
@@ -1005,6 +1022,15 @@
 msgid "confirm deletion"
 msgstr "Confirmation d'effacement"
 
+#: .\ldt_utils\views\workspace.py:125
+msgid ""
+"The content does not exists or you are not allowed to access this content"
+msgstr ""
+
+#: .\ldt_utils\views\workspace.py:129
+msgid "Parameters project_id or content_id must be given in the url"
+msgstr ""
+
 #: .\templates\admin\cms_change_form.html.py:30
 msgid "Approve page deletion"
 msgstr "Accepter l'effacement de la page"
--- a/src/ldt/ldt/static/ldt/css/workspace.css	Thu Oct 04 19:07:33 2012 +0200
+++ b/src/ldt/ldt/static/ldt/css/workspace.css	Mon Oct 08 12:34:11 2012 +0200
@@ -7,7 +7,8 @@
 }
 
 .ldt_player_code {
-	width: 580px;
+	width: 650px;
+	min-height: 250px;
 	overflow: auto;
 	border-style: inset;
 	border: 1px solid silver;