# HG changeset patch # User Raphael Velt # Date 1337698055 -7200 # Node ID 5b7d7ab6baffa1f342e25aece281fdabad04dd13 # Parent 7e5174fe98163bbf33aeee829508f5eeb7fc25b7 re-enabled traces diff -r 7e5174fe9816 -r 5b7d7ab6baff web/edito-arts-numeriques/config.php --- a/web/edito-arts-numeriques/config.php Mon May 21 18:53:02 2012 +0200 +++ b/web/edito-arts-numeriques/config.php Tue May 22 16:47:35 2012 +0200 @@ -47,5 +47,5 @@ // After the event 'metadata' => "http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/99d311d0-8d5e-11e1-aa20-00145ea4a2be", - 'pad_url' => 'http://pads.iri-research.org/p/edito-arts-numeriques?showControls=true&showChat=true&showLineNumbers=true&useMonospaceFont=false' +// 'pad_url' => 'http://pads.iri-research.org/p/edito-arts-numeriques?showControls=true&showChat=true&showLineNumbers=true&useMonospaceFont=false' ); \ No newline at end of file diff -r 7e5174fe9816 -r 5b7d7ab6baff web/player_embed.php --- a/web/player_embed.php Mon May 21 18:53:02 2012 +0200 +++ b/web/player_embed.php Tue May 22 16:47:35 2012 +0200 @@ -61,7 +61,11 @@ { type: "Arrow" }, { type: "Annotation" }, { type: "Tweet" }, - { type: "Mediafragment"} + { type: "Mediafragment"}, + { + type: "Trace", + default_subject: "PolemicTweet-player" + } ] }, player:{ diff -r 7e5174fe9816 -r 5b7d7ab6baff web/polemicaltimeline.php --- a/web/polemicaltimeline.php Mon May 21 18:53:02 2012 +0200 +++ b/web/polemicaltimeline.php Tue May 22 16:47:35 2012 +0200 @@ -121,7 +121,11 @@ //foreign_url : "http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}", container: "AnnotationsListContainer" }, - { type: "Mediafragment"} + { type: "Mediafragment"}, + { + type: "Trace", + default_subject: "PolemicTweet-player" + } ] }, player:{ diff -r 7e5174fe9816 -r 5b7d7ab6baff web/res/js/tracemanager.js --- a/web/res/js/tracemanager.js Mon May 21 18:53:02 2012 +0200 +++ b/web/res/js/tracemanager.js Tue May 22 16:47:35 2012 +0200 @@ -1,7 +1,24 @@ /* * Modelled Trace API + * + * This file is part of ktbs4js. + * + * ktbs4js is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * ktbs4js is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with ktbs4js. If not, see . + * */ -IriSP.TraceManager = function($) { +/* FIXME: properly use require.js feature. This will do for debugging in the meantime */ +window.tracemanager = (function($) { // If there are more than MAX_FAILURE_COUNT synchronisation // failures, then disable synchronisation MAX_FAILURE_COUNT = 20; @@ -74,10 +91,10 @@ /* Sync mode: delayed, sync (immediate sync), none (no * synchronisation with server, the trace has to be explicitly saved * if needed */ - set_sync_mode: function(mode) { + set_sync_mode: function(mode, default_subject) { this.sync_mode = mode; if (! this.isReady && mode !== "none") - this.init(); + this.init(default_subject); if (mode == 'delayed') { this.start_timer(); } else { @@ -120,14 +137,16 @@ /* * Initialize the sync service */ - init: function() { + init: function(default_subject) { var self = this; if (this.isReady) /* Already initialized */ return; + if (typeof default_subject === 'undefined') + default_subject = 'anonymous'; if (this.mode == 'GET') { - var request=$('').attr('src', this.url + 'login?userinfo={"name":"ktbs4js"}'); + var request=$('').attr('src', this.url + 'login?userinfo={"default_subject": "' + default_subject + '"}'); // Do not wait for the return, assume it is // initialized. This assumption will not work anymore // if login returns some necessary information @@ -137,7 +156,7 @@ { $.ajax({ url: this.url + 'login', type: 'POST', - data: 'userinfo={"name":"ktbs4js"}', + data: 'userinfo={"default_subject":"' + default_subject + '"}', success: function(data, textStatus, jqXHR) { self.isReady = true; if (self.buffer.length) { @@ -195,7 +214,7 @@ * if needed */ set_sync_mode: function(mode) { if (this.syncservice !== null) { - this.syncservice.set_sync_mode(mode); + this.syncservice.set_sync_mode(mode, this.default_subject); } }, @@ -248,6 +267,9 @@ }, set_default_subject: function(subject) { + // FIXME: if we call this method after the sync_service + // init method, then the default_subject will not be + // consistent anymore. Maybe we should then call init() again? this.default_subject = subject; }, @@ -434,8 +456,11 @@ var r = { "@t": (this.trace.shorthands.hasOwnProperty(this.type) ? this.trace.shorthands[this.type] : this.type), "@b": this.begin, - "@s": this.subject }; + // Transmit subject only if different from default_subject + if (this.subject !== this.trace.default_subject) + r["@s"] = this.subject; + // Store duration (to save some bytes) and only if it is non-null if (this.begin !== this.end) r["@d"] = this.end - this.begin; @@ -498,8 +523,8 @@ syncmode = params.syncmode ? params.syncmode : "none"; default_subject = params.default_subject ? params.default_subject : "default"; var t = new Trace(url, requestmode); + t.set_default_subject(default_subject); t.set_sync_mode(syncmode); - t.set_default_subject(default_subject); this.traces[name] = t; return t; } @@ -512,4 +537,4 @@ var tracemanager = new TraceManager(); return tracemanager; - }; + })(jQuery); diff -r 7e5174fe9816 -r 5b7d7ab6baff web/res/metadataplayer/Annotation.css --- a/web/res/metadataplayer/Annotation.css Mon May 21 18:53:02 2012 +0200 +++ b/web/res/metadataplayer/Annotation.css Tue May 22 16:47:35 2012 +0200 @@ -4,7 +4,6 @@ border-color: #b7b7b7; padding: 0 1px 1px; margin: 0; - font-family: Helvetica, Arial, sans-serif; } .Ldt-Annotation-Widget.Ldt-Annotation-ShowTop { @@ -20,11 +19,15 @@ .Ldt-Annotation-Inner h3 { margin: 5px 0; - font-size: 15px; + font-size: 14px; font-weight: bold; } -.Ldt-Annotation-Title { +.Ldt-Annotation-Inner h3.Ldt-Annotation-MashupOrigin { + font-size: 12px; +} + +.Ldt-Annotation-Title, .Ldt-Annotation-MashupMedia { color: #0068c4; } @@ -76,16 +79,39 @@ display: none; } +.Ldt-Annotation-TagTitle { + margin: 5px 0 2px; font-size: 12px; +} + ul.Ldt-Annotation-Tags { - list-style: none; padding: 0; margin: 5px 0; + display: inline; list-style: none; padding: 0; margin: 5px 0; +} + +li.Ldt-Annotation-TagLabel { + display: inline-block; border: none; margin: 0 10px 5px 0; height: 23px; padding: 0 0 0 20px; + background: url(img/tag.png) left top no-repeat; + cursor: pointer; } -.Ldt-Annotation-Tags li { - display: inline-block; margin: 0 3px 0 0; padding: 0; +.Ldt-Annotation-TagLabel span { + display: inline-block; font-size: 12px; height: 19px; padding: 4px 5px 0 0; border: none; margin: 0; + background: url(img/tag.png) right top no-repeat; +} + +li.Ldt-Annotation-TagLabel:hover { + background-position: left -23px; } -.Ldt-Annotation-TagLabel { - font-weight: bold; +.Ldt-Annotation-TagLabel:hover span { + background-position: right -23px; +} + +.Ldt-Annotation-MashupOrigin { + display: none; +} + +.Ldt-Annotation-isMashup .Ldt-Annotation-MashupOrigin { + display: block; } .Ldt-Annotation-Empty .Ldt-Annotation-HiddenWhenEmpty { diff -r 7e5174fe9816 -r 5b7d7ab6baff web/res/metadataplayer/Annotation.js --- a/web/res/metadataplayer/Annotation.js Mon May 21 18:53:02 2012 +0200 +++ b/web/res/metadataplayer/Annotation.js Tue May 22 16:47:35 2012 +0200 @@ -12,26 +12,30 @@ share_on: "Partager sur", watching: "Je regarde ", on_site: " sur ", - tags: "Mots-clés :" + tags: "Mots-clés :", + excerpt_from: "Extrait de :" }, "en": { share_on: "Share on", watching: "I'm watching ", on_site: " on ", - tags: "Keywords:" + tags: "Keywords:", + excerpt_from: "Excerpt from:" } } IriSP.Widgets.Annotation.prototype.template = '
' + '
' - + '' - + '' - + '' + + '' + + '' + + '' + '

' + '( - )

' + + '

{{l10n.excerpt_from}} ' + + '( - )

' + '

' - + '
{{l10n.tags}}
    '; + + '
    {{l10n.tags}}
      '; IriSP.Widgets.Annotation.prototype.defaults = { annotation_type : "chap", @@ -78,10 +82,22 @@ var _tags = _annotation.getTagTexts(); if (_tags.length) { var _html = IriSP._(_tags).map(function(_tag) { - return '
    • ' + _tag + '
    • '; + return '
    • ' + _tag + '
    • '; }).join(""); this.$.find(".Ldt-Annotation-Tags").html(_html); this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-NoTags"); + + /* Correct the empty tag bug */ + this.$.find('.Ldt-Annotation-TagLabel').each(function() { + var _el = IriSP.jQuery(this); + if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { + _el.detach(); + } + }); + + this.$.find('.Ldt-Annotation-TagLabel').click(function() { + _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); + }); } else { this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-NoTags"); } @@ -89,6 +105,14 @@ this.$.find(".Ldt-Annotation-Description").html(_annotation.description); this.$.find(".Ldt-Annotation-Begin").html(_annotation.begin.toString()); this.$.find(".Ldt-Annotation-End").html(_annotation.end.toString()); + if (_annotation.elementType === "mashedAnnotation") { + this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-isMashup"); + this.$.find(".Ldt-Annotation-MashupMedia").html(_annotation.getMedia().title); + this.$.find(".Ldt-Annotation-MashupBegin").html(_annotation.annotation.begin.toString()); + this.$.find(".Ldt-Annotation-MashupEnd").html(_annotation.annotation.end.toString()); + } else { + this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup"); + } this.$.find(".Ldt-Annotation-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text })); this.$.find(".Ldt-Annotation-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text })); this.$.find(".Ldt-Annotation-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text })); diff -r 7e5174fe9816 -r 5b7d7ab6baff web/res/metadataplayer/AnnotationsList.js --- a/web/res/metadataplayer/AnnotationsList.js Mon May 21 18:53:02 2012 +0200 +++ b/web/res/metadataplayer/AnnotationsList.js Tue May 22 16:47:35 2012 +0200 @@ -6,6 +6,7 @@ this.throttledRefresh = IriSP._.throttle(function() { _this.refresh(false); }, 1500); + this.mashupMode = (this.source.currentMedia.elementType === "mashup"); }; IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); @@ -23,7 +24,6 @@ * e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}} */ foreign_url : "", - cinecast_version : false, annotation_type : false, refresh_interval : 0, limit_count : 10, @@ -34,7 +34,7 @@ ''; -IriSP.Widgets.AnnotationsList.prototype.clear = function() { -}; - -IriSP.Widgets.AnnotationsList.prototype.clearWidget = function() { -}; - IriSP.Widgets.AnnotationsList.prototype.onSearch = function(searchString) { this.searchString = typeof searchString !== "undefined" ? searchString : ''; var _n = this.refresh(true); @@ -99,6 +93,27 @@ }, this.metadata)); } +IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() { + var _currentTime = this.player.popcorn.currentTime(); + if (typeof _currentTime == "undefined") { + _currentTime = 0; + } + var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); + if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.namespacedId.name !== this.lastMashupAnnotation) { + this.lastMashupAnnotation = _currentAnnotation.namespacedId.name; + var _currentMedia = _currentAnnotation.getMedia(), + _url = Mustache.to_html(this.ajax_url, { + media : _currentMedia.namespacedId.name, + begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity), + end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity) + }); + console.log("Getting", _url); + this.currentSource = this.player.loadMetadata(IriSP._.defaults({ + "url" : _url + }, this.metadata)); + } +} + IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) { _forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw); if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) { @@ -109,7 +124,17 @@ if (typeof _currentTime == "undefined") { _currentTime = 0; } - var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type, true) : this.currentSource.getAnnotations(); + var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations(); + if (this.mashupMode) { + var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000); + if (typeof _currentAnnotation !== "undefined") { + _currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds(); + var _mediaId = _currentAnnotation.getMedia().namespacedId.name; + _list = _list.filter(function(_annotation) { + return _annotation.getMedia().namespacedId.name === _mediaId; + }); + } + } if (this.searchString) { _list = _list.searchByTextFields(this.searchString); } @@ -152,7 +177,7 @@ ) ); var _res = { - id : _annotation.id, + id : _annotation.namespacedId.name, title : _annotation.title.replace(_annotation.description,''), description : _annotation.description, begin : _annotation.begin.toString(), @@ -170,6 +195,14 @@ }); this.$.html(_html); + + /* Correct the empty tag bug */ + this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() { + var _el = IriSP.jQuery(this); + if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { + _el.detach(); + } + }); this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); @@ -184,9 +217,13 @@ } } - if (this.ajax_url && this.ajax_granularity) { - if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) { - this.ajaxSource(); + if (this.ajax_url) { + if (this.mashupMode) { + this.ajaxMashup(); + } else { + if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity / 2000)) { + this.ajaxSource(); + } } } return _list.length; @@ -200,8 +237,12 @@ var _this = this; - if (this.ajax_url && this.ajax_granularity) { - this.ajaxSource(); + if (this.ajax_url) { + if (this.mashupMode) { + this.ajaxMashup(); + } else { + this.ajaxSource(); + } } else { this.currentSource = this.source; } diff -r 7e5174fe9816 -r 5b7d7ab6baff web/res/metadataplayer/Controller.js --- a/web/res/metadataplayer/Controller.js Mon May 21 18:53:02 2012 +0200 +++ b/web/res/metadataplayer/Controller.js Tue May 22 16:47:35 2012 +0200 @@ -100,7 +100,7 @@ this.$playButton.click(this.functionWrapper("playHandler")); this.$.find(".Ldt-Ctrl-Annotate").click(function() { - _this.player.popcorn.trigger("IriSP.Player.AnnotateButton.clicked"); + _this.player.popcorn.trigger("IriSP.CreateAnnotation.toggle"); }); this.$.find(".Ldt-Ctrl-SearchBtn").click(this.functionWrapper("searchButtonHandler")); diff -r 7e5174fe9816 -r 5b7d7ab6baff web/res/metadataplayer/LdtPlayer-core.js --- a/web/res/metadataplayer/LdtPlayer-core.js Mon May 21 18:53:02 2012 +0200 +++ b/web/res/metadataplayer/LdtPlayer-core.js Tue May 22 16:47:35 2012 +0200 @@ -30,6 +30,7 @@ /* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ IriSP.Metadataplayer = function(config, video_metadata) { + IriSP.log("IriSP.Metadataplayer constructor"); for (var key in IriSP.guiDefaults) { if (IriSP.guiDefaults.hasOwnProperty(key) && !config.gui.hasOwnProperty(key)) { config.gui[key] = IriSP.guiDefaults[key] @@ -48,22 +49,21 @@ } IriSP.Metadataplayer.prototype.loadLibs = function() { - - var $L = $LAB.script(IriSP.getLib("underscore")).script(IriSP.getLib("Mustache")).script(IriSP.getLib("jQuery")).script(IriSP.getLib("swfObject")).wait().script(IriSP.getLib("jQueryUI")); + IriSP.log("IriSP.Metadataplayer.prototype.loadLibs"); + var $L = $LAB + .script(IriSP.getLib("underscore")) + .script(IriSP.getLib("Mustache")) + .script(IriSP.getLib("jQuery")) + .script(IriSP.getLib("swfObject")) + .wait() + .script(IriSP.getLib("jQueryUI")); - if(this.config.player.type === "jwplayer" || this.config.player.type === "allocine" || this.config.player.type === "dailymotion") { - // load our popcorn.js lookalike + if (this.config.player.type === "jwplayer" || this.config.player.type === "auto") { $L.script(IriSP.getLib("jwplayer")); - } else { - // load the real popcorn - $L.script(IriSP.getLib("popcorn")).script(IriSP.getLib("popcorn.code")); - // load plugins if necessary - if(this.config.player.type === "youtube") { - $L.script(IriSP.getLib("popcorn.youtube")); - } - if(this.config.player.type === "vimeo"){ - $L.script(IriSP.getLib("popcorn.vimeo")); - } + } + + if (this.config.player.type !== "jwplayer" && this.config.player.type !== "allocine" && this.config.player.type !== "dailymotion") { + $L.script(IriSP.getLib("popcorn")); } /* widget specific requirements */ @@ -75,20 +75,23 @@ } var _this = this; - + IriSP.log($L); $L.wait(function() { - IriSP.jQuery = window.jQuery.noConflict(); - IriSP._ = window._.noConflict(); - - IriSP.loadCss(IriSP.getLib("cssjQueryUI")) - IriSP.loadCss(_this.config.gui.css); - _this.onLibsLoaded(); - }); } IriSP.Metadataplayer.prototype.onLibsLoaded = function() { + IriSP.log("IriSP.Metadataplayer.prototype.onLibsLoaded"); + if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined") { + IriSP.jQuery = window.jQuery.noConflict(); + } + if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined") { + IriSP._ = window._.noConflict(); + } + IriSP.loadCss(IriSP.getLib("cssjQueryUI")); + IriSP.loadCss(this.config.gui.css); + this.videoData = this.loadMetadata(this.video_metadata); this.$ = IriSP.jQuery('#' + this.config.gui.container); this.$.css({ @@ -168,10 +171,26 @@ } IriSP.Metadataplayer.prototype.configurePopcorn = function() { + IriSP.log("IriSP.Metadataplayer.prototype.configurePopcorn"); var pop, ret = this.layoutDivs("video"), containerDiv = ret[0], - spacerDiv = ret[1]; + spacerDiv = ret[1], + _this = this, + _types = { + "html5" : /\.(ogg|ogv|webm)$/, + "youtube" : /^(https?:\/\/)?(www\.)?youtube\.com/, + "dailymotion" : /^(https?:\/\/)?(www\.)?dailymotion\.com/ + }; + + if (this.config.player.type === "auto") { + this.config.player.type = "jwplayer"; + IriSP._(_types).each(function(_v, _k) { + if (_v.test(_this.config.player.video)) { + _this.config.player.type = _k + } + }); + } switch(this.config.player.type) { /* @@ -179,15 +198,22 @@ will contain the video. */ case "html5": - var tmpId = Popcorn.guid("video"); - IriSP.jQuery("#" + containerDiv).append(""); + var _tmpId = Popcorn.guid("video"), + _videoEl = IriSP.jQuery('