# HG changeset patch # User ymh # Date 1276560827 -7200 # Node ID d42bb045f7d103cbcb2fa4066098433780e61a10 # Parent cef485504ba8e6be17e99d297845fed03ea91949 apply changes from eulalie diff -r cef485504ba8 -r d42bb045f7d1 sbin/sync/sync_ldt_platform --- 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 diff -r cef485504ba8 -r d42bb045f7d1 web/franceculture/templates/franceculture/embed_popup.html --- 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 @@ }); - + - + diff -r cef485504ba8 -r d42bb045f7d1 web/franceculture/templates/franceculture/partial/embed.html --- 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 @@
\ No newline at end of file diff -r cef485504ba8 -r d42bb045f7d1 web/franceculture/templates/franceculture/workspace.html --- 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 @@ {% trans "open ldt" %} {% trans "create project" %} {% url ldt.ldt_utils.views.project_json_externalid content.external_id as json_url_externalid %} - {% trans "link json by externalid" %} + {% trans "link json by externalid" %} {% endfor %} @@ -97,7 +97,7 @@ {% trans "open ldt" %} {% trans "copy project" %} {% url ldt.ldt_utils.views.project_json_id project.ldt_id as json_url_id %} - {% trans "link json by id" %} + {% trans "link json by id" %} {% endfor %} diff -r cef485504ba8 -r d42bb045f7d1 web/ldt/ldt_utils/fileimport.py --- 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') diff -r cef485504ba8 -r d42bb045f7d1 web/ldt/ldt_utils/models.py --- 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() diff -r cef485504ba8 -r d42bb045f7d1 web/ldt/ldt_utils/utils.py --- 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() diff -r cef485504ba8 -r d42bb045f7d1 web/static/css/LdtPlayer.css --- /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 diff -r cef485504ba8 -r d42bb045f7d1 web/static/js/LdtPlayer.js --- 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("
").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("
").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("
hello
"); - + function playerLdt (width,height,file,divId,MySwfPath){ $jIRI("#"+divId).append("
\n
\n
\n
\n
\n Get flash to see this player \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n \n \n
\n
"); - 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(){