Generate proper labels for Canvas resources
This commit is contained in:
parent
0cf0df54af
commit
1e6e8989e1
1
app.mjs
1
app.mjs
@ -1,4 +1,3 @@
|
||||
//let createError = require('http-errors');
|
||||
import createError from 'http-errors';
|
||||
import logger from 'morgan';
|
||||
import express from 'express';
|
||||
|
@ -1,8 +1,11 @@
|
||||
import Canvas from '../src/Canvas.js';
|
||||
import Image from '../src/Image.js';
|
||||
import Manifest from '../src/Manifest.js';
|
||||
import Common from '../src/common.js';
|
||||
/**
|
||||
* Generate a canvas object to serve
|
||||
* @todo Use createCanvas from Common?
|
||||
* @todo Pass a Manifest object, not a manifest id
|
||||
* @param {string} manifestId The corresponding manifest's id
|
||||
* @param {number|string} name The canvas name
|
||||
*/
|
||||
@ -11,8 +14,19 @@ export default async function generateCanvas(manifestId, name) {
|
||||
const BASE_URL = process.env.BASE_URL;
|
||||
|
||||
const canvas = new Canvas(IIIF_API_VERSION, BASE_URL);
|
||||
const manifest = new Manifest(IIIF_API_VERSION, BASE_URL);
|
||||
manifest.generateID(manifestId);
|
||||
|
||||
canvas.generateID(manifestId, name);
|
||||
canvas.label = `${manifestId}-${name.toLowerCase()}`;
|
||||
let label = name
|
||||
.replace(/c(\w{1,2})0+(\d+).*(\.\w{2,3})?$/i, function (str, c, number) {
|
||||
return `C${c}. ${number}`;
|
||||
});
|
||||
// Add PCA to canvas label for HSI images
|
||||
if (manifest.technique === 'hsi') {
|
||||
label += ` ${filename.split('_')[3].replace(/\..*$/,'')}`;
|
||||
}
|
||||
canvas.label = label;
|
||||
|
||||
const image = new Image(canvas.id);
|
||||
image.generateID(process.env.IMAGE_SERVER_URL, await Common.getImageName(canvas));
|
||||
|
@ -9,7 +9,8 @@ class ManifestMetadata {
|
||||
date = '';
|
||||
imageAuthor = '';
|
||||
license = 'CC BY-NC-ND 4.0';
|
||||
copyright = "Ministero della Cultura (Biblioteca Nazionale 'Vittorio Emanuele III' di Napoli)/CNR-Istituto di Scienze del Patrimonio Culturale";
|
||||
copyright = `Ministero della Cultura (Biblioteca Nazionale
|
||||
'Vittorio Emanuele III' di Napoli)/CNR-Istituto di Scienze del Patrimonio Culturale`;
|
||||
|
||||
/**
|
||||
* @todo Maybe this doesn't make any sense??
|
||||
@ -39,7 +40,6 @@ class ManifestMetadata {
|
||||
this.license = metadata.license ?? this.license;
|
||||
this.copyright = metadata.copyright ?? this.copyright;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of `label, value`
|
||||
* pairs for all metadata
|
||||
|
Loading…
Reference in New Issue
Block a user