# HG changeset patch # User veltr # Date 1371546530 -7200 # Node ID a86208b60c91d1146ee58383b93ea65c885cc421 # Parent 3210bf928a118d4aacda2fee0835d80893fd6c2d Bugfixes and changes for MDComposer diff -r 3210bf928a11 -r a86208b60c91 src/js/init.js --- a/src/js/init.js Thu May 16 13:34:02 2013 +0200 +++ b/src/js/init.js Tue Jun 18 11:08:50 2013 +0200 @@ -1,7 +1,9 @@ /* Initialization of the namespace */ if (typeof window.IriSP === "undefined") { - window.IriSP = {}; + window.IriSP = { + VERSION: "0.3.1" + }; } if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined" && parseFloat(window.jQuery().jquery) >= 1.7) { diff -r 3210bf928a11 -r a86208b60c91 src/js/model.js --- a/src/js/model.js Thu May 16 13:34:02 2013 +0200 +++ b/src/js/model.js Tue Jun 18 11:08:50 2013 +0200 @@ -1009,7 +1009,10 @@ return (_e.elementType === _listId); }); } else { - return this.contents[_listId] || new IriSP.List(this.directory); + if (typeof this.contents[_listId] === "undefined") { + this.contents[_listId] = new IriSP.List(this.directory); + } + return this.contents[_listId]; } }; diff -r 3210bf928a11 -r a86208b60c91 src/js/serializers/ldt.js --- a/src/js/serializers/ldt.js Thu May 16 13:34:02 2013 +0200 +++ b/src/js/serializers/ldt.js Tue Jun 18 11:08:50 2013 +0200 @@ -58,7 +58,22 @@ "id-ref": _data.id }, items: _source.getAnnotationTypes().filter(function(_at) { - return _at.media === _data; + switch (typeof _at.media) { + case "object": + return (_at.media === _data); + case "string": + return (_at.media === _data.id); + default: + var _ann = _at.getAnnotations(); + if (_ann) { + for (var i = 0; i < _ann.length; i++) { + if (_ann[i].getMedia() === _data) { + return true; + } + } + } + } + return false; }).map(function(_at) { return { "id-ref": _at.id @@ -78,6 +93,9 @@ return _res; }, serializer : function(_data, _source, _dest) { + if (_source.regenerateTags && !_data.regenerated) { + return; + } var _res = { id : _data.id, meta : { @@ -131,6 +149,7 @@ } _res.color = '#' + _c; } + _res.content = _data.content; _res.setMedia(_data.media); _res.setAnnotationType(_data.meta["id-ref"]); _res.setTags(IriSP._(_data.tags).pluck("id-ref")); @@ -153,14 +172,22 @@ id : _data.id, begin : _data.begin.milliseconds, end : _data.end.milliseconds, - content : { - title : _data.title || "", - description : _data.description || "", + content : IriSP._.defaults( + {}, + { + title : _data.title, + description : _data.description, audio : _data.audio, img: { src: _data.thumbnail } }, + _data.content, + { + title: "", + description: "" + } + ), color: _color, media : _data.media.id, meta : { @@ -170,13 +197,22 @@ "dc:creator" : _data.creator || _source.creator, "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator, // project : _source.projectId - }, - tags : IriSP._(_data.tag.id).map(function(_id) { + } + } + if (_source.regenerateTags) { + _res.tags = IriSP._(_data.keywords).map(function(_kw) { + return { + "id-ref": _source.__keywords[_kw.toLowerCase()].id + } + }); + } else { + _res.tags = IriSP._(_data.tag.id).map(function(_id) { return { "id-ref" : _id } - }) + }); } + _res.content.title = _data.title || _res.content.title || ""; _dest.annotations.push(_res); } }, @@ -238,6 +274,24 @@ annotations: [] }, _this = this; + if (_source.regenerateTags) { + _source.__keywords = {}; + _source.getAnnotations().forEach(function(a) { + IriSP._(a.keywords).each(function(kw) { + var lkw = kw.toLowerCase(); + if (typeof _source.__keywords[lkw] === "undefined") { + _source.__keywords[lkw] = { + id: IriSP.Model.getUID(), + title: kw, + regenerated: true + } + } + }); + }); + IriSP._(_source.__keywords).each(function(kw) { + _this.types.tag.serializer(kw, _source, _res); + }) + } _source.forEach(function(_list, _typename) { if (typeof _this.types[_typename] !== "undefined") { _list.forEach(function(_el) { @@ -275,6 +329,11 @@ if (typeof _data.meta !== "undefined") { _source.projectId = _data.meta.id; + _source.title = _data.meta["dc:title"] || _data.meta.title || ""; + _source.description = _data.meta["dc:description"] || _data.meta.description || ""; + _source.creator = _data.meta["dc:creator"] || _data.meta.creator || ""; + _source.contributor = _data.meta["dc:contributor"] || _data.meta.contributor || _source.creator; + _source.created = IriSP.Model.isoToDate(_data.meta["dc:created"] || _data.meta.created); } if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") { diff -r 3210bf928a11 -r a86208b60c91 src/js/utils.js --- a/src/js/utils.js Thu May 16 13:34:02 2013 +0200 +++ b/src/js/utils.js Tue Jun 18 11:08:50 2013 +0200 @@ -57,7 +57,7 @@ addToList(_regexp, '', ''); } - addToList(/(https?:\/\/)?\w+\.\w+\S+/gm, function(matches) { + addToList(/(https?:\/\/)?[\w\d\-]+\.[\w\d\-]+\S+/gm, function(matches) { return '' }, ''); addToList(/@([\d\w]{1,15})/gm, function(matches) { diff -r 3210bf928a11 -r a86208b60c91 src/widgets/Annotation.js --- a/src/widgets/Annotation.js Thu May 16 13:34:02 2013 +0200 +++ b/src/widgets/Annotation.js Tue Jun 18 11:08:50 2013 +0200 @@ -13,9 +13,9 @@ fr: { watching: "Je regarde ", on_site: " sur ", - tags_: "Mots-clés :", - description_: "Description :", - excerpt_from: "Extrait de :", + tags_: "Mots-clés\u00a0:", + description_: "Description\u00a0:", + excerpt_from: "Extrait de\u00a0:", untitled: "Segment sans titre" }, en: { diff -r 3210bf928a11 -r a86208b60c91 src/widgets/CreateAnnotation.js --- a/src/widgets/CreateAnnotation.js Thu May 16 13:34:02 2013 +0200 +++ b/src/widgets/CreateAnnotation.js Tue Jun 18 11:08:50 2013 +0200 @@ -75,9 +75,9 @@ to_time: "à", at_time: "à", submit: "Envoyer", - add_keywords_: "Ajouter des mots-clés :", - add_polemic_keywords_: "Ajouter des mots-clés polémiques :", - your_name_: "Votre nom :", + add_keywords_: "Ajouter des mots-clés\u00a0:", + add_polemic_keywords_: "Ajouter des mots-clés polémiques\u00a0:", + your_name_: "Votre nom\u00a0:", annotate_video: "Annoter cette vidéo", type_title: "Titre de l'annotation", type_description: "Rédigez ici le contenu de votre annotation.", diff -r 3210bf928a11 -r a86208b60c91 src/widgets/KnowledgeConcierge.js --- a/src/widgets/KnowledgeConcierge.js Thu May 16 13:34:02 2013 +0200 +++ b/src/widgets/KnowledgeConcierge.js Tue Jun 18 11:08:50 2013 +0200 @@ -19,8 +19,8 @@ IriSP.Widgets.KnowledgeConcierge.prototype.messages = { "fr": { related_videos: "Vidéos liées", - duration_: "Durée :", - for_keywords_: "pour le(s) mots-clé(s) :", + duration_: "Durée\u00a0:", + for_keywords_: "pour le(s) mots-clé(s)\u00a0:", no_matching_videos: "Pas de vidéos correspondantes" }, "en": { diff -r 3210bf928a11 -r a86208b60c91 src/widgets/Tweet.js --- a/src/widgets/Tweet.js Thu May 16 13:34:02 2013 +0200 +++ b/src/widgets/Tweet.js Tue Jun 18 11:08:50 2013 +0200 @@ -36,8 +36,8 @@ keep_visible: "Empêcher la fermeture automatique", dont_keep_visible: "Permettre la fermeture automatique", close_widget: "Fermer l'affichage du tweet", - original_time: "Heure d'envoi : ", - video_time: "Temps de la vidéo : ", + original_time: "Heure d'envoi\u00a0: ", + video_time: "Temps de la vidéo\u00a0: ", show_original: "Voir l'original" }, "en": { diff -r 3210bf928a11 -r a86208b60c91 test/json/ldt-jwplayer.json --- a/test/json/ldt-jwplayer.json Thu May 16 13:34:02 2013 +0200 +++ b/test/json/ldt-jwplayer.json Tue Jun 18 11:08:50 2013 +0200 @@ -1104,7 +1104,7 @@ "img": { "src": "" }, - "title": "Introduction de Constance Parodi", + "title": "Introduction de Constance Parodi http://iri-veille.tumblr.com/", "color": "3355443", "polemics": [], "audio": { diff -r 3210bf928a11 -r a86208b60c91 test/jwplayer.htm --- a/test/jwplayer.htm Thu May 16 13:34:02 2013 +0200 +++ b/test/jwplayer.htm Tue Jun 18 11:08:50 2013 +0200 @@ -19,10 +19,10 @@ IriSP.language = 'fr'; IriSP.widgetsDir = "metadataplayer"; var _metadata = { -// url: 'json/ldt-jwplayer.json', + url: 'json/ldt-jwplayer.json', // url: 'http://capsicum/pf/ldtplatform/ldt/cljson/id/33e49eac-b3b0-11e1-b44d-00145ea4a2be?callback=?', // url: 'http://capsicum/pf/ldtplatform/ldt/cljson/id/f1a17368-2bc8-11e1-b21a-00145ea49a02', - url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/fc0a654e-49ea-11e2-b4ad-00145ea4a2be', +// url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/fc0a654e-49ea-11e2-b4ad-00145ea4a2be', format: 'ldt' }; var _config = {