apply changes from eulalie
authorymh <ymh.work@gmail.com>
Tue, 15 Jun 2010 02:13:47 +0200
changeset 5 d42bb045f7d1
parent 4 cef485504ba8
child 6 17530fd08ced
apply changes from eulalie
sbin/sync/sync_ldt_platform
web/franceculture/templates/franceculture/embed_popup.html
web/franceculture/templates/franceculture/partial/embed.html
web/franceculture/templates/franceculture/workspace.html
web/ldt/ldt_utils/fileimport.py
web/ldt/ldt_utils/models.py
web/ldt/ldt_utils/utils.py
web/static/css/LdtPlayer.css
web/static/js/LdtPlayer.js
--- a/sbin/sync/sync_ldt_platform	Sat Jun 12 05:19:30 2010 +0200
+++ b/sbin/sync/sync_ldt_platform	Tue Jun 15 02:13:47 2010 +0200
@@ -27,3 +27,5 @@
     echo "Deleting temp export"
     rm -fr ~/tmp/franceculture_V$1;
 fi
+
+ssh iri@web.iri.centrepompidou.fr sudo apache2ctl restart
--- a/web/franceculture/templates/franceculture/embed_popup.html	Sat Jun 12 05:19:30 2010 +0200
+++ b/web/franceculture/templates/franceculture/embed_popup.html	Tue Jun 15 02:13:47 2010 +0200
@@ -31,11 +31,11 @@
 			});
 		</script>
 		
-		<link rel="stylesheet" href="{{MEDIA_URL}}css/custom_player.css" type="text/css"/>
+		
 		<link rel="stylesheet" href="{{MEDIA_URL}}css/workspace.css" type="text/css"/>
 		<link type="text/css" href="{{MEDIA_URL}}css/jq-css/themes/base/jquery.ui.all.css" rel="stylesheet" />
 		<link type="text/css" href="{{MEDIA_URL}}css/jq-css/demos.css" rel="stylesheet" />
-		
+		<link rel="stylesheet" href="{{MEDIA_URL}}css/LdtPlayer.css" type="text/css"/>
 	</head>
 
 	<body id="init_embed_popup">
--- a/web/franceculture/templates/franceculture/partial/embed.html	Sat Jun 12 05:19:30 2010 +0200
+++ b/web/franceculture/templates/franceculture/partial/embed.html	Tue Jun 15 02:13:47 2010 +0200
@@ -1,5 +1,5 @@
 <div id="{{ player_id }}">
 </div>
 <script type="text/javascript">
-    playerLdt(550,310, "{{ json_url }}","{{ player_id }}");
+    playerLdt(550,310, "{{ json_url }}","{{ player_id }}","{{WEB_URL}}{{MEDIA_URL}}swf/player.swf");
 </script>
\ No newline at end of file
--- a/web/franceculture/templates/franceculture/workspace.html	Sat Jun 12 05:19:30 2010 +0200
+++ b/web/franceculture/templates/franceculture/workspace.html	Tue Jun 15 02:13:47 2010 +0200
@@ -81,7 +81,7 @@
         <td><a href="{% url ldt.ldt_utils.views.index content.iri_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
         <td><a href="{% url ldt.ldt_utils.views.create_project content.iri_id %}" class="ldt_link_create">{% trans "create project" %}</a></td>
         {% url ldt.ldt_utils.views.project_json_externalid content.external_id as json_url_externalid %}
-        <td><a href="{{json_url_externalid}}" class="ldt_link_embed" id="player_project_{{content.iri_id}}">{% trans "link json by externalid" %}</a>
+        <td><a href="{{WEB_URL}}{{json_url_externalid}}" class="ldt_link_embed" id="player_project_{{content.iri_id}}">{% trans "link json by externalid" %}</a>
         </td>
     </tr>
 {% endfor %}
@@ -97,7 +97,7 @@
         <td><a href="{% url ldt.ldt_utils.views.indexProject project.ldt_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
         <td><a href="{% url ldt.ldt_utils.views.copy_project project.ldt_id %}" class="ldt_link_create">{% trans "copy project" %}</a></td>
         {% url ldt.ldt_utils.views.project_json_id project.ldt_id as json_url_id %}
-        <td><a href="{{json_url_id}}" class="ldt_link_embed" id="player_project_{{project.ldt_id}}">{% trans "link json by id" %}</a>
+        <td><a href="{{WEB_URL}}{{json_url_id}}" class="ldt_link_embed" id="player_project_{{project.ldt_id}}">{% trans "link json by id" %}</a>
     </tr>
 {% endfor %}
 </table>
--- a/web/ldt/ldt_utils/fileimport.py	Sat Jun 12 05:19:30 2010 +0200
+++ b/web/ldt/ldt_utils/fileimport.py	Tue Jun 15 02:13:47 2010 +0200
@@ -50,21 +50,18 @@
         if 'http' in self.src:
             url = urllib.urlopen(self.src)
             doc = xml.dom.minidom.parse(url)
-            doc = Ft.Xml.Domlette.ConvertDocument(doc)             
-            con = xml.xpath.Context.Context(doc, 1, 1, None)
-            #open .iri and get the title
-            res = xml.xpath.Evaluate("/iri/head/meta[@name='title']/@content", context=con)
-            self.title = res[0].value
-            
         #for import a zip, get title and copy file .iri in the media directory
         else:
             path = os.path.join(self.basepath, self.src)
             doc = xml.dom.minidom.parse(path)
-            
-            con = xml.xpath.Context.Context(doc, 1, 1, None)
-            
-            res = xml.xpath.Evaluate("/iri/head/meta[@name='title']/@content", context=con)
-            self.title = res[0].value
+        
+        
+        doc = Ft.Xml.Domlette.ConvertDocument(doc) 
+        con = xml.xpath.Context.Context(doc, 1, 1, None)
+        
+        res = xml.xpath.Evaluate("/iri/head/meta[@name='title']/@content", context=con)
+        self.title = res[0].value
+
             
         res = xml.xpath.Evaluate("/iri/body/ensembles",context=con)
         ensemblesnode = res[0]
@@ -105,7 +102,7 @@
 
         res = xml.xpath.Evaluate("/iri/body/medias/media[@id='video']/video", context=con)
         if self.flatten:
-            src_video = res[0].getAttribute('src')
+            src_video = res[0].getAttributeNS(None,'src')
             self.videourl = os.path.basename(src_video)
             res[0].setAttributeNS(None,'src', self.videourl)
         self.duration = res[0].getAttributeNS(None, u'dur')
--- a/web/ldt/ldt_utils/models.py	Sat Jun 12 05:19:30 2010 +0200
+++ b/web/ldt/ldt_utils/models.py	Tue Jun 15 02:13:47 2010 +0200
@@ -2,8 +2,7 @@
 from django.conf import settings
 from ldt.core.models import Document, Owner
 from django.utils.translation import ugettext_lazy as _
-from utils import create_ldt, copy_ldt, create_empty_iri
-import os
+from utils import create_ldt, copy_ldt, create_empty_iri, update_iri
 import os.path
 import uuid
 import xml
@@ -48,20 +47,28 @@
         writer.deleteDocuments(lucene.Term("iri_id", self.iri_id))
         writer.commit()
         
+    #TODO: better manage the change in .iri name and error scenario (save in temp file + rename
     def save(self):
         # create iri file if needed
+        created = False
         try:
             iri_file_path = self.iri_file_path()
             if not os.path.exists(iri_file_path):
                 dir = os.path.dirname(iri_file_path)
                 if not os.path.exists(dir):
                     os.makedirs(dir)
+                created = True
                 file = open(iri_file_path,"w")
                 create_empty_iri(file, self, "IRI")
+            else:
+                created = False
+                update_iri(iri_file_path, self, "IRI")
+                
         except Exception, e:
-            if os.path.exists(iri_file_path):
-                os.remove(iri_file_path)
-                raise e
+            if created:
+                if os.path.exists(iri_file_path):
+                    os.remove(iri_file_path)
+            raise e
         # update it 
         super(Content, self).save()
     
--- a/web/ldt/ldt_utils/utils.py	Sat Jun 12 05:19:30 2010 +0200
+++ b/web/ldt/ldt_utils/utils.py	Tue Jun 15 02:13:47 2010 +0200
@@ -10,9 +10,8 @@
 import xml.dom.minidom
 import xml.dom.ext
 import xml.xpath
-import os
-import os.path
 import datetime
+import Ft
 
 class LdtSearch(object):
 
@@ -277,6 +276,7 @@
     
     writer.simpleElement(u'meta', attributes={u'name':u'id', 'content':unicode(content.iri_id)})
     writer.simpleElement(u'meta', attributes={u'name':u'title', 'content':unicode(content.title)})
+    writer.simpleElement(u'meta', attributes={u'name':u'abstract', 'content':unicode(content.description)})
     writer.simpleElement(u'meta', attributes={u'name':u'author', 'content':unicode(username)})
     writer.simpleElement(u'meta', attributes={u'name':u'contributor', 'content':unicode(username)})
     writer.simpleElement(u'meta', attributes={u'name':u'date', 'content':unicode(datetime.date.today().isoformat())})
@@ -294,7 +294,7 @@
     writer.startElement(u"medias")
 
     writer.startElement(u"media", attributes={u'id':u'video'})
-    writer.simpleElement(u'video', attributes={u'src':unicode(content.src),u'id':unicode(uuid.uuid1()),u'dur':unicode(content.duration),u'begin':u'0'})
+    writer.simpleElement(u'video', attributes={u'src':unicode(content.src),u'id':unicode(content.iri_id),u'dur':unicode(content.duration),u'begin':u'0'})
     writer.endElement(u"media")
 
     writer.startElement(u"media", attributes={u'id':u'tool'})
@@ -312,3 +312,43 @@
     writer.endElement(u"iri")
     writer.endDocument()
     
+def update_iri(filepath, content, username):
+    
+    # open xml
+    doc = xml.dom.minidom.parse(filepath)
+    doc = Ft.Xml.Domlette.ConvertDocument(doc) 
+    
+    con = xml.xpath.Context.Context(doc, 1, 1, None)
+    res = xml.xpath.Evaluate("/iri/heqd/meta", context=con)
+    # update meta
+    
+    for meta_node in res:
+        meta_name = meta_node.getAttributeNS(None,"name")
+        content_attr = None
+        if meta_name == u'id':
+            content_attr = unicode(content.iri_id)
+        elif meta_name == u'title':
+            content_attr = unicode(content.title)
+        elif meta_name == u'abstract':
+            content_attr = unicode(content.description)
+        elif meta_name == u'contributor':
+            content_attr = unicode(username)
+        elif meta_name == u"date":
+            content_attr = unicode(datetime.date.today().isoformat())
+        if content_attr is not None:
+            meta_node.setAttributeNS(None, u"content", content_attr)
+
+    res = xml.xpath.Evaluate("/iri/body/medias/media[@id='video']/video", context=con)
+    
+    if len(res) > 0:
+        video_node = res[0]
+        video_node.setAttributeNS(None, u'src', unicode(content.src))
+        video_node.setAttributeNS(None, u'dur', unicode(content.duration))
+        video_node.setAttributeNS(None, u'id', unicode(content.iri_id))
+    # update video
+    
+    f = open(filepath, "w")
+    try:
+        xml.dom.ext.Print(doc, stream=f)
+    finally:
+        f.close()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/static/css/LdtPlayer.css	Tue Jun 15 02:13:47 2010 +0200
@@ -0,0 +1,56 @@
+		#demo-frame > div.demo { padding: 5px !important; };
+		.iri-chapter{
+			padding-top:10px;
+			padding-bottom:5px;
+			border-left:solid 1px #aaaaaa;
+			border-right:solid 1px #aaaaaa;'
+		}
+		
+		.tooltip {
+			display:none;
+			background:transparent url(jq-css/tooltip/white_arrow.png);
+			font-size:12px;
+			height:100px;
+			width:180px;
+			padding:10px;
+			padding-left:15px;
+			padding-right:15px;
+			color:#000;	
+		}
+		
+		#Annotations{
+			padding-left:5px;
+			width:470px;
+			float:left;
+		}
+		#ldtSaTitle{
+			padding-top:2px;
+			padding-bottom:5px;
+			font-size:18px;
+			color:#FFF;	
+			height:22p;
+		}
+		#ldtSaDescription{
+			font-size:12px;	
+			color:#FFF;	
+		}
+		#ShowAnnotation{
+			position:absolute;
+			z-index: 999;
+			padding:5px;
+			background:url(css/custom/images/transBlack.png);
+		}
+		
+		#ldtPlaceHolder{
+			position:absolue;
+			float:none;
+		}
+		.ldtControl1{
+			width:70px;
+			float:left;
+		}
+		.ldtControl2{
+			padding-left:10px;
+			width:70px;
+			float:left;
+		}
\ No newline at end of file
--- a/web/static/js/LdtPlayer.js	Sat Jun 12 05:19:30 2010 +0200
+++ b/web/static/js/LdtPlayer.js	Tue Jun 15 02:13:47 2010 +0200
@@ -3,10 +3,10 @@
    ----------------------------------------------------------------
    
 	LDTPlayer is created by http://www.iri.centrepompidou.fr
-	2010-06-10
+	2010-06-14 - version 0.07
 	
-	Initiated By Samuel Huron < samuel.huron (at) cybunk (dot) com
-	this version is the 0.06
+	init By Samuel Huron < samuel.huron (at) cybunk (dot) com >
+	
 	
    ----------------------------------------------------------------
 */
@@ -146,14 +146,14 @@
 		if (tmp) { tmp.innerHTML = "volume: " + currentVolume; }
 	}
 
-	function createPlayer(width,height,url) {
+	function createPlayer(width,height,url,duration,streamerPath,MySwfPath) {
 	
-		myUrlFragment = url.split("/");
-		//
-		file = myUrlFragment[myUrlFragment.length-3]+"/"+myUrlFragment[myUrlFragment.length-2]+"/"+myUrlFragment[myUrlFragment.length-1];
-		indexofff = url.lastIndexOf(file);
-		streamer = url.substr(0,indexofff);
-		alert(url+"="+streamer+" - "+file);
+		myUrlFragment = url.split(streamerPath);
+		file = myUrlFragment[1];
+		alert(url+" = "+streamerPath+" + "+file);
+		streamer = streamerPath;
+		//alert(" StreamerPath : "+streamer+" - "+file);
+		//alert(" SwfPath : "+MySwfPath);
 		
 		var flashvars = {
 			streamer:streamer,
@@ -174,7 +174,7 @@
 			name:"Ldtplayer1"
 		}
 
-		swfobject.embedSWF("swf/player.swf", "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes);
+		swfobject.embedSWF(MySwfPath, "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes);
 	}
 	
 
@@ -194,19 +194,62 @@
 	var playerLdtWidth;
 	var playerLdtHeight;
 	
-	function loadJson (width,height,urlJson){
+	function loadJson (width,height,urlJson,MySwfPath){
 		
 		playerLdtWidth=width;
 		playerLdtHeight=height;
 		
 		$jIRI.ajax({
 					  dataType: 'jsonp',
-					  url:urlJson,
+					  url:urlJson,//+"?callback=callbackLdts",
+					  //jsonpCallback:callbackLdts,
 					  success: function(json){
 						
-						//alert("success !");
-					
+						//eval(json);
+						//alert("callback LDTS");
+						/* START PARSING ----------------------- */
+						/* metas , medias , annotation-types , annotations , lists , tags , views */
+						/* # fonction avec 1 seul  media et 1 seul annotation type  code a cleaner */
+						/* # créer le player 				   */
+						//$jIRI.each(json.medias, function(i,item) {
+						//});
+						$jIRI("<div></div>").appendTo("#output");
+						MyMedia = new  Media(json.medias[0].id,json.medias[0].href,json.medias[0]["meta"]["dc:duration"],json.medias[0]['dc:title'],json.medias[0]['dc:description']);
+						//alert(" MySwfPath : "+MySwfPath);
+						MyMedia.createPlayer(playerLdtWidth,playerLdtHeight,json.medias[0]["meta"]["item"]["value"],MySwfPath);
+						//alert("success loading ! "+json.medias[0]["meta"]["dc:duration"]+ " | " +json.medias[0]["meta"]["item"]["value"]);
+						
+						/* # créer lignes 				   */
+						/*$jIRI.each(json['annotation-types'], function(i,item) {
+						});*/	
+						MyLdt = new Ligne (json['annotation-types'][0].id,json['annotation-types'][0]['dc:title'],json['annotation-types'][0]['dc:description'],json.medias[0]["meta"]["dc:duration"]);
+						//alert("duration : "+json.medias[0]["dc:duration"]);
 						
+						/* # créer les annotations 				   */
+						$jIRI.each(json.annotations, function(i,item) {
+
+							MyLdt.addAnnotation(
+										item.id,
+										item.begin,
+										item.end,
+										item.media,
+										item.content.title,
+										item.content.description,
+										item.content.color);
+						
+						});	
+						$jIRI.each(json.lists, function(i,item) {
+							trace("lists","");
+						});		
+						$jIRI.each(json.tags, function(i,item) {
+							trace("tags","");
+						});	
+						$jIRI.each(json.views, function(i,item) {
+							trace("views","");
+						});	
+						/* END PARSING ----------------------- */
+						
+										
 					}
 					,error: function(data){
 						  alert("ERROR : "+data);
@@ -215,45 +258,6 @@
 	}
 
 	function callbackLdts(json){
-		/* START PARSING ----------------------- */
-		/* metas , medias , annotation-types , annotations , lists , tags , views */
-		/* # fonction avec 1 seul  media et 1 seul annotation type  code a cleaner */
-		/* # créer le player 				   */
-		//$jIRI.each(json.medias, function(i,item) {
-		//});
-		$jIRI("<div></div>").appendTo("#output");
-		MyMedia = new  Media(json.medias[0].id,json.medias[0].url,json.medias[0]["dc:duration"],json.medias[0]['dc:title'],json.medias[0]['dc:description']);
-		MyMedia.createPlayer(playerLdtWidth,playerLdtHeight);
-
-		/* # créer lignes 				   */
-		/*$jIRI.each(json['annotation-types'], function(i,item) {
-		});*/	
-		MyLdt = new Ligne (json['annotation-types'][0].id,json['annotation-types'][0]['dc:title'],json['annotation-types'][0]['dc:description'],json.medias[0]["dc:duration"]);
-		//alert("duration : "+json.medias[0]["dc:duration"]);
-		
-		/* # créer les annotations 				   */
-		$jIRI.each(json.annotations, function(i,item) {
-
-			MyLdt.addAnnotation(
-						item.id,
-						item.begin,
-						item.end,
-						item.media,
-						item.content.title,
-						item.content.description,
-						item.content.color);
-		
-		});	
-		$jIRI.each(json.lists, function(i,item) {
-			trace("lists","");
-		});		
-		$jIRI.each(json.tags, function(i,item) {
-			trace("tags","");
-		});	
-		$jIRI.each(json.views, function(i,item) {
-			trace("views","");
-		});	
-		/* END PARSING ----------------------- */
 		
 	}
 	
@@ -269,13 +273,10 @@
 INIT player LDT  
 */
 
-	function playerLdt (width,height,file,divId){
-	
-		//$jIRI("#playerLdt").append("<div id=\"div1\">hello</div>");
-		
+	function playerLdt (width,height,file,divId,MySwfPath){
 		
 			$jIRI("#"+divId).append("<div id=\"ldtShow\">\n	<div id=\"ShowAnnotation\" class=\"demo\" >\n			<div id=\"ldtSaTitle\"></div>\n			<div id=\"ldtSaDescription\"></div>\n		</div>		<div id=\"ldtPlaceHolder\">\n			<a href=\"http://www.adobe.com/go/getflashplayer\">Get flash</a> to see this player	\n		</div>\n	</div>\n	<div id=\"controlerLdt\" class=\"demo\">\n		<div class=\"ldtControl1\" >\n			<button id=\"ldtCtrlPlay\" onclick=\"player.sendEvent('PLAY')\">Play</button>\n			<button id=\"ldtCtrlNext\" onclick=\"player.sendEvent('SEEK', currentPosition+10)\">next</button>\n		</div>\n		<div id=\"Annotations\" class=\"ui-slider\">\n			<div id=\"slider-range-min\"></div>\n		</div>\n		<div class=\"ldtControl2\">\n			<button id=\"ldtCtrlScreen\" onclick=\"player.fullscreen('true')\">Enlarge</button>\n			<button id=\"ldtCtrlSound\" onclick=\"player.sendEvent('MUTE')\">Sound</button>\n		</div>\n	</div>");
-			loadJson(width,height,file);
+			loadJson(width,height,file,MySwfPath);
 	}
 	
 	
@@ -328,8 +329,9 @@
 		trace("- content : color",url);
 		trace("- content : audio",title);
 	}
-	function createPlayerMedia(width,height){
-		createPlayer(width,height,this.url,this.duration);
+	function createPlayerMedia(width,height,MyStreamer,MySwfPath){
+		//alert("create swfpath : "+MySwfPath+" my streame : "+MyStreamer);
+		createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
 		createInterface(width,height,this.duration);
 	}
 	function updatePlayerMedia(){