Skip to content

Commit

Permalink
Set up default external icons for beacon-based links (RPB-38)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Nov 28, 2023
1 parent 05652da commit 8ff5607
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/models/AuthorityResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ private List<LinkWithImage> getLinks() {
icon = url.contains(dnbSubstring) ? dnbIcon : collectionMap.get("icon");
label = collectionMap.get("name");
}
return new LinkWithImage(url, icon == null ? "" : icon.toString(), label == null ? "" : label.toString());
return new LinkWithImage(url,
icon == null
? "<i class='octicon octicon-link-external text-muted' aria-hidden='true'></i>&nbsp;"
: icon.toString(),
label == null ? "" : label.toString());
}).collect(Collectors.toList());
if (id.startsWith(GND_PREFIX) && !result.stream().anyMatch(linkWithImage -> linkWithImage.url.contains(dnbSubstring))) {
result.add(new LinkWithImage(id, dnbIcon, dnbLabel));
Expand All @@ -429,7 +433,9 @@ private String html(String field, ArrayList<LinkWithImage> links, int i) {
boolean hasLabel = !link.label.isEmpty();
String label = hasLabel ? link.label : link.url;
String result = String.format(
"<a href='%s'>" + (hasImage ? "<img src='https://lobid.org/imagesproxy?url=%s' style='height:1em' alt='%s'/>&nbsp;" : "%s") + "%s</a>", //
"<a href='%s'>" + (hasImage && !link.image.startsWith("<")
? "<img src='https://lobid.org/imagesproxy?url=%s' style='height:1em' alt='%s'/>&nbsp;"
: "%s") + "%s</a>",
link.url, link.image, label, label);
return withDefaultHidden(field, links.size(), i, result);
}
Expand Down

0 comments on commit 8ff5607

Please sign in to comment.