--- a/src/ldt/ldt/ldt_utils/admin.py Mon Feb 06 15:02:21 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/admin.py Mon Feb 06 16:36:23 2012 +0100
@@ -6,6 +6,7 @@
from ldt.ldt_utils.fileimport import FileImport, FileImportError
from ldt.ldt_utils.forms import LdtImportForm, ReindexForm, StatAnnotationForm
from ldt.ldt_utils.models import Content, Project, Media, Author
+from ldt.ldt_utils.stat import update_stat_content
import ldt.indexation
from guardian.admin import GuardedModelAdmin
@@ -89,13 +90,13 @@
if form.is_valid():
if form.cleaned_data['choose_all']:
- projects = Content.objects.all()
+ contents = Content.objects.all()
else:
- projects = form.cleaned_data['projects']
+ contents = form.cleaned_data['contents']
-# for content in contents:
-# compute_stats_for(content)
- message = "Stats computed for :" + repr(projects)
+ for content in contents:
+ update_stat_content(content)
+ message = "Stats computed for :" + repr(contents)
else:
form = StatAnnotationForm()
--- a/src/ldt/ldt/ldt_utils/forms.py Mon Feb 06 15:02:21 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/forms.py Mon Feb 06 16:36:23 2012 +0100
@@ -25,7 +25,7 @@
index_projects = forms.BooleanField(required=False, initial=False)
class StatAnnotationForm(forms.Form):
- projects = forms.ModelMultipleChoiceField(Project.objects.all())
+ contents = forms.ModelMultipleChoiceField(Content.objects.all(), required=False)
choose_all = forms.BooleanField(required=False, initial=False)
class SearchForm(forms.Form):
@@ -69,7 +69,7 @@
iriurl_data = "%s/%s.iri" % (iri_id_data, iri_id_data)
cleaned_data['iriurl'] = iriurl_data
# if needed, we add a comma to the tag list, to force comma separated list and enable tags with spaces.
- if ',' not in cleaned_data['tags'] :
+ if ',' not in cleaned_data['tags'] and cleaned_data['tags']!="" :
cleaned_data['tags'] = cleaned_data['tags'] + ','
return cleaned_data
--- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Mon Feb 06 15:02:21 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Mon Feb 06 16:36:23 2012 +0100
@@ -1088,7 +1088,7 @@
};
IriSP.SparklineWidget_template = "<div class='Ldt-sparklineWidget' style='width: {{width}}px; height: {{height}}px'> <div class='Ldt-sparkLinePositionMarker' style='width: 0px; height: {{height}}px'></div> <div class='Ldt-sparkLineClickOverlay' style='width: {{width}}px; height: {{height}}px'></div> <div class='Ldt-sparkLine' style='width: {{width}}px; height: {{height}}px'>Loading</div></div>";
IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}<div title='{{divTitle}}' id='{{id}}' class='Ldt-iri-chapter' style='left: {{startPixel}}px; width: {{pxWidth}}px; background-color:#{{hexa_color}};' ></div>";
-IriSP.annotationWidget_template = "{{! template for the annotation widget }}<div class='Ldt-AnnotationsWidget'> <!-- ugly div because we want to have a double border --> <div class='Ldt-Annotation-DoubleBorder'> <div class='Ldt-AnnotationContent'> <div class='Ldt-AnnotationShareIcons'> <a target='_blank' class='Ldt-fbShare' title='share on facebook'></a> <a target='_blank' class='Ldt-TwShare' title='share on twitter'></a> <a target='_blank' class='Ldt-GplusShare' title='share on google+'></a> </div> <div class='Ldt-SaTitle'></div> <div class='Ldt-SaDescription'></div> </div> </div></div>";
+IriSP.annotationWidget_template = "{{! template for the annotation widget }}<div class='Ldt-AnnotationsWidget'> <!-- ugly div because we want to have a double border --> <div class='Ldt-Annotation-DoubleBorder'> <div class='Ldt-AnnotationContent'> <div class='Ldt-AnnotationShareIcons'> <a target='_blank' class='Ldt-fbShare' title='share on facebook'></a> <a target='_blank' class='Ldt-TwShare' title='share on twitter'></a> <a target='_blank' class='Ldt-GplusShare' title='share on google+'></a> </div> <div class='Ldt-SaTitle'></div> <div class='Ldt-SaDescription'></div> <div class='Ldt-SaKeywords'></div> </div> </div></div>";
IriSP.annotation_loading_template = "{{! template shown while the annotation widget is loading }}<div id='Ldt-load-container'><div id='Ldt-loader'> </div> Chargement... </div>";
IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}<div class='Ldt-AnnotationsListWidget'> <!-- ugly div because we want to have a double border --> <div class='Ldt-Annotation-DoubleBorder'> <ul> {{#annotations}} <li> {{! if the url is not present, it means that the annotation exists in the current project }} {{^url}} <a href='#id={{id}}'> {{/url}} {{! otherwise link to url }} {{#url}} <a href='{{url}}#id={{id}}'> {{/url}} <div style='overflow: auto; margin-top: 5px; margin-bottom: 5px;'> <div class='Ldt-AnnotationsList-Caption'> <img src='http://i.imgur.com/aoUlC.jpg'></img> </div> <div class='Ldt-AnnotationsList-Duration'>{{begin}} - {{end}}</div> <div class='Ldt-AnnotationsList-Title'>{{title}}</div> <div class='Ldt-AnnotationsList-Description'>{{desc}}</div> </div> </a> </li> {{/annotations}} </ul> </div></div>";
IriSP.arrowWidget_template = "<div class='Ldt-arrowWidget'></div>";
@@ -2431,7 +2431,10 @@
if (IriSP.null_or_undefined(annotations))
return;
+ /*
+ commented in case we wanted to discriminate against some annotation types.
var view_types = serializer.getIds("Contributions");
+ */
var l = [];
var media = this._serializer.currentMedia()["id"];
@@ -2525,6 +2528,7 @@
var begin = +annotation.begin / 1000;
var end = +annotation.end / 1000;
var duration = +this._serializer.currentMedia().meta["dc:duration"];
+ var tags = "";
var title_templ = "{{title}} - ( {{begin}} - {{end}} )";
var endstr = Mustache.to_html(title_templ, {title: title, begin: IriSP.secondsToTime(begin), end: IriSP.secondsToTime(end)});
@@ -2532,6 +2536,28 @@
this.selector.find(".Ldt-SaTitle").text(endstr);
this.selector.find(".Ldt-SaDescription").text(description);
+
+ if (!IriSP.null_or_undefined(annotation.tags) && !IriSP.null_or_undefined(this._serializer._data.tags)) {
+ /* save the tag id and keywords in a unique structure */
+ var tag_list = {};
+ for (var i = 0; i < this._serializer._data.tags.length; i++) {
+ var id = this._serializer._data.tags[i]["id"];
+ var keyword = this._serializer._data.tags[i]["meta"]["dc:title"];
+
+ tag_list[id] = keyword;
+ }
+
+ /* then browse the list of defined tags for the current annotation */
+ for (var i = 0; i < annotation.tags.length; i++) {
+ if (tag_list.hasOwnProperty(annotation.tags[i]["id-ref"]))
+ tags += tag_list[annotation.tags[i]["id-ref"]] + ", ";
+ }
+ }
+
+ tags = "Keywords: " + tags.slice(0, tags.length - 2);
+
+ this.selector.find(".Ldt-SaKeywords").text(tags);
+
// update sharing buttons
var defaults = IriSP.widgetsDefaults.AnnotationsWidget;
var text = defaults.share_text;
@@ -5426,7 +5452,11 @@
name = name.toUpperCase();
var e;
e = IriSP.underscore.find(this._data["annotation-types"],
- function(entry) { return (entry["dc:title"].toUpperCase().indexOf(name) !== -1) });
+ function(entry) {
+ if (IriSP.null_or_undefined(entry["dc:title"]))
+ return false;
+
+ return (entry["dc:title"].toUpperCase().indexOf(name) !== -1) });
if (typeof(e) === "undefined")
return;