cloud/commit

Fix some bugs and add an HTML page and menu item for the cloud

authorJan Wielemaker
Fri May 20 15:54:40 2011 +0200
committerJan Wielemaker
Fri May 20 15:54:40 2011 +0200
commit3cf2b6e0d5148b01865aa2846ccfe5be59945299
tree0748489cb15316ba516b011d8f09f1ff4a3acd77
parent7e5d247da58fbb24af001dd91f6a642ab55e2f8d
Diff style: patch stat
diff --git a/applications/app_cloud.pl b/applications/app_cloud.pl
index 301b682..82b1731 100644
--- a/applications/app_cloud.pl
+++ b/applications/app_cloud.pl
@@ -33,8 +33,10 @@
 :- use_module(library(settings)).
 :- use_module(library(process)).
 :- use_module(library(http/http_dispatch)).
+:- use_module(library(http/html_write)).
 
-:- http_handler(root('datacloud.svg'), datacloud, [spawn,time_limit(1800)]).
+:- http_handler(root('datacloud.svg'), datacloud,  [spawn,time_limit(1800)]).
+:- http_handler(root('datacloud'),     cloud_page, []).
 
 :- setting(cloud:image_file, atom, 'datacloud.svg',
 	   'File for serving the datacloud').
@@ -46,6 +48,22 @@
 /** <module> Dynamically serve a datacloud
 */
 
+%%	cloud_page(+Request)
+%
+%	Provide a full HTML page with the datacloud
+
+cloud_page(_Request) :-
+	http_link_to_id(datacloud, [], Data),
+	reply_html_page(cliopatria(default),
+			title('Data cloud'),
+			[ object([ data(Data),
+				   type('image/svg+xml'),
+				   width('100%')
+				 ],
+				 [])
+			]).
+
+
 %%	datacloud(+Request)
 %
 %	Serve an SVG holding the datacloud
diff --git a/config-available/cloud.pl b/config-available/cloud.pl
index a1680ba..9d06920 100644
--- a/config-available/cloud.pl
+++ b/config-available/cloud.pl
@@ -3,4 +3,7 @@
 /** <module> Visualize loaded datacloud
 */
 
-:- use_module(application(app_cloud)).
+:- use_module(applications(app_cloud)).
+:- use_module(cliopatria(hooks)).
+
+cliopatria:menu_item(1000=places/cloud_page, 'Data Cloud').
diff --git a/lib/datacloud.pl b/lib/datacloud.pl
index 18ba6e5..009129c 100644
--- a/lib/datacloud.pl
+++ b/lib/datacloud.pl
@@ -159,20 +159,21 @@ get_max_triples(CNList,MaxTriples):-
 get_all_cn(CNList):-
 	findall(cn(Short,Title,Triples,ListOfGraphs),
 		get_cloudnode(Short, Title, _Lib, ListOfGraphs, Triples),
-		CNList).
+		CNList),
+	CNList \== [], !.
+get_all_cn(_) :-
+	existence_error(graph, 'lib:CloudNode').
+
 
 
 % Make a graph of all the manifests that are loaded.
 make_manifests_graph:-
 	findall(Manifest,rdf_library_index(_ID,manifest(Manifest)),Manifests),
-	Manifests \== [], !,
 	sort(Manifests,SManifests),
 	forall(member(OneMani,SManifests),
 	       ( rdf_load(OneMani,[graph(ManifestGraph)]),
 		 assert(mg(ManifestGraph))
 	       )).
-make_manifests_graph :-
-	existence_error(graph, 'lib:CloudNode').
 
 clean_manifests_graph(Options) :-
 	option(unload_manifests(true), Options),