Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian committed Jul 4, 2019
1 parent 8e98ff2 commit b9ac27f
Show file tree
Hide file tree
Showing 64 changed files with 5,587 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

cache
Binary file added data/Audio & Video/Audio/378_Amsterdam.ogg
Binary file not shown.
5 changes: 5 additions & 0 deletions data/Audio & Video/Audio/378_Amsterdam.ogg.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by/3.0",
"attribution": "User:Quichot",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by/3.0",
"attribution": "<a href=\"https://www.amsterdammuseum.nl\">Amsterdam Museum</a>",
"logo": "https://www.amsterdammuseum.nl/sites/default/files/logo.png"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by-sa/3.0/nl/deed.en",
"attribution": "<a href=\"https://www.beeldengeluid.nl\">Netherlands Institute for Sound and Vision</a>",
"logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Open_Beelden_logo.png/100px-Open_Beelden_logo.png"
}
Binary file added data/Images/Amsterdam_-_Boat_-_0635.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions data/Images/Amsterdam_-_Boat_-_0635.jpg.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by-sa/3.0",
"attribution": "Jorge Royan",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by/3.0",
"attribution": "Nikolai Karaneschev",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png"
}
Binary file added data/Images/Concertgebouw_04.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions data/Images/Concertgebouw_04.jpg.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by/4.0",
"attribution": "Sebastian Koppehel",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by-sa/3.0",
"attribution": "Massimo Catarinella",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "https://creativecommons.org/licenses/by-sa/3.0",
"attribution": "Maarten Sepp",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png"
}
Binary file added data/Info/Longer introduction.docx
Binary file not shown.
22 changes: 22 additions & 0 deletions data/Info/Longer introduction.docx.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"license": "http://creativecommons.org/licenses/by-sa/3.0/",
"attribution": "<a href=\"https://en.wikipedia.org\">Provided by Wikipedia</a>",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png",
"rendering": [
{
"@id": "http://localhost:3333/file/manifestation/access",
"label": "Protocol 2002-04-11.pdf (Access copy)",
"format": "application/pdf"
},
{
"@id": "http://localhost:3333/file/manifestation/original",
"label": "Protocol 2002-04-11.pdf (Preservation copy)",
"format": "application/pdf"
},
{
"@id": "http://localhost:3333/file/manifestation/original",
"label": "Protocol 2002-04-11.docx (Original master)",
"format": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
}
]
}
15 changes: 15 additions & 0 deletions data/Info/Short information.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Amsterdam (/ˈæmstərdæm/, UK also /ˌæmstərˈdæm/; Dutch: [ɑmstərˈdɑm] (About this soundlisten)) is the capital city and
most populous municipality of the Netherlands. Its status as the capital is mandated by the Constitution of the
Netherlands, although it is not the seat of the government, which is The Hague. Amsterdam has a population of 866,737
within the city proper, 1,380,872 in the urban area and 2,410,960 in the metropolitan area. The city is located in the
province of North Holland in the west of the country but is not its capital, which is Haarlem. The Amsterdam
metropolitan area comprises much of the northern part of the Randstad, one of the larger conurbations in Europe, which
has a population of approximately 8.1 million.

Amsterdam's name derives from Amstelredamme, indicative of the city's origin around a dam in the river Amstel.
Originating as a small fishing village in the late 12th century, Amsterdam became one of the most important ports in
the world during the Dutch Golden Age (17th century), as a result of its innovative developments in trade. During that
time, the city was the leading centre for finance and trade. In the 19th and 20th centuries the city expanded, and many
new neighbourhoods and suburbs were planned and built. The 17th-century canals of Amsterdam and the 19–20th century
Defence Line of Amsterdam are on the UNESCO World Heritage List. Since the annexation of the municipality of Sloten in
1921 by the municipality of Amsterdam, the oldest historic part of the city lies in Sloten, dating to the 9th century.
5 changes: 5 additions & 0 deletions data/Info/Short information.txt.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"license": "http://creativecommons.org/licenses/by-sa/3.0/",
"attribution": "<a href=\"https://en.wikipedia.org\">Provided by Wikipedia</a>",
"logo": "https://en.wikipedia.org/static/images/project-logos/enwiki.png"
}
Binary file added data/Info/___Longer introduction.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions data/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Amsterdam",
"description": "A fictitious package with <a href=\"https://commons.wikimedia.org/wiki/Category:Amsterdam\">commons</a> of the city of <a href=\"https://en.wikipedia.org/wiki/Amsterdam\">Amsterdam</a>"
}
2 changes: 2 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NODE_ENV=development
IIIF_TEST_SERVER_PORT=3333
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"dependencies": {
"dotenv": "^6.0.0",
"file-icon-vectors": "^1.0.0",
"filesize": "^4.1.2",
"image-size": "^0.7.4",
"koa": "^2.5.2",
"koa-bodyparser": "^4.2.1",
"koa-route": "^3.2.0",
"koa-router": "^7.4.0",
"koa-static-server": "^1.3.4",
"mime-types": "^2.1.20",
"sharp": "^0.22.1"
},
"devDependencies": {
"@types/image-size": "^0.7.0",
"@types/koa": "^2.0.48",
"@types/koa-router": "^7.0.40",
"@types/mime-types": "^2.1.0",
"@types/node": "^12.0.0",
"@types/sharp": "^0.22.2",
"typescript": "^3.4.1",
"typescript-tslint-plugin": "^0.3.1"
},
"scripts": {
"watch-server": "nodemon --watch \"src/**/*\" -e ts,tsx --exec ts-node ./src/server.ts",
"build-server": "tsc"
}
}
92 changes: 92 additions & 0 deletions src/api/collection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import * as Router from 'koa-router';
import * as fs from 'fs';
import * as path from 'path';
import common from './common';

const router: Router = new Router();

router.get('/iiif/collection/:id', ctx => {

let id = '/';
if (ctx.params.id !== undefined) {
id = common.decode(ctx.params.id);
}
if (id === 'demo') {
id = '/';
}

const objectPath = path.join(common.getDemoDataPath(), id);


if (!fs.existsSync(objectPath)) {
ctx.throw(404)
}

if (!fs.lstatSync(objectPath).isDirectory()) {
ctx.throw(404)
}

let output: any = {
'@id': common.getUriByObjectPath(objectPath, ctx, 'collection'),
'@type': 'sc:Collection',
label: path.basename(objectPath),
'@context': 'http://iiif.io/api/collection/2/context.json'
};

if (id !== '/') {
const parentPath = path.resolve(objectPath, '..');
output.within = common.getUriByObjectPath(parentPath, ctx, 'collection');
}

fs.readdirSync(objectPath).map((name: string) => {

const subObjectPath = path.join(objectPath, name);

if (fs.lstatSync(subObjectPath).isDirectory()) {
if (!output.hasOwnProperty('collections')) {
output.collections = [];
}

output.collections.push(
{
'@id': common.getUriByObjectPath(subObjectPath, ctx, 'collection'),
'@type': 'sc:Collection',
label: name,
}
);

} else {
if (name.endsWith('manifest.json')) {
return;
}

if (name.startsWith('___')) {
return;
}

if (!output.hasOwnProperty('manifests')) {
output.manifests = [];
}

const mediaTypeAndFormat = common.getMediaTypeAndFormat(subObjectPath, ctx);

let manifest = {
'@id': common.getUriByObjectPath(subObjectPath, ctx, 'manifest'),
'@type': 'sc:Manifest',
label: name,
thumbnail: mediaTypeAndFormat.thumbnail,
};

manifest = common.addMetadata(manifest, subObjectPath);

output.manifests.push(manifest);
}
});

output = common.addMetadata(output, objectPath);

ctx.body = output;

});

export default router.routes();
Loading

0 comments on commit b9ac27f

Please sign in to comment.