Unverified Commit c865e829 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

image link points always to jpg generated by image server

parent 84fc3983
Pipeline #21730 passed with stages
in 6 minutes and 2 seconds
......@@ -172,21 +172,20 @@ object Extractors {
recordSet =>
getBlankNodeContent(graph)(recordSet)("heldBy")
.flatMap(v => v.get("P154").flatMap(vi => Some(vi.str))) */
val digitalObjectId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("@id")
val manifestId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("@id").flatMap(v => Some(s"$v/manifest"))
digitalObjectId(digitalObject).flatMap(v => Some(s"$v/manifest"))
val sequenceId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("@id").flatMap(v => Some(s"$v/sequence/default"))
digitalObjectId(digitalObject).flatMap(v => Some(s"$v/sequence/default"))
val canvasId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("@id").flatMap(v => Some(s"$v/canvas/default"))
digitalObjectId(digitalObject).flatMap(v => Some(s"$v/canvas/default"))
// This is a slight concession to the fact that the locator is sent as invalid
// sftp link. The locator link can however be built easily from the digitalObject
// id, so we check only the existence of the locator property, but discard a potential
// value.
val imageResourceId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("locator").flatMap(_ =>
manifestId(digitalObject)
.flatMap(v => Some(v.replaceFirst("/manifest", "/binary")))
)
stringValue(digitalObject)("locator")
val mimeType: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("hasMimeType")
val imageHeight: JObj => Option[Double] = digitalObject =>
......
......@@ -20,8 +20,17 @@ package ch.memobase
import de.digitalcollections.iiif.model.enums.ViewingHint
import de.digitalcollections.iiif.model.jackson.IiifObjectMapper
import de.digitalcollections.iiif.model.sharedcanvas.{Canvas => IIIFCanvas, Manifest => IIIFManifest, Sequence => IIIFSequence}
import de.digitalcollections.iiif.model.{MetadataEntry, OtherContent, PropertyValue, ImageContent => IIIFImageContent}
import de.digitalcollections.iiif.model.sharedcanvas.{
Canvas => IIIFCanvas,
Manifest => IIIFManifest,
Sequence => IIIFSequence
}
import de.digitalcollections.iiif.model.{
MetadataEntry,
OtherContent,
PropertyValue,
ImageContent => IIIFImageContent
}
import ujson.{Arr => JArr, Obj => JObj}
import java.time.format.DateTimeFormatter
......@@ -53,7 +62,7 @@ class Manifest {
ExtractionResult(
(
imageContent.getIdentifier.toString.replaceAll("/binary$", ""),
Extractors.digitalObjectId(digitalObject).getOrElse(""),
replaceDomainNamesWithPlaceholders(
iiifMapper.writer.writeValueAsString(manifestResult.obj)
)
......@@ -69,7 +78,12 @@ class Manifest {
digitalObject: JObj
): IIIFImageContent = {
val imageContent = new IIIFImageContent(
Extractors.imageResourceId(digitalObject).getOrElse("")
Extractors
.digitalObjectId(digitalObject)
.flatMap(id =>
Some(s"$id/iiif/full/max/0/default.jpg")
)
.getOrElse("")
)
Extractors
.componentColor(digitalObject)
......@@ -294,8 +308,8 @@ class Manifest {
private def replaceDomainNamesWithPlaceholders(jsonObj: String): String = {
jsonObj
.replaceAll(
""""https://memobase.ch/digital/([^/"]+)/binary""",
""""{{.IIIFImage}}/$1/iiif/full/max/0/default.jpg"""
""""https://memobase.ch/digital/([^/"]+/iiif/full/max/0/default.jpg)""",
""""{{.IIIFImage}}/$1"""
)
.replaceAll(
""""https://memobase.ch/digital/([^/"]+)/manifest""",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment