--- a/src/spel/management/commands/loadspeldata.py Wed Mar 19 12:38:06 2014 +0100
+++ b/src/spel/management/commands/loadspeldata.py Wed Mar 19 14:58:31 2014 +0100
@@ -75,7 +75,7 @@
if do_import:
print("Parsing folder %s ..." % path)
for f in listdir(path):
- json_path = join(path,f,"cinelab.json")
+ json_path = join(path,f,"cinelab_iri.json")
if isfile(json_path):
print("Parsing json file %s ..." % json_path)
json_data = False
--- a/src/spel/static/spel/css/spel.css Wed Mar 19 12:38:06 2014 +0100
+++ b/src/spel/static/spel/css/spel.css Wed Mar 19 14:58:31 2014 +0100
@@ -55,4 +55,12 @@
}
.annot-tag{
background-color: #FFF;
+}
+.searched-tag{
+ background-color: #EEE;
+ margin-right: 5px;
+}
+.searched-tag .glyphicon-remove:hover{
+ color: #FFF;
+ cursor: pointer;
}
\ No newline at end of file
--- a/src/spel/static/spel/js/spectacle.js Wed Mar 19 12:38:06 2014 +0100
+++ b/src/spel/static/spel/js/spectacle.js Wed Mar 19 14:58:31 2014 +0100
@@ -176,6 +176,9 @@
.done(function(html){
$(".annotation-results").removeClass("loader");
$(".annotation-results").html(html);
+ if($('#search-input').val() && $('#search-input').val()!=""){
+ $("#btn-filter-annotations").click();
+ }
})
.fail(function() {
$(".annotation-results").removeClass("loader");
@@ -189,18 +192,15 @@
$(".annotation-results").html("<p>Vous devez indiquer un terme pour la recherche.</p>");
return false;
}
- $('option', $('#mulsel4')).each(function(element) {
- $(this).removeAttr('selected').prop('selected', false);
- });
- $('#mulsel4').multiselect('refresh');
+ console.log("ICI 1");
searchAnnotations();
});
$("#btn-filter-annotations").click(function(e){
if($("#mulsel4").val() && $("#mulsel4").val()!=""){
+ var filters = $("#mulsel4").val();
+ var nb_filters = filters.length;
if($('#search-input').val()!=""){
- var filters = $("#mulsel4").val();
- var nb_filters = filters.length;
$( ".searched-annot" ).each(function(index){
var type_inter = $(this).attr("data-type-inter").split(", ");
var found = true;
@@ -213,6 +213,7 @@
});
}
else{
+ console.log("ICI 2");
searchAnnotations();
}
}
@@ -221,7 +222,41 @@
$(this).show();
});
}
+ // We display the clickable/removable tags.
+ // First we remove all childs but the searched-term one
+ if($(".annot-tag-list").children().first().children().first().hasClass("glyphicon-search")){
+ $(".annot-tag-list").find("li:gt(0)").remove();
+ }
+ else{
+ $(".annot-tag-list").children().remove();
+ }
+ if($("#mulsel4").val() && $("#mulsel4").val()!=""){
+ var filters = $("#mulsel4").val();
+ var nb_filters = filters.length;
+ for(var i=0;i<nb_filters;i++){
+ if(filters[i].trim()!=""){
+ $(".annot-tag-list").append('<li class="small searched-tag">' + filters[i] + ' <span class="glyphicon glyphicon-remove small"></span></li>');
+ }
+ }
+ }
+ // Update number displayed
$(".nb-annotations-found").html($('.annotation-results > div:visible').length);
});
+
+ // click-to-remove-tag management
+ $(".annotation-results").on("click", ".annot-tag-list .glyphicon-remove", function(){
+ console.log(this, $(this).parent().text().trim());
+ if($(this).parent().children().first().hasClass("glyphicon-search")){
+ $("#search-input").val("");
+ }
+ else{
+ $("#mulsel4").multiselect('deselect', $(this).parent().text().trim());
+ }
+ $("#btn-filter-annotations").click();
+ // manage when nothing is selected
+ if($(".annot-tag-list").children().length==0){
+ $(".annotation-results").html('');
+ }
+ });
});
--- a/src/spel/templates/partial/spel_annotations.html Wed Mar 19 12:38:06 2014 +0100
+++ b/src/spel/templates/partial/spel_annotations.html Wed Mar 19 14:58:31 2014 +0100
@@ -1,6 +1,10 @@
{% load static %}
{% load front_tags %}
{% load spel_tags %}
+<ul class="list-inline annot-tag-list">
+ {% if q != "" %}<li class="small searched-tag"><span class="glyphicon glyphicon-search small"></span> : {{ q }} <span class="glyphicon glyphicon-remove small"></span></li>{% endif %}
+ {% for t in searched_tags %}{% if t != "" %}<li class="small searched-tag">{{ t }} <span class="glyphicon glyphicon-remove small"></span></li>{% endif %}{% endfor %}
+</ul>
<p><span class="nb-annotations-found">{{ nb_annotations }}</span> annotation(s) trouvée(s) sur {{ nb_contents }} vidéo(s)</p>
{% for res in results %}
{% for s in res.list %}
@@ -12,9 +16,10 @@
<p>{{ s.tags|get_tags:"ref_text"|join:', ' }}</p>
<p>{% if s.title != "" %}{{ s.title }} : {% endif %}{{ s.abstract }}</p>
<ul class="list-inline">
- {% for ttt in tag_list %}
- <li class="annot-tag small">{{ ttt }}</li>
+ {% for t in tag_list %}
+ <li class="annot-tag small">{{ t }}</li>
{% endfor %}
+</ul>
</div>
{% endwith %}
{% endfor %}
--- a/src/spel/views.py Wed Mar 19 12:38:06 2014 +0100
+++ b/src/spel/views.py Wed Mar 19 14:58:31 2014 +0100
@@ -98,43 +98,34 @@
q = request.GET.get("q", "")
page = 1
content_list = None
- # Query search
if q!="":
field = "abstract"
results, nb_contents, nb_segments = get_search_results(request, q, field, page, content_list)
results = results.object_list
+ type_inter_param = ""
else:
- results = None
- nb_contents = 0
- nb_segments = 0
- # Filter by tags
- type_inter_param = request.GET.get("type_inter", "")
- if type_inter_param!="":
- type_inter = [("type_inter: " + t) for t in type_inter_param.split(",")]
- tags = Tag.objects.filter(name__in=type_inter)
- # If results are from search, we get all segment from content list
- seg_queryset = Segment
- if results :
- seg_queryset = []
- for r in results:
- seg_queryset += r["list"]
- seg_queryset = Segment.objects.filter(id__in=[s.id for s in seg_queryset])
- # Get segments from tagged items
- tagged_segs = TaggedItem.objects.get_by_model(seg_queryset, tags).values()
- # Prefetch all contents
- all_contents = Content.objects.filter(iri_id__in=[s['iri_id'] for s in tagged_segs])
+ type_inter_param = request.GET.get("type_inter", "")
+ seg_queryset = []
results = []
- for iri_id, items in groupby(tagged_segs, itemgetter('iri_id')):
- # Get good content
- content = None
- content_filter = filter(lambda e: e.iri_id == iri_id, all_contents)
- if len(content_filter)>0:
- content = content_filter[0]
- if content is None:
- continue
- # Get segments
- s = list(items)
- results.append({ 'content': content, 'list': s })
+ tagged_segs = []
+ if type_inter_param!="":
+ type_inter = [("type_inter: " + t) for t in type_inter_param.split(",")]
+ tags = Tag.objects.filter(name__in=type_inter)
+ # Get segments from tagged items
+ tagged_segs = TaggedItem.objects.get_by_model(Segment, tags).values()
+ # Prefetch all contents
+ all_contents = Content.objects.filter(iri_id__in=[s['iri_id'] for s in tagged_segs])
+ for iri_id, items in groupby(tagged_segs, itemgetter('iri_id')):
+ # Get good content
+ content = None
+ content_filter = filter(lambda e: e.iri_id == iri_id, all_contents)
+ if len(content_filter)>0:
+ content = content_filter[0]
+ if content is None:
+ continue
+ # Get segments
+ s = list(items)
+ results.append({ 'content': content, 'list': s })
nb_contents = len(results)
nb_segments = len(tagged_segs)