accurator/commit

Renamed topics to subdomains, making more of the domain code reusable.

authorChris Dijkshoorn
Mon Apr 11 14:49:32 2016 +0200
committerChris Dijkshoorn
Mon Apr 11 14:49:32 2016 +0200
commit16670c98343ebdaf60de80b68a67f04c301bd8f1
tree80bddbeea265326be4c2341c802a5a378a14e843
parentfa6705a319a6a6198f48ad5470c38c18ca28dac0
Diff style: patch stat
diff --git a/api/accurator.pl b/api/accurator.pl
index 20364e3..a6ea752 100644
--- a/api/accurator.pl
+++ b/api/accurator.pl
@@ -50,7 +50,6 @@ user:file_search_path(fonts, web(fonts)).
 :- http_handler(cliopatria('item.html'), page_item, []).
 :- http_handler(cliopatria(ui_elements), ui_elements_api, []).
 :- http_handler(cliopatria(domains), domains_api, []).
-:- http_handler(cliopatria(topics), topics_api, []).
 :- http_handler(cliopatria(metadata), metadata_api, []).
 :- http_handler(cliopatria(annotation_fields), annotation_fields_api, []).
 :- http_handler(cliopatria(annotations), annotations_api, []).
@@ -132,28 +131,6 @@ get_parameters_domain(Request, Options) :-
 			 optional(true)])]),
     Options = [domain(Domain)].
 
-%%     topics_api(+Request)
-%
-%	Retrieves the settings specific to a topic.
-topics_api(Request) :-
-    get_parameters_topic(Request, Options),
-	get_topic_settings(Dic, Options),
-	reply_json_dict(Dic).
-
-%%	get_parameters_topic(+Request, -Options)
-%
-%	Retrieves an option list of parameters from the url.
-get_parameters_topic(Request, Options) :-
-    http_parameters(Request,
-        [topic(Topic,
-		    [description('The topic'),
-			 optional(true)]),
-		domain(Domain,
-		    [description('The domain'),
-			 optional(true)])]),
-    Options = [topic(Topic), domain(Domain)].
-
-
 %%	metadata_api(+Request)
 %
 %	Retrieves the metadata for a list of uris or a specific uri, the
diff --git a/lib/accurator/domain.pl b/lib/accurator/domain.pl
index 615fdbc..895eb3b 100644
--- a/lib/accurator/domain.pl
+++ b/lib/accurator/domain.pl
@@ -1,5 +1,4 @@
-:- module(domain, [get_domain_settings/2,
-				   get_topic_settings/2]).
+:- module(domain, [get_domain_settings/2]).
 
 /** <module> Domain
 */
@@ -42,8 +41,8 @@ get_domain_dic(DomainUri, Domain, Dic) :-
 	rdf(DomainUri, accu:hasDescriptiveImage, Image),
 	rdf(Image, accu:hasFilePath, literal(ImagePath)),
 	rdf(Image, accu:brightness, literal(Brightness)),
-	rdf_has(DomainUri, accu:topics, RdfList), !,
-	rdfs_list_to_prolog_list(RdfList, Topics),
+	rdf_has(DomainUri, accu:subDomains, RdfList), !,
+	rdfs_list_to_prolog_list(RdfList, Domains),
 	Dic = domain{domain:Domain,
 				 target:Target,
 				 taxonomy:Taxonomy,
@@ -54,20 +53,4 @@ get_domain_dic(DomainUri, Domain, Dic) :-
 				 annotation_ui:AnnotationUI,
 				 image:ImagePath,
 				 image_brightness:Brightness,
-				 topics:Topics}.
-
-
-%%	get_topic_settings(-Dic, +Options)
-%
-%	If no topic is provided, return available topics for . If domain is
-%	the given option and it exists, get dict with values,
-%	otherwise return dic with the generic settings
-get_topic_settings(Dic, Options) :-
-	option(domain(Domain), Options),
-	var(Domain), !,
-	rdf(DomainUri, rdf:type, accu:'Domain'),
-	rdf(DomainUri, rdfs:label, literal(Domain)),
-	findall(Topic,
-			rdf(DomainUri, accu:topics, Topic),
-			Topics),
-	Dic = Topics.
+				 sub_domains:Domains}.
diff --git a/rdf/domain/bible/bible_domain.ttl b/rdf/domain/bible/bible_domain.ttl
index e461e9b..b5db2e8 100644
--- a/rdf/domain/bible/bible_domain.ttl
+++ b/rdf/domain/bible/bible_domain.ttl
@@ -20,7 +20,7 @@ abib:domain a accu:Domain ;
 	accu:hasDescriptiveImage abib:jeremia ;
 	accu:hasMaximumExpertiseTopics "50" ;
 	accu:hasMaximumChildren "0" ;
-	accu:topics () .
+	accu:subDomains () .
 
 <http://iconclass.org/> a skos:ConceptScheme .
 
diff --git a/rdf/domain/bird/bird_domain.ttl b/rdf/domain/bird/bird_domain.ttl
index 6f17b05..a3a0f1c 100644
--- a/rdf/domain/bird/bird_domain.ttl
+++ b/rdf/domain/bird/bird_domain.ttl
@@ -20,7 +20,7 @@ abir:domain a accu:Domain ;
 	accu:hasDescriptiveImage abir:bird ;
 	accu:hasMaximumExpertiseTopics "50" ;
 	accu:hasMaximumChildren "2" ;
-	accu:topics () .
+	accu:subDomains () .
 
 <http://purl.org/collections/nl/naturalis/ioc_birdlist_en_nl.ttl> a skos:ConceptScheme .
 
diff --git a/rdf/domain/fashion/fashion_domain.ttl b/rdf/domain/fashion/fashion_domain.ttl
index 3f17485..dc98320 100644
--- a/rdf/domain/fashion/fashion_domain.ttl
+++ b/rdf/domain/fashion/fashion_domain.ttl
@@ -20,7 +20,7 @@ afas:domain a accu:Domain ;
 	accu:hasDescriptiveImage afas:dress ;
 	accu:hasMaximumExpertiseTopics "50" ;
 	accu:hasMaximumChildren "2" ;
-	accu:topics (
+	accu:subDomains (
 		afas:jewelry
 		afas:shoes
 		# afas:fans
@@ -30,14 +30,14 @@ afas:domain a accu:Domain ;
 
 <http://iconclass.org/> a skos:ConceptScheme .
 
-afas:jewelry a accu:Topic ;
+afas:jewelry a accu:Domain ;
 	rdfs:label "jewelry" ;
 	accu:hasDescriptiveImage afas:dress ;
 	accu:hasAnnotationUI aafas:fashionUI .
 
 
-afas:shoes
-	rdfs:label "jewelry" ;
+afas:shoes a accu:Domain ;
+	rdfs:label "shoes" ;
 	accu:hasDescriptiveImage afas:dress ;
 	accu:hasAnnotationUI aafas:fashionUI .
 
diff --git a/rdf/domain/page/page_chris_domain.ttl b/rdf/domain/page/page_chris_domain.ttl
index e5a1a20..b33a955 100644
--- a/rdf/domain/page/page_chris_domain.ttl
+++ b/rdf/domain/page/page_chris_domain.ttl
@@ -20,7 +20,7 @@ apag:domain_chris a accu:Domain ;
 	accu:hasDesciptiveImage apag:jeremia ;
 	accu:hasMaximumExpertiseTopics "50" ;
 	accu:hasMaximumChildren "0" ;
-	accu:topics () .
+	accu:subDomains () .
 
 apag:jeremia a dctypes:StillImage ;
 	accu:hasFilePath "img/background/bible.jpg" ;
diff --git a/rdf/domain/page/page_cristina_domain.ttl b/rdf/domain/page/page_cristina_domain.ttl
index 706962f..140b916 100644
--- a/rdf/domain/page/page_cristina_domain.ttl
+++ b/rdf/domain/page/page_cristina_domain.ttl
@@ -20,7 +20,7 @@ apag:domain_cristina a accu:Domain ;
 	accu:hasDesciptiveImage apag:jeremia ;
 	accu:hasMaximumExpertiseTopics "50" ;
 	accu:hasMaximumChildren "0" ;
-	accu:topics () .
+	accu:subDomains () .
 
 apag:jeremia a dctypes:StillImage ;
 	accu:hasFilePath "img/background/bible.jpg" ;
diff --git a/rdf/domain/page/page_leon_domain.ttl b/rdf/domain/page/page_leon_domain.ttl
index 2dede65..0abcffa 100644
--- a/rdf/domain/page/page_leon_domain.ttl
+++ b/rdf/domain/page/page_leon_domain.ttl
@@ -20,7 +20,7 @@ apag:domain_leon a accu:Domain ;
 	accu:hasDesciptiveImage apag:jeremia ;
 	accu:hasMaximumExpertiseTopics "50" ;
 	accu:hasMaximumChildren "0" ;
-	accu:topics () .
+	accu:subDomains () .
 
 apag:jeremia a dctypes:StillImage ;
 	accu:hasFilePath "img/background/bible.jpg" ;
diff --git a/rdf/domain/page/page_sebastien_domain.ttl b/rdf/domain/page/page_sebastien_domain.ttl
index b115bff..5570c0b 100644
--- a/rdf/domain/page/page_sebastien_domain.ttl
+++ b/rdf/domain/page/page_sebastien_domain.ttl
@@ -20,7 +20,7 @@ apag:domain_sebastien a accu:Domain ;
 	accu:hasDesciptiveImage apag:jeremia ;
 	accu:hasMaximumExpertiseTopics "50" ;
 	accu:hasMaximumChildren "0" ;
-	accu:topics () .
+	accu:subDomains () .
 
 apag:jeremia a dctypes:StillImage ;
 	accu:hasFilePath "img/background/bible.jpg" ;
diff --git a/web/js/topic.js b/web/js/topic.js
index 350cbf4..8f4c635 100644
--- a/web/js/topic.js
+++ b/web/js/topic.js
@@ -42,31 +42,29 @@ function topicInit() {
 
 function populateTopics(locale, domainSettings) {
 	var row;
+	console.log("got the following topics ", domainSettings.sub_domains);
 
-	console.log("got the following settings, ", domainSettings);
+	// get topic settings for all the topics
+	for(var i = 0; i < domainSettings.sub_domains.length; i++) {
+		if(!(i%2 === 0)) {
+			row = parseInt((i/2) + 0.5);
+			// Add a new row for every two domains
+			$(".topicDiv").append(
+				$.el.div({'class':'row',
+						  'id':'topic' + row}));
+		}
 
-	// get domain settings for all the domains
-	// for(var i = 0; i < domainLabels.length; i++) {
-	// 	if(!(i%2 === 0)) {
-	// 		row = parseInt((i/2) + 0.5);
-	// 		// Add a new row for every two domains
-	// 		$(".domainDiv").append(
-	// 			$.el.div({'class':'row',
-	// 					  'id':'domain' + row}));
-	// 	}
-	//
-	// 	// add domain specific html to rows
-	// 	$.getJSON("domains", {domain:domainLabels[i]})
-	// 	.then(function(domainData) {
-	// 		if(!(domainData.domain === "generic")) {
-	// 			domainHtml(domainData, row, locale);
-	// 		}
-	// 	});
-	// }
+		// add domain specific html to rows
+		$.getJSON("domains", {domain:domainSettings.sub_domains[i]})
+		.then(function(topicData) {
+			topicHtml(topicData, row, locale);
+		});
+	}
 }
 
-// function domainHtml(domainData, row, locale) {
-// 	var domain = domainData.domain;
+function topicHtml(topicData, row, locale) {
+	console.log("Adding topic for ", topicData);
+// var domain = domainData.domain;
 //
 // 	getLabels(locale, domainData.ui + "domain")
 // 	.then(function(labels) {
@@ -84,7 +82,7 @@ function populateTopics(locale, domainSettings) {
 //
 // 		addDomainEvent(domain);
 // 	});
-// }
+}
 //
 // function addDomainEvent(domain) {
 // 	$("#domainImg" + domain).click(function() {