# HG changeset patch # User ymh # Date 1437221483 -7200 # Node ID 3097cb0581ac841782fda1e3114b18672a6bb015 # Parent 0679b00bb2f13b7082e170e34f15ba849e28e8cb# Parent 5eecb7d31547e5dc964a3ae0d4b7f482e0fbc130 merge changes from mdp adaptation for remie diff -r 0679b00bb2f1 -r 3097cb0581ac src/ldt/ldt/api/ldt/resources/annotation.py --- a/src/ldt/ldt/api/ldt/resources/annotation.py Thu Jul 16 12:59:15 2015 +0200 +++ b/src/ldt/ldt/api/ldt/resources/annotation.py Sat Jul 18 14:11:23 2015 +0200 @@ -84,7 +84,7 @@ meta = a['meta'] author = meta['creator'] date = meta['created'] - # add(media, cutting_id, cutting_title, title, text, tags_list, begin, dur, author, date + # add(media, cutting_id, cutting_title, title, text, tags_list, begin, dur, author, date type_id, new_id, ensemble_id = adder.add(a['media'], a['type'], a['type_title'], a['content']['title'], a['content']['description'], a['tags'], begin, dur, author, date, None, "2194379", audio_src, audio_href) if not new_id: protect_models() diff -r 0679b00bb2f1 -r 3097cb0581ac src/ldt/ldt/ldt_utils/projectserializer.py --- a/src/ldt/ldt/ldt_utils/projectserializer.py Thu Jul 16 12:59:15 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/projectserializer.py Sat Jul 18 14:11:23 2015 +0200 @@ -152,8 +152,7 @@ decoupage_created = datetime.strptime(date_str, date_format).isoformat() break except Exception: - decoupage_created = None - + decoupage_created = None if decoupage_created is None: decoupage_created = datetime.utcnow().isoformat() decoupage_modified = decoupage_created @@ -190,6 +189,7 @@ element_media = content.iri_id element_color = element_node.attrib.get(u"color", "") element_ldt_src = element_node.attrib.get(u"src", "") + element_created = element_node.attrib["date"] element_title = reduce_text_node(element_node, "title/text()") element_description = reduce_text_node(element_node, "abstract/text()") @@ -262,6 +262,7 @@ "begin": int(float(element_begin)), "end": int(float(element_begin)) + int(float(element_duration)), "id": element_id, + "created": element_created, "media": element_media, "color": element_color, "content": { diff -r 0679b00bb2f1 -r 3097cb0581ac src/ldt/ldt/ldt_utils/views/ldt_json.py --- a/src/ldt/ldt/ldt_utils/views/ldt_json.py Thu Jul 16 12:59:15 2015 +0200 +++ b/src/ldt/ldt/ldt_utils/views/ldt_json.py Sat Jul 18 14:11:23 2015 +0200 @@ -72,9 +72,12 @@ one_content_bool = False if one_content_str: one_content_bool = {'true': True, 'false': False, "0": False, "1": True}.get(one_content_str.lower()) - - - ps = ProjectJsonSerializer(project, serialize_contents, first_cutting=first_cutting) + + from_display_str = request.GET.get("from_display", "") + from_display_bool = True + if from_display_str: + from_display_bool = {'true': True, 'false': False, "0": False, "1": True}.get(from_display_str.lower()) + ps = ProjectJsonSerializer(project, serialize_contents, from_display=from_display_bool, first_cutting=first_cutting) project_dict = ps.serialize_to_cinelab(one_content_bool) json_str = json.dumps(project_dict, ensure_ascii=False, indent=indent) diff -r 0679b00bb2f1 -r 3097cb0581ac src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.css Sat Jul 18 14:11:23 2015 +0200 @@ -0,0 +1,43 @@ + +.Ldt-AnnotationsController{ + background: url(img/pinstripe.png); + width: 535px; + max-height: 280px; + margin: 0px; + margin-top: 4px; + border-style: solid; + border-width: 1px; + border-color: #b7b7b7; +} + +.Ldt-AnnotationsController-ButtonsContainer{ + width: 100%; + min-height: 30px; + text-align: center; +} + +.Ldt-AnnotationsController-Button{ + display: inline-block; + background-color: #d93c71; + color: #ffffff; + cursor: pointer; + height: 25px; + width: 150px; + font-size: 14px; + border: 1px solid; + border-color: #eca3bc #631e34 #36101c #e16e93; + cursor: pointer; + margin-right: 10px; + margin-left: 10px; + margin-bottom: 5px; + margin-top: 5px; + padding: 4px; + text-align: center; + vertical-align: middle; + line-height: 30px; +} + +.Ldt-AnnotationsController-Button:hover{ + background-color: #e15581; + border-color: #222222 #e87d9f #f0adc3 #68273c; +} \ No newline at end of file diff -r 0679b00bb2f1 -r 3097cb0581ac src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.js Sat Jul 18 14:11:23 2015 +0200 @@ -0,0 +1,109 @@ +/* + * Widget that ties AnnotationList and CreateAnnotation together + * using buttons to hide/show AnnotationList and CreateAnnotation widgets. + * + */ + +IriSP.Widgets.AnnotationsController = function(player, config){ + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.AnnotationsController.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.AnnotationsController.prototype.defaults = { + // If true, displaying AnnotationList will hide CreateAnnotation and vice versa. + display_or_write: false, + starts_hidden: false, + hide_without_segment: false, + segments_annotation_type: "chap" +}; + +IriSP.Widgets.AnnotationsController.prototype.template = + "
" + + "
" + + "
{{l10n.display}}
" + + "
{{l10n.write}}
" + + "
" + + "
" + +IriSP.Widgets.AnnotationsController.prototype.messages = { + en : { + write : "Write", + display : "Display", + }, + fr : { + write : "Ecrire", + display : "Voir" + } +}; + +IriSP.Widgets.AnnotationsController.prototype.draw = function() { + this.renderTemplate(); + var _this = this; + this.element_$ = this.$.find(".Ldt-AnnotationsController") + + this.displayButton_$ = this.$.find(".Ldt-AnnotationsController-ShowAnnotationsListButton"); + this.writeButton_$ = this.$.find(".Ldt-AnnotationsController-ShowCreateAnnotationButton"); + + this.writeButton_$.click(function(){ + _this.player.trigger("CreateAnnotation.toggle"); + if (_this.display_or_write){ + _this.player.trigger("AnnotationsList.hide"); + } + }); + this.displayButton_$.click(function(){ + _this.player.trigger("AnnotationsList.toggle"); + if (_this.display_or_write){ + _this.player.trigger("CreateAnnotation.hide"); + } + }) + this.onMediaEvent("timeupdate", "onTimeUpdate") + + if (this.starts_hidden) { + this.visible = true + this.hide(); + } + else{ + this.visible = false + this.show(); + } + +}; + +IriSP.Widgets.AnnotationsController.prototype.onTimeUpdate = function(){ + if (this.hide_without_segment){ + _currentTime = this.media.getCurrentTime() + _segmentsAnnotations = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type) + _currentSegments = _segmentsAnnotations.filter(function(_segment){ + return (_currentTime >= _segment.begin && _currentTime <= _segment.end) + }); + if (_currentSegments.length == 0){ + if (this.visible){ + this.hide(); + _this.player.trigger("CreateAnnotation.hide"); + _this.player.trigger("AnnotationsList.hide"); + } + } + else { + if (!this.visible){ + this.show(); + _this.player.trigger("CreateAnnotation.hide"); + _this.player.trigger("AnnotationsList.hide"); + } + } + } +} + +IriSP.Widgets.AnnotationsController.prototype.hide = function() { + if (this.visible){ + this.visible = false; + this.element_$.hide() + } +} + +IriSP.Widgets.AnnotationsController.prototype.show = function() { + if(!this.visible){ + this.visible = true; + this.element_$.show() + } +} diff -r 0679b00bb2f1 -r 3097cb0581ac src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css Thu Jul 16 12:59:15 2015 +0200 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css Sat Jul 18 14:11:23 2015 +0200 @@ -13,6 +13,33 @@ width: 1px; height: 1px; } +.Ldt-AnnotationsList-Filters { + display: table-cell; + width: 100%; + height: 30px; + vertical-align: middle; + text-align: center; + +} + +.Ldt-AnnotationsList-filter-text { + text-align: left; + display: inline; + margin: 4px 2px; +} + +.Ldt-AnnotationsList-filter-dropdown { + text-align: center; + display: inline; + margin: 4px 2px; +} + +.Ldt-AnnotationsList-filter-checkbox { + text-align: center; + display: inline; + margin: 4px 2px; +} + ul.Ldt-AnnotationsList-ul { list-style: none; padding: 2px; @@ -48,6 +75,12 @@ font-size: 12px; margin: 2px; } +.Ldt-AnnotationsList-CreationDate { + color: #f7268e; + text-align: left; + font-size: 12px; + margin: 2px 2px 0 82px; +} h3.Ldt-AnnotationsList-Title { color: #0068c4; font-size: 13px; diff -r 0679b00bb2f1 -r 3097cb0581ac src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js Thu Jul 16 12:59:15 2015 +0200 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js Sat Jul 18 14:11:23 2015 +0200 @@ -12,23 +12,47 @@ IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); IriSP.Widgets.AnnotationsList.prototype.defaults = { - /* URL when the annotations are to be reloaded from an LDT-like segment API - * e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=? + /* + * URL when the annotations are to be reloaded from an LDT-like segment API + * e.g. + * http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=? */ ajax_url : false, - /* number of milliseconds before/after the current timecode when calling the segment API + /* + * number of milliseconds before/after the current timecode when calling the + * segment API */ ajax_granularity : 600000, default_thumbnail : "", - /* URL when the annotation is not in the current project, - * e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}} + /* + * URL when the annotation is not in the current project, e.g. + * http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}} */ foreign_url : "", annotation_type : false, refresh_interval : 0, limit_count : 20, newest_first : false, - show_audio: true, + always_visible : false, + start_visible: true, + show_audio : true, + show_filters : false, + show_creation_date : false, + show_timecode : true, + /* + * Only annotation in the current segment will be displayed. Designed to work with the Segments Widget. + */ + filter_by_segments: false, + segments_annotation_type: "chap", + /* + * Set to a username if you only want to display annotations from a given user + */ + show_only_annotation_from_user: false, + /* + * Show a text field that filter annotations by username + */ + filter_by_user: false, + tags : true, polemics : [{ keyword: "++", background_color: "#c9ecc6" @@ -57,6 +81,13 @@ IriSP.Widgets.AnnotationsList.prototype.template = '
' + + '{{#show_filters}}' + + '
' + + '' + + '' + + '' + + '
' + + '{{/show_filters}}' + '{{#show_audio}}
{{/show_audio}}' + '' @@ -69,11 +100,14 @@ + '' + '' + '
' - + '
{{begin}} - {{end}}
' + + '{{#show_timecode}}
{{begin}} - {{end}}
{{/show_timecode}}' + '

' + '{{{htitle}}}' + '

' + '

{{{hdescription}}}

' + + '{{#created}}' + + '
{{{created}}}
' + + '{{/created}}' + '{{#tags.length}}' + '