Skip to content

Commit

Permalink
Merge pull request #77 from internetarchive/spring-2024
Browse files Browse the repository at this point in the history
Merging spring 2024 fixes
  • Loading branch information
glenrobson authored May 29, 2024
2 parents d057a04 + fd9f88a commit 0d9a212
Show file tree
Hide file tree
Showing 16 changed files with 707 additions and 39 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,12 @@ docs/_build/

# PyBuilder
target/

# Cache dir
cache/

# PyCharm
.idea/

# Old folder from v2?
media/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Unit tests are in the `tests` folder and can be run with:
python -m unittest discover -s tests
```

Run single test:
```
python -m unittest tests.test_video.TestVideo.test_vtt_autogenerated
```

Retrieve large.jpg as 800px wide JPEG
* http://127.0.0.1:8080/iiif/large.jpg/full/800,/0/default.jpg

Expand Down
11 changes: 8 additions & 3 deletions iiify/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from flask_caching import Cache
from iiif2 import iiif, web
from .resolver import ia_resolver, create_manifest, create_manifest3, getids, collection, \
purify_domain, cantaloupe_resolver, create_collection3, IsCollection
purify_domain, cantaloupe_resolver, create_collection3, IsCollection, create_annotations
from .configs import options, cors, approot, cache_root, media_root, \
cache_expr, version, image_server, cache_timeouts
from urllib.parse import quote
Expand All @@ -17,7 +17,7 @@
app = Flask(__name__)
# disabling sorting of the output json
app.config['JSON_SORT_KEYS'] = False
app.config['CACHE_TYPE'] = "FileSystemCache"
app.config['CACHE_TYPE'] = "FileSystemCache" if os.environ.get("FLASK_CACHE_DISABLE", None) != "true" else "NullCache"
app.config['CACHE_DIR'] = "cache"
cors = CORS(app) if cors else None
cache = Cache(app)
Expand Down Expand Up @@ -191,6 +191,11 @@ def manifest3(identifier):
raise excpt
# abort(404)

@app.route('/iiif/<version>/annotations/<identifier>/<fileName>/<canvas_no>.json')
@cache.cached(timeout=cache_timeouts["long"], forced_update=cache_bust)
def annnotations(version, identifier, fileName, canvas_no):
domain = purify_domain(request.args.get('domain', request.url_root))
return ldjsonify(create_annotations(version, identifier, fileName, canvas_no, domain=domain))

@app.route('/iiif/<identifier>/manifest.json')
@cache.cached(timeout=cache_timeouts["long"], forced_update=cache_bust)
Expand All @@ -199,7 +204,7 @@ def manifest(identifier):

@app.route('/iiif/2/<identifier>/manifest.json')
def manifest2(identifier):
domain = "https://iiif.archivelab.org/iiif/"
domain = purify_domain(request.args.get('domain', request.url_root))
page = None
if '$' in identifier:
identifier, page = identifier.split('$')
Expand Down
4 changes: 4 additions & 0 deletions iiify/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import sys
import types
import configparser
import json

path = os.path.dirname(os.path.realpath(__file__))
approot = os.path.abspath(os.path.join(path, os.pardir))
Expand Down Expand Up @@ -75,3 +76,6 @@ def getdef(self, section, option, default_value):
"long": 432000, # 5 days
"longest": 2592000 # 30 days
}

with open('%s/links.json' % path, 'r') as file:
LINKS = json.load(file)
137 changes: 137 additions & 0 deletions iiify/configs/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"Animated GIF": {
"field": "rendering",
"type": "Image",
"format": "image/gif"
},
"Text PDF": {
"field": "rendering",
"type": "Text",
"format": "application/pdf"
},
"Abbyy GZ": {
"field": "rendering",
"type": "Dataset",
"format": "application/gzip"
},
"Archive BitTorrent": {
"field": "rendering",
"type": "Dataset",
"format": "application/x-bittorrent"
},
"Grayscale PDF": {
"field": "rendering",
"type": "Text",
"format": "application/pdf"
},
"chOCR": {
"field": "rendering",
"type": "Text",
"format": "application/gzip"
},
"DjVuTXT": {
"field": "rendering",
"type": "Text",
"format": "text/plain"
},
"Djvu XML": {
"field": "rendering",
"type": "Dataset",
"format": "application/xml"
},
"hOCR": {
"field": "rendering",
"type": "Text",
"format": "text/html"
},
"Single Page Processed JP2 ZIP": {
"field": "rendering",
"type": "Image",
"format": "application/zip"
},
"OCR Search Text": {
"field": "rendering",
"type": "Text",
"format": "application/gzip"
},
"Single Page Original JP2 Tar": {
"field": "rendering",
"type": "Image",
"format": "application/x-tar"
},
"DjVu": {
"field": "rendering",
"type": "Image",
"format": "image/vnd.djvu"
},
"Cloth Cover Detection Log": {
"field": "seeAlso",
"type": "Text",
"format": "text/plain"
},
"Dublin Core": {
"field": "seeAlso",
"type": "Dataset",
"format": "application/xml"
},
"OCR Page Index": {
"field": "seeAlso",
"type": "Dataset",
"format": "application/json"
},
"MARC": {
"field": "seeAlso",
"type": "Dataset",
"format": "application/xml"
},
"MARC Binary": {
"field": "seeAlso",
"type": "Dataset",
"format": "application/marc"
},
"MARC Source": {
"field": "seeAlso",
"type": "Dataset",
"format": "application/xml"
},
"Page Numbers JSON": {
"field": "seeAlso",
"type": "Dataset",
"format": "application/json"
},
"Scandata": {
"field": "seeAlso",
"type": "Dataset",
"format": "application/xml"
},
"SubRip": {
"field": "rendering",
"type": "Text",
"format": "text/plain"
},
"Web Video Text Tracks": {
"field": "rendering",
"type": "Text",
"format": "text/vtt"
},
"Intermediate ASR JSON": {
"field": "rendering",
"type": "Text",
"format": "application/json"
},
"Whisper ASR JSON": {
"field": "rendering",
"type": "Text",
"format": "application/json"
},
"Storj Upload Log": {
"field": "seeAlso",
"type": "Text",
"format": "text/plain"
},
"Storj Upload Trigger": {
"field": "seeAlso",
"type": "Text",
"format": "text/plain"
}
}
Loading

0 comments on commit 0d9a212

Please sign in to comment.