From 2554c08428339507bac493db995bcfc451df56a6 Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Tue, 5 Dec 2023 14:50:00 -0500 Subject: [PATCH] Add external links and seeAlso to sidebar (#959) --- apps/iiif/manifests/models.py | 21 +++++++++++++++++++++ apps/templates/page.html | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/apps/iiif/manifests/models.py b/apps/iiif/manifests/models.py index 31c71600..20cb85d0 100644 --- a/apps/iiif/manifests/models.py +++ b/apps/iiif/manifests/models.py @@ -272,6 +272,27 @@ def related_links(self): }) return links + @property + def external_links(self): + """Dict of lists of external links for display on volume pages + + :return: Dict of external links ("related" and "seeAlso") + :rtype: dict + """ + related_links = self.relatedlink_set.all() + return { + "see_also": [ + link.link + for link in related_links + if link.data_type.lower() == "dataset" + ], + "related": [ + link.link + for link in related_links + if link.data_type.lower() != "dataset" + ], + } + @property def see_also_links(self): """List of links for IIIF v2 'seeAlso' field (structured data). diff --git a/apps/templates/page.html b/apps/templates/page.html index 9df5932b..b07f083b 100644 --- a/apps/templates/page.html +++ b/apps/templates/page.html @@ -430,6 +430,25 @@

Text

{% endif %} + + {% if volume.external_links.see_also %} + + {% for link in volume.external_links.see_also %} + + + {% endfor %} + + {% endif %} + + {% if volume.external_links.related %} + + {% for link in volume.external_links.related %} + + + {% endfor %} + + {% endif %} +