Comparing version 0.0.14 to 0.0.15
@@ -5,7 +5,7 @@ "use strict"; | ||
const { glob } = require('glob'); | ||
const { posix, dirname, extname, join } = require('path'); | ||
const { basename, dirname, extname, join } = require('path'); | ||
const urljoin = require('url-join'); | ||
const chalk = require('chalk'); | ||
const config = require('./config'); | ||
const contentAnnotationBoilerplate = require('./boilerplate/contentAnnotation'); | ||
const contentAnnotationBoilerplate = require('./boilerplate/contentannotation'); | ||
const yaml = require('js-yaml'); | ||
@@ -38,3 +38,3 @@ const Utils_1 = require("./Utils"); | ||
directoryName = directoryName.substr(directoryName.lastIndexOf('/')); | ||
const fileName = posix.basename(file); | ||
const fileName = basename(file); | ||
const id = urljoin(this.url.href, directoryName, fileName); | ||
@@ -70,3 +70,3 @@ if (matchingExtension) { | ||
// default to the directory name | ||
this.infoYml.label = posix.basename(this.filePath); | ||
this.infoYml.label = basename(this.filePath); | ||
} | ||
@@ -73,0 +73,0 @@ } |
@@ -5,3 +5,3 @@ "use strict"; | ||
const { glob } = require('glob'); | ||
const { join, posix } = require('path'); | ||
const { join, basename } = require('path'); | ||
const chalk = require('chalk'); | ||
@@ -16,5 +16,5 @@ const urljoin = require('url-join'); | ||
const collectionBoilerplate = require('./boilerplate/collection'); | ||
const collectionMemberBoilerplate = require('./boilerplate/collectionMember'); | ||
const collectionMemberBoilerplate = require('./boilerplate/collectionmember'); | ||
const manifestBoilerplate = require('./boilerplate/manifest'); | ||
const manifestMemberBoilerplate = require('./boilerplate/manifestMember'); | ||
const manifestMemberBoilerplate = require('./boilerplate/manifestmember'); | ||
class Directory { | ||
@@ -48,3 +48,3 @@ constructor(filePath, url) { | ||
console.log(chalk.green('creating directory for: ') + directory); | ||
this.directories.push(new Directory(directory, urljoin(this.url.href, posix.basename(directory)))); | ||
this.directories.push(new Directory(directory, urljoin(this.url.href, basename(directory)))); | ||
}); | ||
@@ -82,3 +82,3 @@ this.isCollection = this.directories.length > 0; | ||
// default to the directory name | ||
this.infoYml.label = posix.basename(this.filePath); | ||
this.infoYml.label = basename(this.filePath); | ||
} | ||
@@ -85,0 +85,0 @@ } |
{ | ||
"name": "biiif", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "A CLI to build IIIF collections", | ||
@@ -10,2 +10,5 @@ "main": "index.js", | ||
}, | ||
"scripts": { | ||
"test": "tsc && mocha" | ||
}, | ||
"keywords": [ | ||
@@ -30,4 +33,7 @@ "IIIF", | ||
"@types/node": "^8.0.53", | ||
"jsonfile": "^4.0.0", | ||
"mocha": "^4.0.1", | ||
"mock-fs": "^4.4.2", | ||
"typescript": "^2.6.1" | ||
} | ||
} |
@@ -1,7 +0,18 @@ | ||
# BIIIF (Build IIIF) | ||
# biiif (build iiif) 👷✨📃 | ||
npm i biiif -g | ||
<img src="https://travis-ci.org/edsilv/biiif.svg?branch=master" /> | ||
BIIIF uses your file system to generate static IIIF collections and manifests. | ||
``` | ||
npm i biiif --save | ||
``` | ||
``` | ||
const biiif = require('biiif'); | ||
biiif('myfolder', 'http://example.com/myfolder'); | ||
``` | ||
Tested in Node v8.9.1 | ||
biiif uses your file system to generate static [IIIF](http://iiif.io) collections and manifests. | ||
Use [biiif-cli](https://github.com/edsilv/biiif-cli) to run from a terminal. | ||
@@ -11,6 +22,4 @@ | ||
Example: | ||
## Conventions | ||
biiif myfolder -u http://example.com | ||
A collection is a folder with sub-folders whose names _do not_ start with an underscore. | ||
@@ -26,4 +35,2 @@ | ||
You must pass a `-u` parameter to specify the base URL used to generate all of the `id` IRIs. | ||
## Metadata | ||
@@ -38,4 +45,5 @@ | ||
metadata: | ||
license: Copyright Tolkien Estate | ||
License: Copyright Tolkien Estate | ||
Author: J. R. R. Tolkien | ||
Published Date: 29 July 1954 | ||
``` | ||
@@ -45,11 +53,11 @@ | ||
To add a thumbnail to your collection, manifest, or canvas simply include a file named `thumb.jpg` (any image extension will work) in the directory. | ||
To add a thumbnail to your collection, manifest, or canvas simply include a file named `thumb.jpg` (any image file extension will work) in the directory. | ||
## Examples | ||
Here is an example of how to organise your files/folders for BIIIF. | ||
Here is an example of how to organise your files/folders for biiif. | ||
This example only has a single root collection, but BIIIF will happily build collections to any nested depth. | ||
This example only has a single root collection, but biiif will happily build collections to any nested depth. | ||
BIIIF will accept a manifest folder too, generating a single manifest `index.json`. | ||
biiif will accept a manifest folder too, generating a single manifest `index.json`. | ||
@@ -56,0 +64,0 @@ ``` |
@@ -30,5 +30,7 @@ "use strict"; | ||
if (thumbnails.length) { | ||
const thumbnail = thumbnails[0]; | ||
let thumbnail = thumbnails[0]; | ||
// get the part after and inclusive of the canvas | ||
thumbnail = thumbnail.substr(thumbnail.lastIndexOf('_')); | ||
const thumbnailJson = Utils.cloneJson(thumbnailBoilerplate); | ||
thumbnailJson[0].id = urljoin(url.origin, thumbnail); | ||
thumbnailJson[0].id = urljoin(url.href, thumbnail); | ||
json.thumbnail = thumbnailJson; | ||
@@ -35,0 +37,0 @@ } |
22192
20
460
94
5
4