Skip to content

Commit

Permalink
trying prezi2
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardKoschicek committed Sep 22, 2023
1 parent a907812 commit 2025820
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions openatlas/views/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from pathlib import Path
from typing import Any, Union, Optional

from iiif_prezi3 import Manifest, config
from flask import g, render_template, request, send_from_directory, url_for, \
session
from iiif_prezi.factory import ManifestFactory
from flask import g, render_template, request, send_from_directory, url_for
from flask_babel import lazy_gettext as _
from werkzeug.utils import redirect
from werkzeug.wrappers import Response
Expand Down Expand Up @@ -89,28 +88,48 @@ def convert_image_to_iiif(id_):
f"--tile-width 256 --tile-height 256")
subprocess.Popen(command, shell=True)

def getManifest(img_id):

def getManifest(img_id):
path = request.base_url

fac = ManifestFactory()
# Where the resources live on the web
fac.set_base_prezi_uri(path)
# Where the resources live on disk
fac.set_base_prezi_dir(Path(app.config['IIIF_DIR']))

# Default Image API information
fac.set_base_image_uri("http://www.example.org/path/to/image/api/")
fac.set_iiif_image_info(2.0, 2) # Version, ComplianceLevel

# 'warn' will print warnings, default level
# 'error' will turn off warnings
# 'error_on_warning' will make warnings into errors

config.configs['helpers.auto_fields.AutoLang'].auto_lang = session['language']
entity = Entity.get_by_id(img_id)
fac.set_debug("warn")
manifest = fac.manifest(label="Example Manifest")
manifest.set_metadata({
"Title": entity.name,
"Author": "John Doe",
"Date": "2023-09-22"
})
canvas = manifest.canvas(ident="canvas1")
image = canvas.image(ident=img_id, iiif=True)
image.set_hw(2000, 1500)

manifest = Manifest(
id=path,
label=str(img_id))
canvas = manifest.make_canvas_from_iiif(
url=app.config['IIIF_URL'] + str(img_id))
manifest_json = manifest.toJSON()

return manifest_json

return manifest.json(indent=2)

@app.route('/iiif_/<int:img_id>.json')
def iiif(img_id: int):
return getManifest(img_id)


@app.route('/iiif/<int:id_>', methods=['GET'])
@app.route('/iiif/<prefix>/<int:id_>', methods=['GET'])
@required_group('contributor')
def view_iiif(id_: int, prefix: Optional[str] = None):

return redirect(url_for('view', id_=id_))

0 comments on commit 2025820

Please sign in to comment.