Skip to content

Commit

Permalink
Add external links and seeAlso to sidebar (#959)
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Dec 5, 2023
1 parent 1e057a3 commit 2554c08
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apps/iiif/manifests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
19 changes: 19 additions & 0 deletions apps/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,25 @@ <h2 class="uk-modal-title">Text</h2>
<v-info-content-url-external label="Stable Page" volume="{% url 'volume' volume.pid %}" url="https://{{ request.META.HTTP_HOST }}{% url 'volume' volume.pid %}/page/{{ page.pid }}">
</v-info-content-url-external>
{% endif %}

{% if volume.external_links.see_also %}
<v-info-content-url-multiple label="See Also">
{% for link in volume.external_links.see_also %}
<v-info-content-url-unit url="{{ link }}">
</v-info-content-url-unit>
{% endfor %}
</v-info-content-url-multiple>
{% endif %}

{% if volume.external_links.related %}
<v-info-content-url-multiple label="External Links">
{% for link in volume.external_links.related %}
<v-info-content-url-unit url="{{ link }}">
</v-info-content-url-unit>
{% endfor %}
</v-info-content-url-multiple>
{% endif %}

</div>
</div>

Expand Down

0 comments on commit 2554c08

Please sign in to comment.