From ee75519debe5e98b0414549efbf4837b1c156b15 Mon Sep 17 00:00:00 2001
From: Fabian Steeg
Date: Fri, 7 Oct 2022 13:14:35 +0200
Subject: [PATCH 1/8] Pretty-print single-resource JSON responses, like others
(#275)
---
app/controllers/HomeController.java | 5 ++--
test/controllers/JsonResponseTest.java | 32 ++++++++++++++++++++++----
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java
index 4bea084..93597fb 100644
--- a/app/controllers/HomeController.java
+++ b/app/controllers/HomeController.java
@@ -208,8 +208,9 @@ public Result authority(String id, String format) {
return ok(views.html.details.render(entity));
}
default: {
- return rdfResultFor(Json.parse(jsonLd), responseFormat.queryParamString).orElseGet(() -> {
- return result(jsonLd, Accept.Format.JSON_LD.types[0]);
+ JsonNode jsonLdObject = Json.parse(jsonLd);
+ return rdfResultFor(jsonLdObject, responseFormat.queryParamString).orElseGet(() -> {
+ return result(prettyJsonString(jsonLdObject), Accept.Format.JSON_LD.types[0]);
});
}
}
diff --git a/test/controllers/JsonResponseTest.java b/test/controllers/JsonResponseTest.java
index ac8dc2a..e6fc4ca 100644
--- a/test/controllers/JsonResponseTest.java
+++ b/test/controllers/JsonResponseTest.java
@@ -1,4 +1,4 @@
-/* Copyright 2018, hbz. Licensed under the Eclipse Public License 1.0 */
+/* Copyright 2018, 2022 hbz. Licensed under the Eclipse Public License 1.0 */
package controllers;
@@ -15,7 +15,15 @@
import static play.test.Helpers.route;
import static play.test.Helpers.running;
+import java.util.Arrays;
+import java.util.Collection;
+
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import com.fasterxml.jackson.databind.JsonNode;
import modules.IndexTest;
import play.Application;
@@ -23,17 +31,33 @@
import play.mvc.Result;
@SuppressWarnings("javadoc")
+@RunWith(Parameterized.class)
public class JsonResponseTest extends IndexTest {
+ @Parameters(name = "{0}")
+ public static Collection
}}
From e2b4e0c5cc9fa469fe128e3d3b08cc24fafe9175 Mon Sep 17 00:00:00 2001
From: Fabian Steeg
Date: Mon, 10 Oct 2022 18:20:27 +0200
Subject: [PATCH 7/8] Add setup to avoid specific entities on start page (#301)
---
app/controllers/HomeController.java | 6 +++++-
conf/application.conf | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java
index 93597fb..592e309 100644
--- a/app/controllers/HomeController.java
+++ b/app/controllers/HomeController.java
@@ -121,7 +121,11 @@ public Result redirectSlash(String path) {
}
public Result index() {
- QueryStringQueryBuilder query = index.queryStringQuery("depiction:*");
+ String queryString = "depiction:*";
+ for (String dont : CONFIG.getStringList("dontShowOnMainPage")) {
+ queryString += " AND NOT gndIdentifier:" + dont;
+ }
+ QueryStringQueryBuilder query = index.queryStringQuery(queryString);
FunctionScoreQueryBuilder functionScoreQuery = QueryBuilders.functionScoreQuery(query,
ScoreFunctionBuilders.randomFunction(System.currentTimeMillis()));
SearchRequestBuilder requestBuilder = index.client().prepareSearch(config("index.prod.name"))
diff --git a/conf/application.conf b/conf/application.conf
index 321d369..4e505ae 100644
--- a/conf/application.conf
+++ b/conf/application.conf
@@ -3,6 +3,8 @@
host : "https://lobid.org"
+dontShowOnMainPage: ["1012979-0"]
+
play {
http.secret.key=""
filters.disabled+=play.filters.hosts.AllowedHostsFilter
From 3131fc1bf0430e50be79dd79baae033a4933d67e Mon Sep 17 00:00:00 2001
From: Fabian Steeg
Date: Tue, 11 Oct 2022 17:53:12 +0200
Subject: [PATCH 8/8] Revert showing `dateModified` in UI (2c3f79d, #244)
---
app/models/AuthorityResource.java | 4 ----
app/views/details.scala.html | 1 -
2 files changed, 5 deletions(-)
diff --git a/app/models/AuthorityResource.java b/app/models/AuthorityResource.java
index 0aab437..4f7d584 100644
--- a/app/models/AuthorityResource.java
+++ b/app/models/AuthorityResource.java
@@ -468,8 +468,4 @@ private static String year(JsonNode node) {
String text = node.elements().next().asText();
return text.matches("\\d{4}-\\d{2}-\\d{2}") ? text.split("-")[0] : text;
}
-
- public String dateModified() {
- return json.findValue("dateModified").asText().split("T")[0];
- }
}
diff --git a/app/views/details.scala.html b/app/views/details.scala.html
index e35644d..7a65260 100644
--- a/app/views/details.scala.html
+++ b/app/views/details.scala.html
@@ -156,7 +156,6 @@
Turtle)
@if(entityFacts){und EntityFacts (JSON-LD)}
| CC0
- | @resource.dateModified
}}