Remove leading zeros in canvas names (WIP)
This commit is contained in:
12
README.md
12
README.md
@@ -1,6 +1,6 @@
|
|||||||
# IIIF Manifest service for the GreekSchools Project
|
# IIIF Manifest service for the GreekSchools Project
|
||||||
|
|
||||||
This repository holds the code for a NodeJS/Express service that implements dynamic generation of IIIF manifests, compliant with version 2 of the Presentation API. Support for version 3 should be added in the future.
|
This repository holds the code for a NodeJS/Express service that implements dynamic generation of IIIF manifests for images produced by the [GreekSchools ERC project](https://greekschools.eu). The service is compliant with version 2 of the Presentation API, support for version 3 should be added in the future.
|
||||||
|
|
||||||
The project uses `yarn` for dependency management and an `.env` file to set environment variables, an example of which can be found in `.env.example`.
|
The project uses `yarn` for dependency management and an `.env` file to set environment variables, an example of which can be found in `.env.example`.
|
||||||
|
|
||||||
@@ -8,19 +8,19 @@ The project uses `yarn` for dependency management and an `.env` file to set envi
|
|||||||
|
|
||||||
`GreekManifests` requires NodeJS v. >= 20 to be installed on the system, as well as `yarn` as a package manager, which can be installed globally via `npm`:
|
`GreekManifests` requires NodeJS v. >= 20 to be installed on the system, as well as `yarn` as a package manager, which can be installed globally via `npm`:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
npm install -g yarn
|
npm install -g yarn
|
||||||
```
|
```
|
||||||
|
|
||||||
To install the service itself, clone this repository on the target host (replace `<target_dir>` with a suitable path, or remove to install in `./greek-manifests`):
|
To install the service itself, clone this repository on the target host (replace `<target_dir>` with a suitable path, or remove to install in `./greek-manifests`):
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git clone https://git.electricmandarine.cloud/nicolo/greek-manifests <target_dir>
|
git clone https://git.electricmandarine.cloud/nicolo/greek-manifests <target_dir>
|
||||||
```
|
```
|
||||||
|
|
||||||
then run the following commands from the root folder:
|
then run the following commands from the root folder:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
yarn
|
yarn
|
||||||
node app.mjs
|
node app.mjs
|
||||||
```
|
```
|
||||||
@@ -30,9 +30,9 @@ This will start the [Express](https://expressjs.com) web server, which will rema
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Automatic JSDoc documentation for the codebase can be generated by running the following command from the root folder:
|
Automatic [JSDoc](https://jsdoc.app) documentation for the codebase can be generated by running the following command from the project's root folder:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
jsdoc -c jsdoc.json
|
jsdoc -c jsdoc.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,14 @@ export function getCanvasName(imgFilename, technique) {
|
|||||||
canvasName += imgFilename.split('_')[3].replace(/\..*$/,'');
|
canvasName += imgFilename.split('_')[3].replace(/\..*$/,'');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if name is of `fr01&02` type...
|
||||||
|
let names = canvasName.split('&');
|
||||||
|
|
||||||
|
// Remove leading zeroes everywhere
|
||||||
|
names = names.map(name => name.replaceAll(/^([a-z]+)?0*(\d+)/ig, '$1$2'));
|
||||||
|
// Rejoin if needed...
|
||||||
|
canvasName = names.join('&');
|
||||||
|
|
||||||
return canvasName;
|
return canvasName;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user