Add Image resource + fake controllers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import IIIFResource from './IIIFResource.js';
|
||||
import Image from './Image.js';
|
||||
/**
|
||||
* @implements IIIFResource
|
||||
*/
|
||||
@@ -29,6 +30,12 @@ class Canvas {
|
||||
setLabel(label) {
|
||||
this.label = label;
|
||||
}
|
||||
/**
|
||||
* @param {Image} image Add an image to the canvas
|
||||
*/
|
||||
addImage(image) {
|
||||
this.images.push(image.toObject());
|
||||
}
|
||||
/**
|
||||
* Add a thumbnail object
|
||||
* @todo Support multiple thumbs?
|
||||
@@ -52,6 +59,7 @@ class Canvas {
|
||||
"@id" : this.id,
|
||||
"@type" : this.type,
|
||||
"label" : this.label,
|
||||
"images" : this.images,
|
||||
"thumbnail" : this.thumbnail
|
||||
}
|
||||
}
|
||||
|
||||
39
src/Image.js
Normal file
39
src/Image.js
Normal file
@@ -0,0 +1,39 @@
|
||||
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';
|
||||
height = 0;
|
||||
width = 0;
|
||||
service = {};
|
||||
|
||||
constructor(height, width) {
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
}
|
||||
/**
|
||||
* Object representation of
|
||||
* image resource
|
||||
* @returns {object}
|
||||
*/
|
||||
toObject() {
|
||||
return {
|
||||
resource : {
|
||||
"@id" : this.id,
|
||||
"@type" : this.type,
|
||||
format: this.format,
|
||||
service : this.service,
|
||||
height: this.height,
|
||||
width: this.width,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Image;
|
||||
@@ -28,6 +28,9 @@ class Manifest {
|
||||
this.id = `${this.BASE_URL}/iiif/${idParam}/manifest` ;
|
||||
}
|
||||
/**
|
||||
* Object representation of this
|
||||
* manifest
|
||||
*
|
||||
* @todo Implement
|
||||
* @returns {object}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user