Mercurial > hg > digilib
changeset 1686:e46756f0d661
Config to select page labels and documentation for Manifester.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 26 Mar 2018 19:09:27 +0200 |
parents | b234dd84320d |
children | dce010b1105c |
files | doc/src/site/markdown/iiif-api.md iiif-presentation/src/main/java/digilib/conf/ManifestServletConfiguration.java iiif-presentation/src/main/java/digilib/servlet/Manifester.java |
diffstat | 3 files changed, 47 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/src/site/markdown/iiif-api.md Mon Mar 26 16:12:41 2018 +0200 +++ b/doc/src/site/markdown/iiif-api.md Mon Mar 26 19:09:27 2018 +0200 @@ -60,3 +60,25 @@ [http://universalviewer.io/](http://universalviewer.io/) and enter the URL of your manifest in the "view a manifest" box on the page. This will work even with a local digilib installation since the Javascript in your Browser reads and interprets the manifest. + +The minimal information in the manifest can be enhanced with additional metadata or the replaced +by a custom manifest. If the servlet finds a file with the name + + manifest.json + +in a directory then the contents of that file are sent instead of an auto-generated manifest. +This works also in directories with no images so you could put a file with +[collection](http://iiif.io/api/presentation/2.1/#collection) information in a higher-level directory. + +If the servlet finds a file with the name + + manifest-meta.json + +in a directory with images then the contents of that file are added to the top-level manifest +(`@context`, `@type`, `@id`, `sequences` are ignored). You can use this to add real bibliographical +information to the manifest. + +The configuration parameter `iiif-manifest-page-label` determines the format of the label of each image: +`filename` uses the image file name (default, sans extension), `index` uses the index (counting from 1). + +
--- a/iiif-presentation/src/main/java/digilib/conf/ManifestServletConfiguration.java Mon Mar 26 16:12:41 2018 +0200 +++ b/iiif-presentation/src/main/java/digilib/conf/ManifestServletConfiguration.java Mon Mar 26 19:09:27 2018 +0200 @@ -67,6 +67,8 @@ newParameter("webapp-base-url", null, null, 'f'); // Scaler servlet name used in constructing IIIF image API paths newParameter("scaler-servlet-name", "Scaler", null, 'f'); + // how to generate label for pages + newParameter("iiif-manifest-page-label", "filename", null, 'f'); } /* @@ -78,10 +80,8 @@ @Override public void configure(ServletContext context) { super.configure(context); - // set version setValue("servlet.version", getVersion()); - } /**
--- a/iiif-presentation/src/main/java/digilib/servlet/Manifester.java Mon Mar 26 16:12:41 2018 +0200 +++ b/iiif-presentation/src/main/java/digilib/servlet/Manifester.java Mon Mar 26 19:09:27 2018 +0200 @@ -1,9 +1,5 @@ package digilib.servlet; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - /* * #%L * @@ -11,7 +7,7 @@ * * Digital Image Library servlet components * %% - * Copyright (C) 2003 - 2017 MPIWG Berlin + * Copyright (C) 2003 - 2018 MPIWG Berlin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -31,6 +27,10 @@ * Created on 24.5.2017 */ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + import java.io.IOException; import java.util.EnumSet; import java.util.List; @@ -71,6 +71,9 @@ /** * Servlet for creating IIIF Presentation API manifests. * + * Reads file manifest.json to replace the automatically generated output. + * Reads file manifest-meta.json and merges the content into the top-level + * of the generated manifest. * * @author casties * @@ -108,6 +111,9 @@ /** set CORS header ACAO* for info requests */ protected boolean corsForInfoRequests = true; + + /** how to create label for pages */ + protected String pageLabelMode; /* * (non-Javadoc) @@ -141,6 +147,8 @@ iiifPathSep = dlConfig.getAsString("iiif-slash-replacement"); // CORS for info requests corsForInfoRequests = dlConfig.getAsBoolean("iiif-info-cors"); + // page label mode + pageLabelMode = dlConfig.getAsString("iiif-manifest-page-label"); } /** @@ -369,6 +377,9 @@ } else if (k.equals("@id")) { // we already have id continue; + } else if (k.equals("sequences")) { + // we already have sequences + continue; } else if (k.equals("label")) { // copy label hasLabel = true; @@ -469,9 +480,15 @@ manifest.writeStartObject() .write("@type", "sc:Canvas") .write("@id", params.manifestUrl + "/canvas/p" + idx) - .write("label", "image " + FileOps.basename(imgFile.getName())) .write("height", imgSize.getHeight()) .write("width", imgSize.getWidth()); + + if (pageLabelMode.equals("filename")) { + manifest.write("label", FileOps.basename(imgFile.getName())); + } else { + manifest.write("label", Integer.toString(idx)); + } + /* * images */