# HG changeset patch # User Robert Casties # Date 1511273911 -3600 # Node ID 75a74f7045b482e53f3378cbc93a307fdd3024aa # Parent dc440131299bf9ae27d40d06b76f232f4de019ad# Parent 28df291d4e263aa7637fc28782ecc82d50d987cd Merge branch 'master' into release-2.5 Conflicts: common/src/main/java/digilib/conf/DigilibConfiguration.java diff -r dc440131299b -r 75a74f7045b4 .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Tue Nov 21 15:18:31 2017 +0100 @@ -0,0 +1,7 @@ +/.project +/*/.project +/target/ +/*/target/ +/.settings/ +/*/.settings/ +/*/.classpath diff -r dc440131299b -r 75a74f7045b4 README.md --- a/README.md Mon Jun 12 16:08:27 2017 +0200 +++ b/README.md Tue Nov 21 15:18:31 2017 +0100 @@ -28,11 +28,36 @@ ## Where can I get digilib? -`digilib` source code, binaries and documentation can be found on the -[digilib project pages](https://sourceforge.net/projects/digilib/) -on [SourceForge](https://sourceforge.net/): - -* [Source code](https://sourceforge.net/p/digilib/code/ci/default/tree/) +* [Source code](https://github.com/robcast/digilib) +* [Issue tracker](https://github.com/robcast/digilib/issues) * Daily built [WAR files](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/) * Daily built [Javadoc](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/javadoc/) * [Maven repository](http://it-dev.mpiwg-berlin.mpg.de/maven-repo/) + +`digilib` documentation can be found on the +[digilib documentation pages](https://robcast.github.io/digilib/) on GitHub +or on [SourceForge](http://digilib.sourceforge.net). + +## How do I run digilib? + +Requirements: +* [git](https://git-scm.com/) +* [Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) version 7 or later +* [Maven](https://maven.apache.org/) version 3 or later + +Build: +1. Clone the digilib repository + + `git clone https://github.com/robcast/digilib.git` + +2. Change to the repository + + `cd digilib` + +3. build and run the webapp in the embedded Jetty runtime for development + + `mvn jetty:run-exploded --projects webapp` + + and watch digilib at http://localhost:8080/digilib/digilib.html + +or follow the build and install instructions on the [documentation pages](https://robcast.github.io/digilib/). diff -r dc440131299b -r 75a74f7045b4 common/pom.xml --- a/common/pom.xml Mon Jun 12 16:08:27 2017 +0200 +++ b/common/pom.xml Tue Nov 21 15:18:31 2017 +0100 @@ -12,7 +12,7 @@ digilib-common digilib-common The Digital Image Library - common library - http://digilib.sourceforge.net + https://github.com/robcast/digilib jar diff -r dc440131299b -r 75a74f7045b4 common/src/main/java/digilib/conf/DigilibConfiguration.java --- a/common/src/main/java/digilib/conf/DigilibConfiguration.java Mon Jun 12 16:08:27 2017 +0200 +++ b/common/src/main/java/digilib/conf/DigilibConfiguration.java Tue Nov 21 15:18:31 2017 +0100 @@ -57,7 +57,11 @@ /** digilib version */ public static String getClassVersion() { +<<<<<<< HEAD return "2.5.3"; +======= + return "2.5.4a"; +>>>>>>> refs/heads/master } /* non-static getVersion for Java inheritance */ diff -r dc440131299b -r 75a74f7045b4 common/src/main/java/digilib/image/DocuImage.java --- a/common/src/main/java/digilib/image/DocuImage.java Mon Jun 12 16:08:27 2017 +0200 +++ b/common/src/main/java/digilib/image/DocuImage.java Tue Nov 21 15:18:31 2017 +0100 @@ -318,4 +318,20 @@ * @param hackString */ public void setHacks(String hackString); + + /** + * Set optional image specific hints with additional information. + * + * @param key + * @param value + */ + public void setHint(String key, Object value); + + /** + * Returns the image specific hint with the given key. + * + * @param key + * @return + */ + public Object getHint(String key); } diff -r dc440131299b -r 75a74f7045b4 common/src/main/java/digilib/image/DocuImageImpl.java --- a/common/src/main/java/digilib/image/DocuImageImpl.java Mon Jun 12 16:08:27 2017 +0200 +++ b/common/src/main/java/digilib/image/DocuImageImpl.java Tue Nov 21 15:18:31 2017 +0100 @@ -30,9 +30,11 @@ import java.awt.Rectangle; import java.io.IOException; import java.io.OutputStream; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Map; import org.apache.log4j.Logger; @@ -68,6 +70,9 @@ /** ImageInput that was read */ protected ImageInput input; + + /** image specific hints */ + protected Map hints = new HashMap(); /** * Returns the version. @@ -228,4 +233,20 @@ // doing nothing } + /* (non-Javadoc) + * @see digilib.image.DocuImage#setHint(java.lang.String, java.lang.Object) + */ + @Override + public void setHint(String key, Object value) { + hints.put(key, value); + } + + /* (non-Javadoc) + * @see digilib.image.DocuImage#getHint(java.lang.String) + */ + @Override + public Object getHint(String key) { + return hints.get(key); + } + } diff -r dc440131299b -r 75a74f7045b4 common/src/main/java/digilib/io/FileOps.java --- a/common/src/main/java/digilib/io/FileOps.java Mon Jun 12 16:08:27 2017 +0200 +++ b/common/src/main/java/digilib/io/FileOps.java Tue Nov 21 15:18:31 2017 +0100 @@ -295,6 +295,23 @@ return pathname.substring(a, e + 1); } + + /** + * Returns if the filename is valid. + * + * Currently only checks if filename starts with a dot. + * + * @param filename + * @return + */ + public static boolean isValidFilename(String filename) { + // exclude filenames starting with a dot + if (filename.startsWith(".")) { + return false; + } + return true; + } + /** * FileFilter for general files */ @@ -311,7 +328,11 @@ static class ImageFileFilter implements FileFilter { public boolean accept(File f) { - return (classForFilename(f.getName()) == FileClass.IMAGE); + String fn = f.getName(); + if (isValidFilename(fn)) { + return (classForFilename(fn) == FileClass.IMAGE); + } + return false; } } @@ -320,9 +341,13 @@ */ static class TextFileFilter implements FileFilter { - public boolean accept(File f) { - return (classForFilename(f.getName()) == FileClass.TEXT); - } + public boolean accept(File f) { + String fn = f.getName(); + if (isValidFilename(fn)) { + return (classForFilename(fn) == FileClass.TEXT); + } + return false; + } } /** @@ -331,9 +356,13 @@ */ static class SVGFileFilter implements FileFilter { - public boolean accept(File f) { - return (classForFilename(f.getName()) == FileClass.SVG); - } + public boolean accept(File f) { + String fn = f.getName(); + if (isValidFilename(fn)) { + return (classForFilename(fn) == FileClass.SVG); + } + return false; + } } /** diff -r dc440131299b -r 75a74f7045b4 common/src/main/java/digilib/meta/IndexMetaAuthLoader.java --- a/common/src/main/java/digilib/meta/IndexMetaAuthLoader.java Mon Jun 12 16:08:27 2017 +0200 +++ b/common/src/main/java/digilib/meta/IndexMetaAuthLoader.java Tue Nov 21 15:18:31 2017 +0100 @@ -1,20 +1,5 @@ package digilib.meta; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.log4j.Logger; - /* * #%L * IndexMetaAuthLoader -- Load XML format metadata into MetadataMaps @@ -41,6 +26,21 @@ * Author: Robert Casties (robcast@users.sourceforge.net) */ +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URI; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.log4j.Logger; + /** * Class loading index.meta files extracting image file related information. * @@ -85,12 +85,13 @@ protected String metaTag = "meta"; protected String fileTag = "file"; - protected String[] fileNameTag = {"file", "name"}; - protected String[] filePathTag = {"file", "path"}; - protected String[] fileMetaTag = {"file", "meta"}; + protected String[] fileNamePath = {"file", "name"}; + protected String[] filePathPath = {"file", "path"}; + protected String[] fileMetaPath = {"file", "meta"}; protected String imgTag = "img"; - protected String[] accessTag = {"access-conditions", "access"}; - protected String[] accessNameTag = {"access", "name"}; + protected String accessTag = "access"; + protected String[] accessPath = {"access-conditions", "access"}; + protected String[] accessNamePath = {"access", "name"}; private XMLStreamReader reader; private LinkedList tags; @@ -137,7 +138,7 @@ /* * meta tag - read contents in new meta map */ - if (tagsMatchPath(fileMetaTag)) { + if (tagsMatchPath(fileMetaPath)) { fileMeta = readMetaTag(new MetadataMap()); } else { otherMeta = readMetaTag(new MetadataMap()); @@ -171,12 +172,12 @@ // save meta in file list files.put(fn, fileMeta); } - } else if (tagsMatchPath(fileNameTag)) { + } else if (tagsMatchPath(fileNamePath)) { /* * file/name tag - record name */ filename = text.toString(); - } else if (tagsMatchPath(filePathTag)) { + } else if (tagsMatchPath(filePathPath)) { /* * file/path tag - record path */ @@ -239,7 +240,7 @@ StringBuffer text = new StringBuffer(); String accType = null; String accName = null; - if (tagsMatchPath(accessTag)) { + if (tagsMatchPath(accessPath)) { // read attribute from current access tag accType = reader.getAttributeValue(null, "type"); } @@ -258,12 +259,12 @@ } else if (event == XMLStreamConstants.CHARACTERS) { text.append(reader.getText()); } else if (event == XMLStreamConstants.END_ELEMENT) { - if (tagsMatchPath(accessNameTag)) { + if (tagsMatchPath(accessNamePath)) { /* * access/name tag */ accName = text.toString(); - } else if (tagsMatchPath(accessTag)) { + } else if (tagsMatchPath(accessPath)) { /* * access tag - we're done */ @@ -305,7 +306,7 @@ * img tag */ map = readTagToMap(map); - } else if (tagsMatchPath(accessTag)) { + } else if (tagsMatchPath(accessPath)) { /* * access tag */ diff -r dc440131299b -r 75a74f7045b4 doc/pom.xml --- a/doc/pom.xml Mon Jun 12 16:08:27 2017 +0200 +++ b/doc/pom.xml Tue Nov 21 15:18:31 2017 +0100 @@ -9,7 +9,7 @@ pom digilib-doc The Digital Image Library - documentation - http://digilib.sourceforge.net + https://github.com/robcast/digilib @@ -24,6 +24,25 @@ + + com.github.github + site-maven-plugin + 0.12 + + digilib + robcast + github + Creating site for ${project.version} + + + + + site + + site + + + diff -r dc440131299b -r 75a74f7045b4 doc/src/site/markdown/build-maven.md --- a/doc/src/site/markdown/build-maven.md Mon Jun 12 16:08:27 2017 +0200 +++ b/doc/src/site/markdown/build-maven.md Tue Nov 21 15:18:31 2017 +0100 @@ -1,34 +1,30 @@ # Building digilib with Maven -The easiest way to get the latest and greatest digilib is the [Maven](http://maven.apache.org/) build tool. -It will download, compile, and install the latest digilib version and all required libraries. +The best way to get the latest and greatest digilib is using the [git](https://git-scm.com/) version control and the [Maven](http://maven.apache.org/) build tool. +Git will download the digilib code and Maven will compile, and install the latest digilib version and all required libraries. ## What you need -* [Java](http://www.java.com/) (1.5 or higher) +* [git](https://git-scm.com/) +* [Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (7 or higher) * [Maven](http://maven.apache.org/) -* [Mercurial](http://mercurial.selenic.com/) -* A Servlet container like [Tomcat](http://tomcat.apache.org/) -or [Jetty](http://www.eclipse.org/jetty/) to run the web application. -## Quick build +## Quick developer build and run -The fastest way to build the digilib web application is to download the digilib -project file [pom.xml](https://sourceforge.net/p/digilib/code/ci/default/tree/pom.xml?format=raw) -(download and save it) and run - - mvn scm:bootstrap -N - -in the same directory as the `pom.xml` file. +1. Clone the digilib repository into a directory `digilib` + + git clone https://github.com/robcast/digilib.git + +2. Change to the directory + + cd digilib + +3. build and run the webapp in the embedded Jetty runtime for development + + mvn jetty:run-exploded --projects webapp + + and watch your digilib at http://localhost:8080/digilib.html -This will create a web application directory `digilib-webapp-2.2-SNAPSHOT` -and a WAR file `digilib-webapp-2.2-SNAPSHOT-srv3.war` (or similar) -in the subdirectory `target/checkout/webapp/target/` - -Digilib uses the Asynchronous Servlet API (3.0) by default. You will need Java version 6 -and Tomcat version 7 or Jetty version 8 or later to use it. -If you want to use the old non-Asynchronous Servlet API (2.3) add `-Pservlet2` -to the Maven command line above. ## Developer build @@ -38,31 +34,27 @@ To check out the latest source code into the directory `digilib` run - hg clone http://hg.code.sf.net/p/digilib/code digilib + git clone https://github.com/robcast/digilib.git + +and change into the repository directory -The digilib configuration files are now in `digilib/webapp/src/main/webapp/WEB-INF/` + cd digilib If you want to update your copy of digilib to the latest version at some time in the future just run - hg pull - hg up - -in the `digilib` directory. + git pull -To build the resulting source code, change into the `digilib` -directory you checked out above and run +The digilib configuration files are in the sub-directory `webapp/src/main/webapp/WEB-INF/` (see below). + +To build the resulting source code run mvn package -This will create a web application directory `digilib-webapp-2.2-SNAPSHOT` -and a WAR file `digilib-webapp-2.2-SNAPSHOT-srv3.war` (or similar) in +This will create a web application directory `digilib-webapp-2.5-SNAPSHOT` +and a WAR file `digilib-webapp-2.5-SNAPSHOT-srv3.war` (or similar) in the subdirectory `webapp/target/` . -Digilib uses the Asynchronous Servlet API (3.0) by default. You will need Java version 6 -and Tomcat version 7 or Jetty version 8 or later to use it. -If you want to use the old non-Asynchronous Servlet API (2.3) add `-Pservlet2` -to the Maven command line above. ## Deploying the web application by hand @@ -72,20 +64,32 @@ Since the URL of your digilib server starts with the name of the web application and the name of the web application is derived from the name of the web application directory or the WAR file **please rename the web application directory or WAR file -to `digitallibrary` before you start** +to `digilib` before you start** -Then you should see your digilib running at the URL -[http://localhost:8080/digitallibrary/jquery/digilib.html](http://localhost:8080/digitallibrary/jquery/digilib.html) +Then you should see digilib running at the URL +http://localhost:8080/digilib/digilib.html If you use the unmodified default configuration you should see the digilib logo and other sample images from the `sample-images` directory of the web application. +For more detailed documentation see the [deployment instructions](install-digilib.html). + ## Configuring digilib -To change the configuration of digilib just edit the file `digilib-config.xml` -in the web application directory (`digitallibrary/WEB-INF/digilib-config.xml`). -Documentation of the configuration options is [here](digilib-config.html). +To change the configuration of digilib just create and edit the file `digilib-config.xml` +in the web application WEB-INF directory (`webapp/src/main/webapp/WEB-INF/digilib-config.xml`). +You can copy and rename the sample file `digilib-config.xml.template` to get some default options to start with. +Please check the [documentation of the configuration options](digilib-config.html). You can see a summary of your running digilib configuration at the URL -[http://localhost:8080/digitallibrary/server/dlConfig.jsp](http://localhost:8080/digitallibrary/server/dlConfig.jsp) +http://localhost:8080/digilib/server/dlConfig.jsp + +## Additional Maven build options + +### servlet2 +Digilib uses the Asynchronous Servlet API (3.0) by default. You will need Java version 6 or later +and Tomcat version 7 or Jetty version 8 or later to use it. +If you want to use the old non-Asynchronous Servlet API (2.3) add `-Pservlet2` +to the Maven command line above. + diff -r dc440131299b -r 75a74f7045b4 doc/src/site/markdown/digilib-config.md --- a/doc/src/site/markdown/digilib-config.md Mon Jun 12 16:08:27 2017 +0200 +++ b/doc/src/site/markdown/digilib-config.md Tue Nov 21 15:18:31 2017 +0100 @@ -1,100 +1,272 @@ # Configuring digilib -## digilib-config.xml +The main configuration for *digilib* is the XML file `digilib-config.xml` in the +`WEB-INF` directory of the webapp. Alternatively you can also use a Java properties +file `digilib.properties` somewhere in the classpath. +(If you really need a different location for the XML file you can define it in +the `config-file` init-parameter to the Servlet. **TODO** add an example) -The main configuration for digilib is the XML file `digilib-config.xml` in the `WEB-INF` -directory in the webapp or a Java properties file `digilib.properties` somewhere in the classpath. -(If you really need a different location for the XML file you can define it in the `config-file` -init-parameter to the Servlet.) +In the configuration file you can set lots of paths and options. *digilib* uses +default values for all configuration settings that meet most requirements. +Hence you have to configure only the settings that you want to change. The +**`basedir-list`** parameter however is **mandatory** unless you only want to serve +the contributed example images for an evaluation. -In the configuration file you can set lots of paths and options. digilib uses -default values for all configuration settings that meet most requirements -so you have to configure only the settings that you want to change. +All options are defined as `parameter` elements with the attributes `name` and +`value` that are wrapped in the root element `digilib-config`. A minimal +configuration looks like this: -You have to adjust the **`basedir-list`** parameter to the directories -where your images are installed. The directory path has to be an absolute -path following the conventions of your operating system (a relative path -is taken to be relative to the web application directory). +```xml + + + + +``` -You need only one directory if you don't want to provide pre-scaled low resolution -versions of your images. If you have pre-scaled images the directory with the -high-resolution images must be the first entry in the list. +A more extensive example is included in the sources as +[digilib-config.xml.template](https://github.com/robcast/digilib/blob/master/webapp/src/main/webapp/WEB-INF/digilib-config.xml.template). + + +## Available parameters -Documentation on the directory layout and on using pre-scaled images is -[here](image-directories.html). +The documented parameter values below are the defaults. + +If relative paths are provided as file locations, these will be resolved with +the web application's directory as base. -A minimal configuration looks like this: +You can inspect a summary of your running digilib configuration at the URL +`/server/dlConfig.jsp`. + +### Image locations + +```xml + +``` - - - - - - -A more customized configuration may look like the following -(for another commented example see -[digilib-config.xml.template](https://sourceforge.net/p/digilib/code/ci/default/tree/webapp/src/main/webapp/WEB-INF/digilib-config.xml.template), -for a full list of -configuration options and their default values use the source: -[DigilibConfiguration](https://sourceforge.net/p/digilib/code/ci/default/tree/common/src/main/java/digilib/conf/DigilibConfiguration.java), -[DigilibServletConfiguration](https://sourceforge.net/p/digilib/code/ci/default/tree/servlet/src/main/java/digilib/conf/DigilibServletConfiguration.java), -[DigilibServlet3Configuration](https://sourceforge.net/p/digilib/code/ci/default/tree/servlet3/src/main/java/digilib/conf/DigilibServlet3Configuration.java) -): +A list of directories where images are searched. See +[this document](image-directories.html) for details. + +```xml + +``` + +This image is sent to indicate an authorization failure. + +```xml + +``` + +This image is sent to indicate a general failure. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +```xml + +``` + +This image to sent to indicate that the requested image does not exist or could not be read. + +```xml + +``` + +Enables the mapping of 'virtual directories' to actual directories in the +filesystem using a mapping file. + +```xml + +``` + +The location of the mapping file. Refer to +[digilib-map.xml.template](https://github.com/robcast/digilib/blob/master/webapp/src/main/webapp/WEB-INF/digilib-map.xml.template) +for an example. + +The file contains `mapping` elements with a `link` attribute containing a 'virtual directory' name that is mapped to the +directory given in the `dir` attribute. + + +### Image processing options + +```xml + +``` -You can supply your own icons for the "error" and "access denied" -messages by the servlet. Standard images will be used if these -parameters are not defined. +The default interpolation quality. + +* `0`: do not use interpolation (worst), +* `1`: use linear interpolation, +* `2`: use bilinear interpolation and blur-before-scale (best). + +```xml + +``` + +The maximum size of delivered images as pixel area, `40000` means up to 200x200 or 100x400, `0` means no limit. -If you need authorization set `use-authorization` to true and read the +```xml + +``` + +Defines whether requests with `mo=file` or `mo=rawfile` as parameter are allowed to download files (see +[Scaler API](scaler-api.html)). + +```xml + +``` + +Degree of subsampling on image load. This is the minimum factor that is scaled by interpolation and not by +subsampling, i.e. by skipping pixels. + + +### Authentication and authorization + +Details are provided in the [documentation on authentication and authorization](auth.html). -You can see a summary of your running digilib configuration at the URL -[http://localhost:8080/digitallibrary/server/dlConfig.jsp](http://localhost:8080/digitallibrary/server/dlConfig.jsp) +```xml + +``` + +Configuration file for authentication and authorization. The format and content of the configuration file +is determined by the chosen authentication and authorization classes. + +```xml + +``` + +The name of the cookie that holds the authentication token for `digilib.auth.OpenIdAuthnOps`. + +```xml + +``` + +The class to handle authentication. + +```xml + +``` + +The class to handle authorization. + +```xml + +``` + +Enable or disable all authorization. If `use-authorization` is `true` it also needs to be configured +using `authnops-class` and `authzops-class` and the `auth-file`. + + +### IIIF API options + +The options configure the IIIF interface. For more information see the [digilib IIIF documentation](iiif-api) + +```xml + +``` + +The IIIF API version for the generated `info.json` information response. + +```xml + +``` + +Enables the `Cross-Origin Resource Sharing` header in IIIF info requests. + +```xml + +``` + +Enables the `Cross-Origin Resource Sharing` header in IIIF image requests. + +```xml + +``` + +The prefix (after `Scaler`) that leads to the IIIF API. + +```xml + +``` + +The character that replaces a slash in the identifier of IIIF requests. + + +### Threading options + +```xml + +``` - \ No newline at end of file +The maximum number of requests waiting in the queue before sending "service unavailable". + +```xml + +``` + +The maximum number of concurrently working threads. + +```xml + +``` + +Timeout for worker threads in milliseconds. + + +### Assorted options + +```xml + +``` + +Defines how errors are presented to the user. Allowed values are `code`, `image` and +`text`. + +* `image` sends an error-image as error code (see `denied-image`, `error-image`, `notfound-image` parameters). +* `code` sends an HTTP error code, which may result in a broken image display in the browser. +* `text` sends a plain-text error message, which may result in a broken image display in the browser. + +```xml + +``` + +Enables the use of a disk cache for the image toolkit. Using the disk cache may leak file handles +and lead to resource issues if digilib runs for a long time. + +```xml + +``` + +Location of the logging configuration file. The current logger is +[Log4J 1.2](https://logging.apache.org/log4j/1.2/manual.html). + + +### Unknown category + +**TODO** move items to appropriate sections + +```xml + +``` + +Class for **TODO**. + +```xml + +``` + +Class for **TODO**. + +```xml + +``` + +Class for the `DocuImage` instance, **TODO** elaborate intended use + +```xml + +``` + +**TODO** elaborate + +```xml + +``` +Class for **TODO**. diff -r dc440131299b -r 75a74f7045b4 doc/src/site/markdown/index.md --- a/doc/src/site/markdown/index.md Mon Jun 12 16:08:27 2017 +0200 +++ b/doc/src/site/markdown/index.md Tue Nov 21 15:18:31 2017 +0100 @@ -26,10 +26,11 @@ ## Where can I get digilib? `digilib` source code, binaries and documentation can be found on the -[digilib project pages](https://sourceforge.net/projects/digilib/) -on [SourceForge](https://sourceforge.net/): +[digilib project pages](https://github.com/robcast/digilib) +on [GitHub](https://github.com) +or [SourceForge](https://sourceforge.net/projects/digilib/): -* [Source code](https://sourceforge.net/p/digilib/code/ci/default/tree/) +* [Source code](https://github.com/robcast/digilib) * Daily built [WAR files](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/) * Daily built [Javadoc](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/javadoc/) * [Maven repository](http://it-dev.mpiwg-berlin.mpg.de/maven-repo/) diff -r dc440131299b -r 75a74f7045b4 doc/src/site/markdown/install-digilib.md --- a/doc/src/site/markdown/install-digilib.md Mon Jun 12 16:08:27 2017 +0200 +++ b/doc/src/site/markdown/install-digilib.md Tue Nov 21 15:18:31 2017 +0100 @@ -2,73 +2,102 @@ To run digilib you need: -* [Java](http://www.java.com/) (1.6 or higher) +* [Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (7 or higher) * a Servlet Container like [Tomcat](http://tomcat.apache.org/) (version 7 or -higher) or [Jetty](http://www.eclipse.org/jetty/) (version 8 or higher) +later) or [Jetty](http://www.eclipse.org/jetty/) (version 8 or later) * the digilib web application as a WAR file or application directory -## Run the Servlet Container +## Start the Servlet Container Install and run the Servlet Container of your choice: [Tomcat](http://tomcat.apache.org/tomcat-7.0-doc/setup.html) or [Jetty](http://wiki.eclipse.org/Jetty/Howto/Run_Jetty). -When it runs you should be able to access the start page on +When the Servlet Container runs you should be able to access the start page on +## Deploy via WAR file or web application directory? + +A web application can be deployed either as a WAR file or a web application directory (aka "exploded web application"). + +The advantage of the WAR file is that it is easy to handle because it is just one file. + +The disadvantage of the WAR file is that it is not easy to change the [digilib configuration](digilib-config.html) +file or any of the HTML or Javascript files because they are hidden in the WAR file. + +It is possible to unpack a WAR file into a web application directory to be able to change its contents (see below). + +## Where to get a WAR file or web application directory? + +The preferred way is to [build your own](build-maven.html) WAR file or web application directory using the digilib sources. +In this way you can change the configuration files in the source directory and create a new WAR file +or web application directory any time you need. +Also you get the chance to always use the latest digilib version by updating the source code. + +You can also download a digilib WAR file with a default configuration from the +[SourceForge download page](https://sourceforge.net/projects/digilib/files/) +or the latest digilib build from the +[daily build page](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/). +The default configuration will only show a set of sample images. If you want to show your own images +you will need to change the [digilib configuration](digilib-config.html) to point to your image directories. + + ## Install a digilib WAR file -1. Download a digilib WAR file of a recent digilib release from the -SourceForge [Download page](https://sourceforge.net/projects/digilib/files/) -or the latest digilib build from the -[daily build page](https://it-dev.mpiwg-berlin.mpg.de/downloads/digilib/daily-build/). +1. Get a digilib WAR file. 2. Rename the WAR file to `digilib.war`. -3. Deploy the WAR file, i.e. drop it into the `webapps` directory of your +3. Deploy the WAR file by copying it into the `webapps` directory of your Servlet Container. 4. Restart your Servlet Container (this may not be necessary). 5. Access your digilib instance at . You will now be able to see the sample images provided with the digilib -installation. +installation in the default configuration yor your own images +if you have updated the [configuration](digilib-config.html). -If you want to use digilib to show your own images you have to change the -configuration file [digilib-config.xml](digilib-config.html) **inside** the -web application. This is hard to do with a WAR file so its better to -deploy digilib as a web application directory. +In digilib you can view images by providing the directory and file +name as the `fn` parameter to `digilib.html`, e.g. if your file is called +`ruler.jpg` and it is in the base directory you can now access the URL + + + +Read more about the layout of image files and directories +[here](image-directories.html). + ## Install digilib as a web application directory -Unpack the WAR file into a directory called `digilib` using +1. Get a digilib web application directory. +2. Rename the WAR file to `digilib.war`. +3. Deploy the WAR file by copying it into the `webapps` directory of your +Servlet Container. +4. Restart your Servlet Container (this may not be necessary). +5. Access your digilib instance at + +You will now be able to see the sample images provided with the digilib +installation in the default configuration yor your own images +if you have updated the [configuration](digilib-config.html). + +In digilib you can view images by providing the directory and file +name as the `fn` parameter to `digilib.html`, e.g. if your file is called +`ruler.jpg` and it is in the base directory you can now access the URL + + + +Read more about the layout of image files and directories +[here](image-directories.html). + + +## Unpack a WAR file into a web application directory + +You can unpack the WAR file into a directory called `digilib` using an unzip tool or the `jar -xf` Java command. Alternatively you can look into the `webapps` directory of your Servlet Container (when its not running) to see if it created an unpacked web -application directory called `digilib`. - -Alternatively you can build your own version of digilib as documented -[here](build-maven.html). - -Then: +application directory called `digilib`. Then: 1. Make sure that your Servlet Container is not running and remove any `digilib.war` files from the `webapps` directory. 2. Copy your `digilib` directory into the `webapps` directory of the Servlet Container. -3. Edit the `digilib-config.xml` file in the `WEB-INF` subdirectory of the -`digilib` directory and adjust the `basedir-list` parameter to point to -the directory with your image files [according to the -documentation](digilib-config.html). If there is no file `digilib-config.xml` -you can either create a new file or rename the sample file -`digilib-config.xml.template` to `digilib-config.xml` and edit it. -4. Start your Servlet Container. -5. Access your digilib instance at - -You can now view your own images in digilib by providing the directory and file -name as the `fn` parameter to `digilib.html`, e.g. if your file is called -`flower.jpg` and it is in a subdirectory of the base directory called -`digilib-test` you can now access the URL - - - -Read more about the layout of image files and directories -[here](image-directories.html). diff -r dc440131299b -r 75a74f7045b4 doc/src/site/markdown/server-setup.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/src/site/markdown/server-setup.md Tue Nov 21 15:18:31 2017 +0100 @@ -0,0 +1,40 @@ +# Server setups for digilib + +There are a variety of ways to deploy digilib on different server configurations for production sites. + +Here are some examples. + +## nginx as proxy + +This is an example configuration for `nginx` as a proxy for a single instance +of digilib (listening on port `8080`) that handles transport encryption and +restricts access to sensitive data to the gateway of a local network +(`1.2.3.4`). + +```nginx +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name digilib.example.org; + + # this certificate chain shall *not* include the root certificate: + ssl_certificate /etc/ssl/certs/digilib.example.org.pem; + ssl_certificate_key /etc/ssl/private/digilib.example.org.key; + + include /etc/nginx/proxy_params; + + location ~* .*/(dlConfig|dlRequest).jsp$ { + allow 1.2.3.4; + deny all; + proxy_pass http://localhost:8080; + } + + location / { + proxy_pass http://localhost:8080; + } +} +``` + +## Resources + +- the [nginx documentation](nginx.org/en/docs/) diff -r dc440131299b -r 75a74f7045b4 doc/src/site/site.xml --- a/doc/src/site/site.xml Mon Jun 12 16:08:27 2017 +0200 +++ b/doc/src/site/site.xml Tue Nov 21 15:18:31 2017 +0100 @@ -10,15 +10,16 @@ digilib - a versatile image viewing environment for the internet - http://digilib.sourceforge.net/ + https://robcast.github.io/digilib/ images/digilib-logo-small.png - http://digilib.sourceforge.net/ + https://robcast.github.io/digilib/ - - + + + @@ -28,8 +29,9 @@ + - + diff -r dc440131299b -r 75a74f7045b4 iiif-presentation/pom.xml --- a/iiif-presentation/pom.xml Mon Jun 12 16:08:27 2017 +0200 +++ b/iiif-presentation/pom.xml Tue Nov 21 15:18:31 2017 +0100 @@ -11,7 +11,7 @@ digilib-iiif-presentation digilib-iiif-presentation The Digital Image Library - IIIF presentation API manifest serving servlet - http://digilib.sourceforge.net + https://github.com/robcast/digilib UTF-8 diff -r dc440131299b -r 75a74f7045b4 iiif-presentation/src/main/java/digilib/conf/ManifestServletConfiguration.java --- a/iiif-presentation/src/main/java/digilib/conf/ManifestServletConfiguration.java Mon Jun 12 16:08:27 2017 +0200 +++ b/iiif-presentation/src/main/java/digilib/conf/ManifestServletConfiguration.java Tue Nov 21 15:18:31 2017 +0100 @@ -59,8 +59,14 @@ public ManifestServletConfiguration() { super(); + // base URL used in constructing IIIF manifests including servlet name and iiif-prefix (optional) + newParameter("iiif-manifest-base-url", null, null, 'f'); + // base URL used in constructing IIIF manifests including servlet name and iiif-prefix (optional) + newParameter("iiif-image-base-url", null, null, 'f'); + // web-application base URL used in constructing API paths (optional) + newParameter("webapp-base-url", null, null, 'f'); // Scaler servlet name used in constructing IIIF image API paths - newParameter("scaler-servlet-path", "Scaler", null, 'f'); + newParameter("scaler-servlet-name", "Scaler", null, 'f'); } /* diff -r dc440131299b -r 75a74f7045b4 iiif-presentation/src/main/java/digilib/servlet/Manifester.java --- a/iiif-presentation/src/main/java/digilib/servlet/Manifester.java Mon Jun 12 16:08:27 2017 +0200 +++ b/iiif-presentation/src/main/java/digilib/servlet/Manifester.java Tue Nov 21 15:18:31 2017 +0100 @@ -125,7 +125,7 @@ // DocuDirCache instance dirCache = (DocuDirCache) dlConfig.getValue(DigilibServletConfiguration.DIR_CACHE_KEY); // Scaler path - scalerServletPath = dlConfig.getAsString("scaler-servlet-path"); + scalerServletPath = dlConfig.getAsString("scaler-servlet-name"); // IIIF path separator iiifPathSep = dlConfig.getAsString("iiif-slash-replacement"); // CORS for info requests @@ -256,17 +256,27 @@ } /* - * get manifest base URL + * configure base URLs for manifest */ - String url = request.getRequestURL().toString(); - // get base URL for Servlets - int srvPathLen = request.getServletPath().length() + request.getPathInfo().length(); - String servletBaseUrl = url.substring(0, url.length() - srvPathLen); - // manifest base URL - String baseurl = servletBaseUrl + request.getServletPath() + "/" + dlConfig.getAsString("iiif-prefix") + "/" + identifier; - - params.manifestUrl = baseurl; - params.imgApiUrl = servletBaseUrl +"/" + this.scalerServletPath + "/" + dlConfig.getAsString("iiif-prefix"); + params.imgApiUrl = dlConfig.getAsString("iiif-image-base-url"); + String manifestBaseUrl = dlConfig.getAsString("iiif-manifest-base-url"); + if ("".equals(params.imgApiUrl) || "".equals(manifestBaseUrl)) { + // try to figure out base URLs + String servletBaseUrl = dlConfig.getAsString("webapp-base-url"); + if ("".equals(servletBaseUrl)) { + String url = request.getRequestURL().toString(); + // get base URL for web application by last occurrence of Servlet path + int srvPathLen = url.lastIndexOf(request.getServletPath()); + servletBaseUrl = url.substring(0, srvPathLen); + } + // manifest base URL + manifestBaseUrl = servletBaseUrl + request.getServletPath() + "/" + dlConfig.getAsString("iiif-prefix"); + // Image API base URL + params.imgApiUrl = servletBaseUrl + "/" + this.scalerServletPath + "/" + + dlConfig.getAsString("iiif-prefix"); + } + // full manifest URL with identifier + params.manifestUrl = manifestBaseUrl + "/" + identifier; params.identifier = identifier; params.docuDir = dlDir; @@ -366,6 +376,7 @@ ImageFileSet imgFs = (ImageFileSet) imgFile; ImageInput img = imgFs.getBiggest(); ImageSize imgSize = img.getSize(); + if (imgSize == null) continue; /* * canvas */ diff -r dc440131299b -r 75a74f7045b4 pdf/pom.xml --- a/pdf/pom.xml Mon Jun 12 16:08:27 2017 +0200 +++ b/pdf/pom.xml Tue Nov 21 15:18:31 2017 +0100 @@ -9,7 +9,7 @@ digilib-pdf digilib-pdf The Digital Image Library - PDF generation servlet - http://digilib.sourceforge.net + https://github.com/robcast/digilib + + + org.eclipse.jetty + jetty-maven-plugin + 9.2.22.v20170606 + + + /digilib + + + @@ -386,13 +397,13 @@ org.eclipse.jetty jetty-servlet - 9.2.13.v20150730 + 9.2.22.v20170606 test org.eclipse.jetty jetty-http - 9.2.13.v20150730 + 9.2.22.v20170606 test diff -r dc440131299b -r 75a74f7045b4 webapp/src/main/webapp/jquery/digilib-dbg.html --- a/webapp/src/main/webapp/jquery/digilib-dbg.html Mon Jun 12 16:08:27 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ - - - - - - Digilib jQuery: fullscreen - - - - - - - - - - - - - - - - - - - - - - - -
-

digilib doesn't work! Please switch on Javascript or notify the server administrator!

- -
- - - diff -r dc440131299b -r 75a74f7045b4 webapp/src/main/webapp/jquery/digilib-dev.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webapp/src/main/webapp/jquery/digilib-dev.html Tue Nov 21 15:18:31 2017 +0100 @@ -0,0 +1,50 @@ + + + + + + Digilib jQuery: fullscreen + + + + + + + + + + + + + + + + + + + + + + + +
+

digilib doesn't work! Please switch on Javascript or notify the server administrator!

+ +
+ + +