Use private properties in classes
This commit is contained in:
parent
e9e299d845
commit
b91f14055a
@ -12,7 +12,7 @@ export default async function generateCanvas(manifestId, name) {
|
|||||||
|
|
||||||
const canvas = new Canvas(IIIF_API_VERSION, BASE_URL);
|
const canvas = new Canvas(IIIF_API_VERSION, BASE_URL);
|
||||||
canvas.generateID(manifestId, name);
|
canvas.generateID(manifestId, name);
|
||||||
canvas.setLabel(`${manifestId}-${name.toLowerCase()}`);
|
canvas.label = `${manifestId}-${name.toLowerCase()}`;
|
||||||
|
|
||||||
const image = new Image(canvas.id);
|
const image = new Image(canvas.id);
|
||||||
image.generateID(process.env.IMAGE_SERVER_URL, await Common.getImageName(canvas));
|
image.generateID(process.env.IMAGE_SERVER_URL, await Common.getImageName(canvas));
|
||||||
|
@ -5,8 +5,8 @@ import Image from './Image.js';
|
|||||||
*/
|
*/
|
||||||
class Canvas {
|
class Canvas {
|
||||||
id = '';
|
id = '';
|
||||||
type = 'sc:Canvas';
|
#type = 'sc:Canvas';
|
||||||
label = '';
|
#label = '';
|
||||||
resourceId = '';
|
resourceId = '';
|
||||||
name = '';
|
name = '';
|
||||||
images = [];
|
images = [];
|
||||||
@ -28,8 +28,8 @@ class Canvas {
|
|||||||
/**
|
/**
|
||||||
* @param {string} label A label for this canvas
|
* @param {string} label A label for this canvas
|
||||||
*/
|
*/
|
||||||
setLabel(label) {
|
set label(label) {
|
||||||
this.label = label;
|
this.#label = label;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {Image} image Add an image to the canvas
|
* @param {Image} image Add an image to the canvas
|
||||||
@ -59,8 +59,8 @@ class Canvas {
|
|||||||
return {
|
return {
|
||||||
"@context" : this.context,
|
"@context" : this.context,
|
||||||
"@id" : this.id,
|
"@id" : this.id,
|
||||||
"@type" : this.type,
|
"@type" : this.#type,
|
||||||
"label" : this.label,
|
"label" : this.#label,
|
||||||
"images" : this.images,
|
"images" : this.images,
|
||||||
"thumbnail" : this.thumbnail
|
"thumbnail" : this.thumbnail
|
||||||
}
|
}
|
||||||
|
22
src/Image.js
22
src/Image.js
@ -4,15 +4,15 @@ import IIIFResource from './IIIFResource.js';
|
|||||||
*/
|
*/
|
||||||
class Image {
|
class Image {
|
||||||
id = '';
|
id = '';
|
||||||
context = `https://iiif.io/api/presentation/${process.env.IIIF_API_VERSION}/context.json`;
|
#context = `https://iiif.io/api/presentation/${process.env.IIIF_API_VERSION}/context.json`;
|
||||||
type = 'oa:Annotation';
|
#type = 'oa:Annotation';
|
||||||
motivation = 'sc:painting';
|
#motivation = 'sc:painting';
|
||||||
__type = 'dctypes:Image';
|
#resType = 'dctypes:Image';
|
||||||
__format = 'image/jpeg';
|
#format = 'image/jpeg';
|
||||||
height = 0;
|
height = 0;
|
||||||
width = 0;
|
width = 0;
|
||||||
service = {
|
service = {
|
||||||
"@context" : this.context,
|
"@context" : this.#context,
|
||||||
"@id" : '',
|
"@id" : '',
|
||||||
profile : 'https://iiif.io/api/image/2/level2.json',
|
profile : 'https://iiif.io/api/image/2/level2.json',
|
||||||
};
|
};
|
||||||
@ -53,13 +53,13 @@ class Image {
|
|||||||
*/
|
*/
|
||||||
toObject() {
|
toObject() {
|
||||||
return {
|
return {
|
||||||
"@context" : this.context,
|
"@context" : this.#context,
|
||||||
"@type" : this.type,
|
"@type" : this.#type,
|
||||||
motivation : this.motivation,
|
motivation : this.#motivation,
|
||||||
resource : {
|
resource : {
|
||||||
"@id" : this.id,
|
"@id" : this.id,
|
||||||
"@type" : this.__type,
|
"@type" : this.#resType,
|
||||||
format: this.__format,
|
format: this.#format,
|
||||||
service : this.service,
|
service : this.service,
|
||||||
height: this.height,
|
height: this.height,
|
||||||
width: this.width,
|
width: this.width,
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
import IIIFResource from './IIIFResource.js';
|
import IIIFResource from './IIIFResource.js';
|
||||||
import Sequence from "./Sequence.js";
|
import Sequence from "./Sequence.js";
|
||||||
|
|
||||||
|
const TECH = {
|
||||||
|
nir: "Technical Photography, Near Infrared Imaging 1000nm",
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @implements IIIFResource
|
* @implements IIIFResource
|
||||||
*/
|
*/
|
||||||
class Manifest {
|
class Manifest {
|
||||||
id = '';
|
id = '';
|
||||||
_type = 'sc:Manifest';
|
#type = 'sc:Manifest';
|
||||||
_label = '';
|
#label = '';
|
||||||
resourceId = '';
|
resourceId = '';
|
||||||
/**
|
/**
|
||||||
* @var {Sequence[]}
|
* @var {Sequence[]}
|
||||||
@ -34,7 +38,7 @@ class Manifest {
|
|||||||
* Create IIIF label for this manifest
|
* Create IIIF label for this manifest
|
||||||
*/
|
*/
|
||||||
generateLabel() {
|
generateLabel() {
|
||||||
this._label = `P.Herc. ${this.resourceId.split('-')[1]}`;
|
this.#label = `P.Herc. ${this.resourceId.split('-')[1]}`;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Object representation of this
|
* Object representation of this
|
||||||
@ -47,8 +51,8 @@ class Manifest {
|
|||||||
return {
|
return {
|
||||||
"@context" : this.context,
|
"@context" : this.context,
|
||||||
"@id" : this.id,
|
"@id" : this.id,
|
||||||
"@type" : this._type,
|
"@type" : this.#type,
|
||||||
label : this._label,
|
label : this.#label,
|
||||||
sequences: this.sequences,
|
sequences: this.sequences,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import Canvas from './Canvas.js';
|
|||||||
class Sequence {
|
class Sequence {
|
||||||
canvases = [];
|
canvases = [];
|
||||||
id = '';
|
id = '';
|
||||||
type = 'sc:Sequence';
|
#type = 'sc:Sequence';
|
||||||
resourceId = '';
|
resourceId = '';
|
||||||
|
|
||||||
constructor(baseUrl) {
|
constructor(baseUrl) {
|
||||||
@ -34,7 +34,7 @@ class Sequence {
|
|||||||
toObject() {
|
toObject() {
|
||||||
return {
|
return {
|
||||||
"@id" : this.id,
|
"@id" : this.id,
|
||||||
"@type" : this.type,
|
"@type" : this.#type,
|
||||||
canvases : this.canvases
|
canvases : this.canvases
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ Common.populateCanvases = async function (manifest, images) {
|
|||||||
const canvasName = img.split('_')[3].replace(/\.[\w\d]{2,3}$/,'');
|
const canvasName = img.split('_')[3].replace(/\.[\w\d]{2,3}$/,'');
|
||||||
|
|
||||||
canvas.generateID(manifest.resourceId, canvasName);
|
canvas.generateID(manifest.resourceId, canvasName);
|
||||||
canvas.setLabel(`${manifest.resourceId}-${canvasName.toLowerCase()}`);
|
canvas.label = `${manifest.resourceId}-${canvasName.toLowerCase()}`;
|
||||||
|
|
||||||
let image = new Image(canvas.id);
|
let image = new Image(canvas.id);
|
||||||
image.generateID(process.env.IMAGE_SERVER_URL, img);
|
image.generateID(process.env.IMAGE_SERVER_URL, img);
|
||||||
|
Loading…
Reference in New Issue
Block a user