cluster_search_ui/commit
Updated code for annotation retrieval and showing of metadata is more bootstrap compliant.
author | Chris Dijkshoorn |
---|---|
Tue Feb 24 12:31:33 2015 +0000 | |
committer | Chris Dijkshoorn |
Tue Feb 24 12:31:33 2015 +0000 | |
commit | 401110b40d8061f22b9c3fbb0c8a1b43f834a099 |
tree | d7449367f7be539a0bda6eb5be430efa2b1307a2 |
parent | cfd71ada1375deb651ea40be4a1c8d3664ecea8e |
Diff style: patch stat
diff --git a/lib/cluster_search_ui/enrichment.pl b/lib/cluster_search_ui/enrichment.pl index a5d573d..8f68a43 100644 --- a/lib/cluster_search_ui/enrichment.pl +++ b/lib/cluster_search_ui/enrichment.pl @@ -37,21 +37,22 @@ metadata(Uri, Metadata) :- % % Get all properties and subjects attached to a Uri object_annotations(Uri, Annotations) :- - findall(annotation{%predicate=Predicate, + findall(annotation{ field:FieldLabel, - %object=Object, - body:NiceAnnotation}, - ( rdf_has(Selector, oa:hasSource, Uri), - rdf_has(AnnotationHash, oa:hasTarget, Selector), - rdf_has(AnnotationHash, oa:hasBody, Annotation), - process_annotation(Annotation, NiceAnnotation), - rdf_has(AnnotationHash, ann_ui:annotationField, FieldUri), + body:NiceBody}, + ( get_annotation(Uri, AnnotationBody, AnnotationHash), + process_annotation(AnnotationBody, NiceBody), + rdf(AnnotationHash, ann_ui:annotationField, FieldUri), rdf_display_label(FieldUri, _, FieldLabel) ), FoundAnnotations), get_title(Uri, DisplayTitle), Annotations = annotations{display_title:DisplayTitle, annotations:FoundAnnotations}. +get_annotation(Uri, AnnotationBody, AnnotationHash) :- + rdf(AnnotationHash, oa:hasTarget, Uri), + rdf(AnnotationHash, oa:hasBody, AnnotationBody). + process_annotation(literal(Annotation), Annotation) :- !. process_annotation(Annotation, Label) :- rdf_display_label(Annotation, _, Label). diff --git a/web/js/result.js b/web/js/result.js index 8956bae..87eda7f 100644 --- a/web/js/result.js +++ b/web/js/result.js @@ -17,28 +17,31 @@ function metadata(uri) { application: 'enrichment', ask: 'metadata(' + Pengine.stringify(uri, {string:'atom'}) + ', Metadata),!', onsuccess: function () { - $("#metadata").append(metadataWell(this.data, uri)); + appendMetadataWell(this.data, uri); } }); } -function metadataWell(data, uri) { +function appendMetadataWell(data, uri) { var metadata = data[0].Metadata; - var html = $.el.div({'class':'well well-sm'}, - $.el.h4('Showing metadata for ' + metadata.display_title), - $.el.dl({'class':'dl-horizontal'})); - // First item is title, so start from 1 - for(var i=1; i<metadata.properties.length; i++) { - html.appendChild( + $("#metadata").append( + $.el.div({'class':'row'}, + $.el.div({'class':'col-md-10 col-md-offset-1'}, + $.el.div({'class':'well well-sm'}, + $.el.h4('Showing metadata for ' + metadata.display_title), + $.el.dl({'class':'dl-horizontal', + 'id':'metadataList'}))))); + + for(var i=0; i<metadata.properties.length; i++) { + $("#metadataList").append( $.el.dt(metadata.properties[i].predicate_label)); - html.appendChild( + $("#metadataList").append( $.el.dd( $.el.a({'class':'r_undef', 'href':displayOptions.metadataLinkBase + metadata.properties[i].object_label}, metadata.properties[i].object_label))); } - return html; } function annotations(uri) { @@ -47,7 +50,7 @@ function annotations(uri) { application: 'enrichment', ask: 'object_annotations(' + Pengine.stringify(uri, {string:'atom'}) + ', Annotations),!', onsuccess: function () { - if(this.data[0].Annotations.annotations > 0) + if(this.data[0].Annotations.annotations.length > 0) $("#metadata").append(annotationWell(this.data)); } }); @@ -55,13 +58,24 @@ function annotations(uri) { function annotationWell(data) { var annotations = data[0].Annotations.annotations; - var html = $.el.div({'class':'well well-sm'}, - $.el.h4('Annotations added to ' + data[0].Annotations.display_title), - $.el.dl({'class':'dl-horizontal'})); - // First item is title, so start from 1 - for(var i=1; i<annotations.length; i++) { - html.appendChild($.el.dt(annotations[i].field)); - html.appendChild($.el.dd(annotations[i].body)); + + $("#metadata").append( + $.el.div({'class':'row'}, + $.el.div({'class':'col-md-10 col-md-offset-1'}, + $.el.div({'class':'well well-sm'}, + $.el.h4('Annotations for ' + data[0].Annotations.display_title), + $.el.dl({'class':'dl-horizontal', + 'id':'annotationList'}))))); + + + for(var i=0; i<annotations.length; i++) { + $("#annotationList").append( + $.el.dt(annotations[i].field)); + $("#annotationList").append( + $.el.dd( + $.el.a({'class':'r_undef', + 'href':displayOptions.metadataLinkBase + + annotations[i].body}, + annotations[i].body))); } - return html; } \ No newline at end of file