# HG changeset patch # User cavaliet # Date 1379427073 -7200 # Node ID 594f79a5706bea703b89a1a72cf64cb8971f74cd # Parent fd2ba38ce4ada81cd81aa1b3bface8c1fb0def77 acronym better management diff -r fd2ba38ce4ad -r 594f79a5706b src/p4l/settings.py --- a/src/p4l/settings.py Mon Sep 16 18:00:04 2013 +0200 +++ b/src/p4l/settings.py Tue Sep 17 16:11:13 2013 +0200 @@ -408,12 +408,13 @@ PREFIX rdf: PREFIX owl: PREFIX rdfs: -SELECT DISTINCT ?uri ?label +SELECT DISTINCT ?uri ?label ?acro WHERE { ?uri a skos:Concept. ?uri skos:inScheme . ?uri skos:prefLabel ?label. ?uri skos:prefLabel ?lab. + OPTIONAL { ?uri skos:altLabel ?acro }. FILTER regex (str(?lab), ?reg, 'i'). BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). BIND (STRLEN(STR(?lab)) AS ?len) @@ -425,11 +426,12 @@ PREFIX rdf: PREFIX owl: PREFIX rdfs: -SELECT DISTINCT ?uri ?label +SELECT DISTINCT ?uri ?label ?acro WHERE { ?uri a skos:Concept ; skos:inScheme ; skos:prefLabel ?label . + OPTIONAL { ?uri skos:altLabel ?acro } } ORDER BY ?label """ @@ -440,12 +442,13 @@ PREFIX rdf: PREFIX owl: PREFIX rdfs: -SELECT DISTINCT ?uri ?label +SELECT DISTINCT ?uri ?label ?acro WHERE { ?uri a skos:Concept. ?uri skos:inScheme . ?uri skos:prefLabel ?label. ?uri skos:prefLabel ?lab. + OPTIONAL { ?uri skos:altLabel ?acro }. FILTER regex (str(?lab), ?reg, 'i'). BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). BIND (STRLEN(STR(?lab)) AS ?len) @@ -457,11 +460,12 @@ PREFIX rdf: PREFIX owl: PREFIX rdfs: -SELECT DISTINCT ?uri ?label +SELECT DISTINCT ?uri ?label ?acro WHERE { ?uri a skos:Concept ; skos:inScheme ; skos:prefLabel ?label . + OPTIONAL { ?uri skos:altLabel ?acro } } ORDER BY ?label """ diff -r fd2ba38ce4ad -r 594f79a5706b src/p4l/static/p4l/js/semantictree.js --- a/src/p4l/static/p4l/js/semantictree.js Mon Sep 16 18:00:04 2013 +0200 +++ b/src/p4l/static/p4l/js/semantictree.js Tue Sep 17 16:11:13 2013 +0200 @@ -23,10 +23,11 @@ success: function( data ) { // build response response( $.map( data["results"]["bindings"], function( item ) { - //console.log(item["uri"]["value"] + " = " + item["label"]["value"]); + // If acronym + var s = (("acro" in item)?(item["acro"]["value"] + ". "):"") + item["label"]["value"]; return { - label: item["label"]["value"], - value: item["label"]["value"] + " (" + item["uri"]["value"] + ")" + label: s, + value: s + " (" + item["uri"]["value"] + ")" } })); } @@ -73,8 +74,9 @@ var root_query = $("#id_"+input_name).attr("data-root-query"); var childs_query = $("#id_"+input_name).attr("data-childs-query"); var child_count_query = $("#id_"+input_name).attr("data-child-count-query"); - $('#term-tree-'+input_name) - .jstree({ + // We load the tree only once + if(!$('#term-tree-'+input_name).hasClass("jstree")){ + $('#term-tree-'+input_name).jstree({ themes: { theme: "apple", dots: true, @@ -131,23 +133,25 @@ attr = {'rel':'leaf'}; } } + // If acronym : + var s = (("acro" in b[i])?(b[i]["acro"]["value"] + ". "):"") + b[i]["label"]["value"]; // nb of child > 0 : state closed if yes, no state if not. if(nb>0){ mytree.push({ "data" : { - "title" : b[i]["label"]["value"] + " (" + nb + ") " + "title" : s + " (" + nb + ") " }, "state" : "closed", - "metadata" : {uri: "<"+uri+">", label:b[i]["label"]["value"]}, + "metadata" : {uri: "<"+uri+">", label:s}, "attr": attr }); } else{ mytree.push({ "data" : { - "title" : b[i]["label"]["value"] + "title" : s }, - "metadata" : {uri: "<"+uri+">", label:b[i]["label"]["value"]}, + "metadata" : {uri: "<"+uri+">", label:s}, "attr": attr }); } @@ -171,12 +175,7 @@ }, plugins : [ "themes", "json_data", "ui", "types"] }); - }, - close: function( event, ui ) { - //console.log("close"); - // this is the span with class="dialog" and id="dialog-inputname" - var input_name = this.id.substr(7); - $.jstree._reference($('#term-tree-'+input_name)).destroy(); + } }, buttons: [ { diff -r fd2ba38ce4ad -r 594f79a5706b src/p4l/utils.py --- a/src/p4l/utils.py Mon Sep 16 18:00:04 2013 +0200 +++ b/src/p4l/utils.py Tue Sep 17 16:11:13 2013 +0200 @@ -107,7 +107,7 @@ first_label = b['label']['value'] else: if 'acro' in b and 'value' in b['acro']: - first_label = b['acro']['value'] + " : " + b['label']['value'] + first_label = b['acro']['value'] + ". " + b['label']['value'] else: first_label = b['label']['value'] if lang in tmp_dict or first_label: