yaz/commit
move prolog to json conversion to yaz_util
author | Michiel Hildebrand |
---|---|
Sun Jan 30 17:51:00 2011 +0100 | |
committer | Michiel Hildebrand |
Sun Jan 30 17:51:00 2011 +0100 | |
commit | ec97d1d039faa4b493a246f3a2f511a1ae23dc02 |
tree | 906bf4d5e064dcf87537f38638548e844804f6fd |
parent | 7940aff4d353559066da55b20bedc5de49cd50f1 |
Diff style: patch stat
diff --git a/applications/yaz_game.pl b/applications/yaz_game.pl index 28b44c2..613068e 100644 --- a/applications/yaz_game.pl +++ b/applications/yaz_game.pl @@ -727,7 +727,7 @@ assert_channel_info :- add_video(URL, Video, Title, Duration) :- %rdf_retractall(URL, _, _), - cond_object_assert(URL, pprime:video, Video, video), + cond_object_assert(URL, pprime:source, Video, video), cond_object_assert(URL, dc:title, literal(Title), video), cond_object_assert(URL, pprime:duration, literal(Duration), video). diff --git a/applications/yaz_game_recap.pl b/applications/yaz_game_recap.pl index d37922e..09e008f 100644 --- a/applications/yaz_game_recap.pl +++ b/applications/yaz_game_recap.pl @@ -103,21 +103,13 @@ html_video_page_containers(Video, _Options) --> ]) ]). -:- json_object - i(uri:atom, time:number), - uri(value:uri) + [type=uri], - literal(lang:atom, value:_) + [type=literal], - literal(type:atom, value:_) + [type=literal], - literal(value:atom) + [type=literal], - annotation(tag:_, startTime:number, endTime:number, annotations:list). - html_video_page_yui(Video, Annotations, StartTime, _Options) --> { video_source(Video, Src), http_absolute_location(js('videoplayer/'), FilePath, []), http_absolute_location(js('videoplayer/videoplayer.js'), VideoPlayer, []), http_absolute_location(js('tagcarousel/tagcarousel.js'), TagCarousel, []), http_absolute_location(js('changehistory/changehistory.js'), ChangeHistory, []), - prolog_to_json(Annotations, JSONTags) + annotation_to_json(Annotations, JSONTags) }, html_requires(js('videoplayer/swfobject.js')), js_yui3([{modules:{'video-player':{fullpath:VideoPlayer}, diff --git a/applications/yaz_player.pl b/applications/yaz_player.pl index d2658f7..8ba66d8 100644 --- a/applications/yaz_player.pl +++ b/applications/yaz_player.pl @@ -10,7 +10,6 @@ :- use_module(library(http/http_json)). :- use_module(library(http/js_write)). :- use_module(library(http/json)). -:- use_module(library(http/json_convert)). :- use_module(library(http/http_session)). :- use_module(user(user_db)). :- use_module(library(semweb/rdf_db)). @@ -90,20 +89,12 @@ html_video_page_containers(Video, _Options) --> ]) ]). -:- json_object - i(uri:atom, time:number), - uri(value:uri) + [type=uri], - literal(lang:atom, value:_) + [type=literal], - literal(type:atom, value:_) + [type=literal], - literal(value:atom) + [type=literal], - annotation(tag:_, startTime:number, endTime:number, annotations:list). - html_video_page_yui(Video, Annotations, StartTime, _Options) --> { video_source(Video, Src), http_absolute_location(js('videoplayer/'), FilePath, []), http_absolute_location(js('videoplayer/videoplayer.js'), VideoPlayer, []), http_absolute_location(js('tagcarousel/tagcarousel.js'), TagCarousel, []), - prolog_to_json(Annotations, JSONTags) + annotation_to_json(Annotations, JSONTags) }, html_requires(js('videoplayer/swfobject.js')), js_yui3([{modules:{'video-player':{fullpath:VideoPlayer}, diff --git a/applications/yaz_tag_agreement.pl b/applications/yaz_tag_agreement.pl index e5b787c..d6fa9e3 100644 --- a/applications/yaz_tag_agreement.pl +++ b/applications/yaz_tag_agreement.pl @@ -195,15 +195,6 @@ html_page_layout(Video) --> * JS * *******************************/ -:- json_object - i(uri:atom, time:number), - uri(value:uri) + [type=uri], - literal(lang:atom, value:_) + [type=literal], - literal(type:atom, value:_) + [type=literal], - literal(value:atom) + [type=literal], - annotation(tag:_, count:number), - annotation(tag:_, tags:_, count:number). - %% html_page_yui(+Video, +Annotations, +Options) % % Emit JavaScript for the tag gardening page. @@ -221,7 +212,7 @@ html_page_yui(Video, Annotations, _Options) --> -> http_location_by_id(http_reconcile, ReconcileServer) ; setting(reconcile_server, ReconcileServer) ), - prolog_to_json(Annotations, JSONTags) + annotation_to_json(Annotations, JSONTags) }, html_requires(js('videoplayer/swfobject.js')), html_requires(yui3('yui/yui-min.js')), diff --git a/applications/yaz_tag_garden.pl b/applications/yaz_tag_garden.pl index bfad1e3..d4f7429 100644 --- a/applications/yaz_tag_garden.pl +++ b/applications/yaz_tag_garden.pl @@ -151,14 +151,6 @@ html_page_layout(Video) --> * JS * *******************************/ -:- json_object - i(uri:atom, time:number), - uri(value:uri) + [type=uri], - literal(lang:atom, value:_) + [type=literal], - literal(type:atom, value:_) + [type=literal], - literal(value:atom) + [type=literal], - annotation(tag:_, count:number). - %% html_page_yui(+Video, +Annotations, +Options) % % Emit JavaScript for the tag gardening page. @@ -176,7 +168,7 @@ html_page_yui(Video, Annotations, _Options) --> -> http_location_by_id(http_reconcile, ReconcileServer) ; setting(reconcile_server, ReconcileServer) ), - prolog_to_json(Annotations, JSONTags) + annotation_to_json(Annotations, JSONTags) }, html_requires(js('videoplayer/swfobject.js')), js_yui3([{modules:{'video-player':{fullpath:VideoPlayer}, diff --git a/lib/yaz_util.pl b/lib/yaz_util.pl index 0a435ea..ea662a2 100644 --- a/lib/yaz_util.pl +++ b/lib/yaz_util.pl @@ -16,7 +16,8 @@ iri_to_url/2, delete_nonground/2, video_source/2, - video_source/3 + video_source/3, + annotation_to_json/2 ]). :- use_module(library(semweb/rdf_db)). @@ -279,10 +280,18 @@ video_source(URL, Video, Duration) :- ). video_source(URL, Video) :- - rdf_has(URL, pprime:video, Video). + rdf_has(URL, pprime:source, Video). video_source(URL, URL). +%% annotation_to_json(+AnnotationList, -JSONTerm) +% +% Convert between a prolog list of annotation terms and a JSON +% term. + +annotation_to_json(As, JSON) :- + prolog_to_json(As, JSON). + http:convert_parameter(jsonresource, Atom, Term) :- atom_json_term(Atom, JSON, []), @@ -292,4 +301,11 @@ http:convert_parameter(jsonresource, Atom, Term) :- uri(value:uri) + [type=uri], literal(lang:atom, value:_) + [type=literal], literal(type:atom, value:_) + [type=literal], - literal(value:atom) + [type=literal]. + literal(value:_) + [type=literal], + i(uri:atom, time:number), + annotation(tag:_, count:number), + annotation(tag:_, tags:list, count:number), + annotation(tag:_, startTime:number, endTime:number, annotations:list). + + +