Skip to content

Commit

Permalink
Set up separate config values for host.main and host.reconcile
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Sep 13, 2024
1 parent e20d130 commit c94b7fa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/controllers/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ static String returnAsJson(String q, SearchResponse queryResponse) {
List<Map<String, Object>> hits = Arrays.asList(queryResponse.getHits().getHits()).stream()
.map(hit -> hit.getSource()).collect(Collectors.toList());
ObjectNode object = Json.newObject();
object.put("@context", config("host") + routes.HomeController.context());
object.put("id", config("host") + request().uri());
object.put("@context", configNested("host", "main") + routes.HomeController.context());
object.put("id", configNested("host", "main") + request().uri());
object.put("totalItems", queryResponse.getHits().getTotalHits());
object.set("member", Json.toJson(hits));

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/Reconcile.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Result main(String callback, String queries, String extend) {
}

private ObjectNode metadata() {
final String host = HomeController.config("host");
final String host = HomeController.configNested("host", "reconcile");
ObjectNode result = Json.newObject();
result.putArray("versions").add("0.1").add("0.2");
result.put("name", "GND reconciliation for OpenRefine");
Expand Down Expand Up @@ -151,7 +151,7 @@ private ObjectNode metadata() {

private ObjectNode suggestService(String suggest) {
return Json.newObject()//
.put("service_url", HomeController.config("host") + "/gnd/reconcile")//
.put("service_url", HomeController.configNested("host", "reconcile"))//
.put("service_path", "/suggest/" + suggest)//
.put("flyout_service_path", "/flyout/" + suggest + "?id=${id}");
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/preview.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@(resource: String)

@import play.api.libs.json._
@import controllers.HomeController.CONFIG
@import controllers.HomeController.configNested

<html><head><meta charset="utf-8" /></head>
<body style="margin: 0px; font-family: Arial; sans-serif">
Expand All @@ -16,7 +16,7 @@
details = elems.tail.mkString(" | ");
fullId <- (json \ "id").asOpt[String];
shortId = fullId.split("/").last;
url = CONFIG.getString("host") + routes.HomeController.authority(shortId,null);
url = configNested("host", "reconcile") + routes.HomeController.authority(shortId,null);
cat <- (json \ "category").asOpt[String];
image = (json \ "image").asOpt[String]) {
@for(img <- image){
Expand Down
12 changes: 6 additions & 6 deletions app/views/reconcile.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>GND Reconciliation</h1>

<p>Dieser Dienst ermöglicht den Abgleich eigener Daten mit der Gemeinsamen Normdatei, insbesondere mit OpenRefine, einem nicht nur im Bibliotheksbereich weitverbreiteten Werkzeug. OpenRefine bietet zahlreiche Funktionalitäten zur Bereinigung und Transformation von Daten, sowie zum Abgleich (Reconciliation) mit externen Datenquellen und zur Anreicherung auf Basis der abgeglichenen Daten. Dieser Dienst stellt die GND als eine solche Datenquelle in OpenRefine bereit. Der Dienst kann zugleich auch in anderen Anwendungen verwendet werden, z. B. im Bibliotheksmanagementsystem Alma über Alma Refine (s. <a href="https://reconciliation-api.github.io/census/clients/">weitere Clients</a>).</p>

<p>Service-URL: <code>@controllers.HomeController.config("host")</code></p>
<p>Service-URL: <code>@controllers.HomeController.configNested("host", "reconcile")</code></p>

<h2>Daten und Werkzeuge</h2>

Expand Down Expand Up @@ -50,11 +50,11 @@ <h2>API</h2>
<h3>Allgemeine API <small>(<a href="https://www.w3.org/community/reports/reconciliation/CG-FINAL-specs-0.2-20230410">spec</a>)</small></h3>

<p><b>Service</b><br/>
<code>curl @controllers.HomeController.config("host")</code>
<code>curl @controllers.HomeController.configNested("host", "reconcile")</code>
<p><b>JSONP-callback</b><br/>
<code>curl @controllers.HomeController.config("host")?callback=jsonp</code>
<code>curl @controllers.HomeController.configNested("host", "reconcile")?callback=jsonp</code>
<p><b>CORS-header</b><br/>
<code>curl --head @controllers.HomeController.config("host") | grep Access-Control-Allow-Origin</code>
<code>curl --head @controllers.HomeController.configNested("host", "reconcile") | grep Access-Control-Allow-Origin</code>
</p>

<h3>View-API</h3>
Expand All @@ -66,7 +66,7 @@ <h3>Query-API <small>(<a href="https://www.w3.org/community/reports/reconciliati

@desc("Query: GET", routes.Reconcile.main(queries="{\"q1\":{\"query\":\"Twain, Mark\"}}"))
<p><b>Query: POST</b><br/>
<code>curl --data 'queries={"q1":{"query":"Twain, Mark"}}' @controllers.HomeController.config("host")</code></p>
<code>curl --data 'queries={"q1":{"query":"Twain, Mark"}}' @controllers.HomeController.configNested("host", "reconcile")</code></p>

<h3>Suggest-API <small>(<a href="https://www.w3.org/community/reports/reconciliation/CG-FINAL-specs-0.2-20230410/#suggest-services">spec</a>)</small></h3>

Expand All @@ -82,6 +82,6 @@ <h3>Data-extension-API</h3>
@desc("Property-proposals (<a href=\"https://www.w3.org/community/reports/reconciliation/CG-FINAL-specs-0.2-20230410/#data-extension-property-proposals\">spec</a>)", routes.Reconcile.properties("","Work",""))
@desc("Extend: GET (<a href=\"https://www.w3.org/community/reports/reconciliation/CG-FINAL-specs-0.2-20230410/#data-extension-service\">spec</a>)", routes.Reconcile.main(extend="{\"ids\":[\"1081942517\",\"4791358-7\"],\"properties\":[{\"id\":\"preferredName\"},{\"id\":\"firstAuthor\"}]}"))
<p><b>Extend: POST</b><br/>
<code>curl --data 'extend={"ids":["1081942517","4791358-7"],"properties":[{"id":"preferredName"},{"id":"firstAuthor"}]}' @controllers.HomeController.config("host")</code></p>
<code>curl --data 'extend={"ids":["1081942517","4791358-7"],"properties":[{"id":"preferredName"},{"id":"firstAuthor"}]}' @controllers.HomeController.configNested("host", "reconcile")</code></p>

}
5 changes: 4 additions & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# This is the main configuration file for the application.
# https://www.playframework.com/documentation/latest/ConfigFile

host : "https://reconcile.lobid.org"
host {
main: "https://lobid.org"
reconcile: "https://reconcile.gnd.network"
}

dontShowOnMainPage: ["1012979-0"]

Expand Down

0 comments on commit c94b7fa

Please sign in to comment.