Possibly complete manifest
This commit is contained in:
@@ -18,11 +18,11 @@ class Canvas {
|
||||
this.BASE_URL = baseURL;
|
||||
}
|
||||
/**
|
||||
* @param {string} idParam From the request
|
||||
* @param {string} resourceId The resource ID for this canvas
|
||||
* @param {int|string} name A unique name for this canvas
|
||||
*/
|
||||
generateID(idParam, name) {
|
||||
this.id = `${this.BASE_URL}/iiif/${idParam}/canvas/${name}`;
|
||||
generateID(resourceId, name) {
|
||||
this.id = `${this.BASE_URL}/iiif/${resourceId}/canvas/${name}`;
|
||||
}
|
||||
/**
|
||||
* @param {string} label A label for this canvas
|
||||
@@ -39,12 +39,13 @@ class Canvas {
|
||||
/**
|
||||
* Add a thumbnail object
|
||||
* @todo Support multiple thumbs?
|
||||
* @param {int} [height=300]
|
||||
* @param {int} [width=300]
|
||||
* @param {number} height
|
||||
* @param {number} width
|
||||
* @param {string} imageId The full image ID as server URL
|
||||
*/
|
||||
setThumbnail(height = 300, width = 300) {
|
||||
setThumbnail(height, width, imageId) {
|
||||
this.thumbnail = {
|
||||
"@id" : '',
|
||||
"@id" : `${imageId.replace(/\/full.*$/,'')}/full/${width},${height}/0/default.jpg`,
|
||||
"@type" : 'dctypes:Image',
|
||||
height,
|
||||
width
|
||||
|
||||
50
src/Image.js
50
src/Image.js
@@ -3,35 +3,63 @@ import IIIFResource from './IIIFResource.js';
|
||||
* @implements IIIFResource
|
||||
*/
|
||||
class Image {
|
||||
/**
|
||||
* @var {string} id A URL pointing to the image resource
|
||||
*/
|
||||
id = '';
|
||||
type = 'dctypes:Image';
|
||||
format = 'image/jpeg';
|
||||
context = `http://iiif.io/api/presentation/${process.env.IIIF_API_VERSION}/context.json`;
|
||||
type = 'oa:Annotation';
|
||||
motivation = 'sc:painting';
|
||||
__type = 'dctypes:Image';
|
||||
__format = 'image/jpeg';
|
||||
height = 0;
|
||||
width = 0;
|
||||
service = {};
|
||||
|
||||
constructor(height, width) {
|
||||
canvasId = '';
|
||||
/**
|
||||
*
|
||||
* @param {string} canvasId The canvas IIIF id
|
||||
*/
|
||||
constructor(canvasId) {
|
||||
this.canvasId = canvasId;
|
||||
}
|
||||
/**
|
||||
* @param {number} height
|
||||
* @param {number} width
|
||||
*/
|
||||
setSize(height, width) {
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
}
|
||||
/**
|
||||
* Generate IIIF id pointing to image
|
||||
* server endpoint for this image
|
||||
* @param {string} serviceURL The image server base URL
|
||||
* @param {string} filename The image's complete filename
|
||||
*/
|
||||
generateID(serviceURL, filename) {
|
||||
let splitFilename = filename.split('_');
|
||||
const baseFolder = splitFilename.slice(0,2).join('_') + '_iiif';
|
||||
const subfolder = splitFilename.slice(0,3).join('_') + '_iiif';
|
||||
|
||||
this.id = `${serviceURL}/2/${baseFolder}%2F${subfolder}%2F${filename}/full/full/0/default.jpg`;
|
||||
}
|
||||
/**
|
||||
* Object representation of
|
||||
* image resource
|
||||
* @returns {object}
|
||||
* @returns {Object}
|
||||
*/
|
||||
toObject() {
|
||||
return {
|
||||
"@context" : this.context,
|
||||
"@type" : this.type,
|
||||
motivation : this.motivation,
|
||||
resource : {
|
||||
"@id" : this.id,
|
||||
"@type" : this.type,
|
||||
format: this.format,
|
||||
"@type" : this.__type,
|
||||
format: this.__format,
|
||||
service : this.service,
|
||||
height: this.height,
|
||||
width: this.width,
|
||||
}
|
||||
},
|
||||
on : this.canvasId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,18 @@ class Sequence {
|
||||
canvases = [];
|
||||
id = '';
|
||||
type = 'sc:Sequence';
|
||||
|
||||
constructor(baseUrl) {
|
||||
this.BASE_URL = baseUrl;
|
||||
}
|
||||
/**
|
||||
* @param {string} resourceId The resource ID for this sequence
|
||||
* @param {int|string} name A unique name for this sequence
|
||||
*/
|
||||
generateID(resourceId, name) {
|
||||
this.id = `${this.BASE_URL}/iiif/${resourceId}/sequence/${name}`;
|
||||
}
|
||||
/**
|
||||
* @todo Implement
|
||||
* @param {Canvas} canvas The Canvas object
|
||||
*/
|
||||
addCanvas(canvas) {
|
||||
|
||||
Reference in New Issue
Block a user