Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions iiify/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from .search import iiif_search
from .resolver import ia_resolver, create_manifest, create_manifest3, scrape, \
collection, purify_domain, cantaloupe_resolver, create_collection3, IsCollection, \
create_annotations, create_vtt_stream, infojson, create_annotations_from_comments
create_annotations, create_vtt_stream, infojson, create_annotations_from_comments, \
retrieve_collection, MAX_API_LIMIT, MAX_SCRAPE_LIMIT
from .configs import options, cors, approot, cache_root, media_root, \
cache_expr, version, image_server, cache_timeouts
from urllib.parse import quote
Expand Down Expand Up @@ -111,7 +112,9 @@ def helper(identifier):
elif mediatype == "texts":
return render_template('helpers/texts.html', identifier=identifier, reviews=reviews)
elif mediatype == "collection":
return render_template('helpers/collection.html', identifier=identifier, reviews=reviews)
# Work out number of pages for the collection.
results = retrieve_collection(identifier)
return render_template('helpers/collection.html', identifier=identifier, reviews=reviews, page_size=MAX_API_LIMIT, max_results=MAX_SCRAPE_LIMIT, result_num=results['response']['numFound'])
else:
return render_template('helpers/unknown.html', identifier=identifier, reviews=reviews)

Expand Down
8 changes: 6 additions & 2 deletions iiify/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ def collection(domain, identifiers, label='Custom Archive.org IIIF Collection'):
})
return cs

def retrieve_collection(identifier, page=1, rows=MAX_API_LIMIT):
asURL = f'{ADVANCED_SEARCH}?q=collection%3A{identifier}&fl[]=identifier&fl[]=mediatype&fl[]=title&fl[]=description&sort[]=&sort[]=&sort[]=&rows={rows}&page={page}&output=json&save=yes'
itemsSearch = requests.get(asURL).json()
return itemsSearch

def create_collection3(identifier, domain, page=1, rows=MAX_API_LIMIT):
# Get item metadata
metadata = requests.get('%s/metadata/%s' % (ARCHIVE, identifier)).json()
Expand All @@ -179,8 +184,7 @@ def create_collection3(identifier, domain, page=1, rows=MAX_API_LIMIT):
addMetadata(collection, identifier, metadata['metadata'], collection=True)
addPartOfCollection(collection, metadata.get('metadata').get('collection', []), domain)

asURL = f'{ADVANCED_SEARCH}?q=collection%3A{identifier}&fl[]=identifier&fl[]=mediatype&fl[]=title&fl[]=description&sort[]=&sort[]=&sort[]=&rows={rows}&page={page}&output=json&save=yes'
itemsSearch = requests.get(asURL).json()
itemsSearch = retrieve_collection(identifier, page, rows)
total = itemsSearch['response']['numFound']
# There is a max of 10,000 items that can be retrieved from the advanced search
if total > MAX_SCRAPE_LIMIT:
Expand Down
2 changes: 1 addition & 1 deletion iiify/templates/helpers/audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h2>IIIF player options for this mediatype:</h2>
<li><a href="https://iiif-react-media-player.netlify.app//?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Ramp</a></li>
<li><a href="https://iiif.aviaryplatform.com/player?manifest=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Aviary</a></li>
<li><a href="https://samvera-labs.github.io/clover-iiif?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Clover</a></li>

<li><a href="https://theseusviewer.org/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Theseus</a></li>
</ul>

{% include "partials/reviews_block.html" %}
Expand Down
14 changes: 14 additions & 0 deletions iiify/templates/helpers/collection.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,23 @@ <h2>IIIF viewer options</h2>
<li><a href="https://projectmirador.org/embed/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/collection.json">Mirador</a></li>
<li><a href="https://uv-v4.netlify.app/#?manifest=https://iiif.archive.org/iiif/{{ identifier }}/collection.json">Universal Viewer</a></li>
<li><a href="https://samvera-labs.github.io/clover-iiif?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/collection.json">Clover</a></li>
<li><a href="https://theseusviewer.org/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/collection.json">Theseus</a></li>

</ul>

<p><b>Note:</b> collections will be limited to {{max_results}} items due to API limits.</p>
{% set total_pages = (result_num / page_size) | round(0, 'ceil') | int %}
<p>This collection has {{result_num}} items and is split into {{ total_pages }} pages with each page
containing {{page_size}} items. The last item in the collection points to the next collection page.</p>
<p>This collection consists of the following pages:
<ul>
{% for page_num in range(1, total_pages + 1) %}
<li><a href="https://iiif.archive.org/iiif/{{ identifier }}/{{page_num}}/collection.json">Page {{page_num}}: https://iiif.archive.org/iiif/{{ identifier }}/{{page_num}}/collection.json</a></li>
{% endfor %}
</ul>

</p>

{% include "partials/reviews_block.html" %}
</div>

Expand Down
2 changes: 1 addition & 1 deletion iiify/templates/helpers/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2>IIIF viewer options</h2>
<li><a href="https://projectmirador.org/embed/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Mirador</a></li>
<li><a href="https://uv-v4.netlify.app/#?manifest=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Universal Viewer</a></li>
<li><a href="https://samvera-labs.github.io/clover-iiif?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Clover</a></li>

<li><a href="https://theseusviewer.org/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Theseus</a></li>
</ul>

<h2>IIIF image tool options</h2>
Expand Down
2 changes: 1 addition & 1 deletion iiify/templates/helpers/movies.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2>IIIF viewer options for this mediatype:</h2>
<li><a href="https://iiif-react-media-player.netlify.app//?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Ramp</a></li>
<li><a href="https://iiif.aviaryplatform.com/player?manifest=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Aviary</a></li>
<li><a href="https://samvera-labs.github.io/clover-iiif?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Clover</a></li>

<li><a href="https://theseusviewer.org/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Theseus</a></li>
</ul>

{% include "partials/reviews_block.html" %}
Expand Down
1 change: 1 addition & 0 deletions iiify/templates/helpers/texts.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ <h2>IIIF Viewer options for this mediatype:</h2>
<li><a href="https://projectmirador.org/embed/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Mirador</a></li>
<li><a href="https://uv-v4.netlify.app/#?manifest=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Universal Viewer</a></li>
<li><a href="https://samvera-labs.github.io/clover-iiif?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Clover</a></li>
<li><a href="https://theseusviewer.org/?iiif-content=https://iiif.archive.org/iiif/{{ identifier }}/manifest.json">Theseus</a></li>
</ul>

{% include "partials/reviews_block.html" %}
Expand Down