From c099d7ec9b8e0c0c5098d48e58fd3132df0b29e8 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Mon, 23 Dec 2024 14:44:23 +0100 Subject: [PATCH 1/3] Add modal with links to matches for classification entries (#656) Get `exactMatch` and `narrowMatch` from SKOS, add to `matches` --- app/controllers/nwbib/Classification.java | 38 +++++++++++++++++------ app/views/tags/browse_list.scala.html | 17 ++++++++++ 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/app/controllers/nwbib/Classification.java b/app/controllers/nwbib/Classification.java index fa47848..c2c3ab9 100644 --- a/app/controllers/nwbib/Classification.java +++ b/app/controllers/nwbib/Classification.java @@ -175,7 +175,9 @@ private SearchResponse classificationData() { private enum Property { LABEL("http://www.w3.org/2004/02/skos/core#prefLabel"), // BROADER("http://www.w3.org/2004/02/skos/core#broader"), // - NOTATION("http://www.w3.org/2004/02/skos/core#notation"); + NOTATION("http://www.w3.org/2004/02/skos/core#notation"), // + NARROW_MATCH("http://www.w3.org/2004/02/skos/core#narrowMatch"), // + EXACT_MATCH("http://www.w3.org/2004/02/skos/core#exactMatch"); String value; @@ -449,19 +451,35 @@ private static void collectLabelAndValue(SearchHit hit, JsonNode json, if (label != null) { String id = toNwbibNamespace(hit.getId()); String notation = notation(json); - ImmutableMap map = ImmutableMap.of(// - "value", id, // - "label", - (style == Label.PLAIN || notation.isEmpty() ? "" - : "" + notation + "" + " ") - + label.findValue("@value").asText(), // - "hits", Lobid.getTotalHitsNwbibClassification(id), // - "notation", notation, // - "focus", focus(json)); + ImmutableMap map = ImmutableMap. builder()// + .put("value", id) // + .put("label", + (style == Label.PLAIN || notation.isEmpty() ? "" + : "" + notation + "" + " ") + + label.findValue("@value").asText()) // + .put("hits", Lobid.getTotalHitsNwbibClassification(id)) // + .put("notation", notation) // + .put("focus", focus(json)) // + .put("matches", matches(json)).build(); result.add(Json.toJson(map)); } } + private static List matches(JsonNode json) { + List result = new ArrayList<>(); + addMatches(json, Property.NARROW_MATCH, result); + addMatches(json, Property.EXACT_MATCH, result); + return result; + } + + private static void addMatches(JsonNode json, Property p, + List result) { + JsonNode match = json.findValue(p.value); + if (match != null) { + match.forEach(m -> result.add(m.get("@id").textValue())); + } + } + static String toNwbibNamespace(String id) { return id // .replace("http://purl.org/lobid/nwbib-spatial#n", NWBIB_SPATIAL + "N") diff --git a/app/views/tags/browse_list.scala.html b/app/views/tags/browse_list.scala.html index c1ee9e0..1cde8c0 100644 --- a/app/views/tags/browse_list.scala.html +++ b/app/views/tags/browse_list.scala.html @@ -70,6 +70,7 @@ normalized = entryLabel.replaceAll("ß", "ss") + entryLabel.replaceAll("ss", "ß"); value = (json\"value").as[String]; hits = (json\"hits").asOpt[scala.Long].getOrElse(0L); + matches = (json\"matches").asOpt[Seq[String]].getOrElse(Seq()); anchor = value.split("[/#]").last; textToCopy = (if(entryLabel.contains("span")){entryLabel.split(" ")(1)}else{entryLabel}) + "$$0" + value) {
  • @if(id=="root" && !placeholder.contains("Register") && t!="Wikidata" && t!="Zeitschriften") { @Html(entryLabel) } else { @@ -89,6 +90,22 @@ case _ => value }}">@hits) } + @if(!matches.isEmpty()) { + + + } @if(t!="Zeitschriften"){}
    @normalized
    } From 8cd6349bcdf254ef475a0377e0c5c648cadcb695 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Mon, 6 Jan 2025 12:09:56 +0100 Subject: [PATCH 2/3] Tweak additional links in classification list view (#656) - Display button as link - Don't include number of links - Show icons for DNB and Wikidata --- app/views/tags/browse_list.scala.html | 11 +++++++++-- public/images/dnb.png | Bin 0 -> 1151 bytes public/images/wikidata.png | Bin 0 -> 908 bytes 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 public/images/dnb.png create mode 100644 public/images/wikidata.png diff --git a/app/views/tags/browse_list.scala.html b/app/views/tags/browse_list.scala.html index 1cde8c0..4d1f999 100644 --- a/app/views/tags/browse_list.scala.html +++ b/app/views/tags/browse_list.scala.html @@ -91,7 +91,7 @@ }}">@hits) } @if(!matches.isEmpty()) { - + diff --git a/public/images/dnb.png b/public/images/dnb.png new file mode 100644 index 0000000000000000000000000000000000000000..7565a7ec92e1f0fbd2238d13719fd2ad736cc1f8 GIT binary patch literal 1151 zcmds$Ur5tY6vuCo4;h$GJxleVM68I02E8OAzSQ!il}4}?g!Lfga3w*RMSFGh5>(W* zmn4D^hEGv6jYvVwAfBQ%hPgx(20m>{FGQ;%k$in!K(H|6wMdA7Poop^m@vrBvCc7fdAjJi|Crb_C;Xl! zJ{>_H1060mdn>DiLuMPHq2ajjbUH2g$mhfDzAAhp6=yzb^2;Aq+Uwo$h{Pu*z6q8z z%d&)j421{`3<}4Z`)mH-o3|3Ls8G0EL&D4XZS9viTxX-bMnQ3b_>6hK??E56bw^}v zVLc^ix7!#SLwF`*Y8nm(@!q~8S}A{VHcYGSAiK|;#@pQoqb;PYB>PV_>-}>C0y*mI z8`)S};b_ZQ91aH;uUzBv!$!zPS(^{T>t5`$v$xz|a}s=g!L| z#RZh&_4IHF0@4B?%)tgECwx&)n+L zjWJ(l#MYFfz)_U&;Qyr5nTbEeru_P@v+z;nxdSU_^B&l{JD&Mla+U7I93TA$8(h3? zUT?j6=);^wSzR@o`~zYQk4~tb`zt-W^k1Os)#qEy*RpIl^k#a)dtnC#Miv1O5#VLZ zFh^ZAobh#GEYMN-d;kns1_Q7U!kK=y14H>K$OjpXZ)bS>y*3bOvsYhODA**XCcbP9 z!wsRO9jpg)6Mf%2=#%&`VS&O&kBnerkDwi%0_v_SV@}>b;`R2%|M$l~dLDdOU?J0| z>c)G3!DWG|i)ik)M(YL4cf_@AZ@fBq_~3&R40}r56RWTEGWHl+Pe1#NM-O zPmqW>>7~7W;*kR_CR~w~4^$W3TC#cn7VQhCP6f$*5e7Q{|Eqn$;+>6uzD3^>J&|6w z@Ai*JOD;yoBrQ0cpB6vM?|kQx1Kwd#Gxtwp1)mcUZ=AYuFJG_JjsLfA=WeQ> zAUz`~Q(|h`3@-2O(I*?`|FsTGI3?t+xWX)zHHbMZPksVt^`S?`3V)S02icrx$(>Xu z>@R)INZgot?R(aJ>ucN=1YHR-I2PW&@6&CDxeqF@`9GK$F{jtB>Am`kX9p`zN&j4u dyk={Xw)$moyxgi`IP)rJ)rt4&TaZ%+7XS*lan1k$ literal 0 HcmV?d00001 From 12d502a19cb8d7e3d39ae0cca7abb30ff09ae790 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Mon, 6 Jan 2025 12:49:37 +0100 Subject: [PATCH 3/3] Use GND, not DNB logo for GND links (#661) --- app/views/tags/browse_list.scala.html | 4 ++-- public/images/dnb.png | Bin 1151 -> 0 bytes public/images/gnd.png | Bin 0 -> 4783 bytes 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 public/images/dnb.png create mode 100644 public/images/gnd.png diff --git a/app/views/tags/browse_list.scala.html b/app/views/tags/browse_list.scala.html index 4d1f999..5057ab8 100644 --- a/app/views/tags/browse_list.scala.html +++ b/app/views/tags/browse_list.scala.html @@ -102,8 +102,8 @@