Skip to content

Commit

Permalink
Merge branch 'master' of ssh://[email protected]/robcast/digilib.git
Browse files Browse the repository at this point in the history
  • Loading branch information
robcast committed Sep 12, 2024
2 parents 3b26520 + faecb8c commit 9115105
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
7 changes: 7 additions & 0 deletions doc/src/site/markdown/digilib-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ The prefix (after `Scaler`) that leads to the IIIF API.

The character that replaces a slash in the identifier of IIIF requests.

```xml
<parameter name="iiif-image-base-url" value="" />
```

The base URL used in constructing IIIF information resource URLs (needs to include servlet name and iiif-prefix).
This is only necessary in some cases behind a proxy.


### Threading options

Expand Down
8 changes: 7 additions & 1 deletion doc/src/site/markdown/iiif-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ in a directory with images then the contents of that file are added to the top-l
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).
the value `filename` uses the image file name (default, sans extension), `index` uses the index (counting from 1).

Additional configuration parameters can optionally be used to fix the generation of URLs in the IIIF presentation
API output when running behind a proxy that changes URL paths:

* `iiif-manifest-base-url`: base URL used in constructing IIIF manifests including servlet name and iiif-prefix
* `webapp-base-url`: web-application base URL used in constructing API paths
* `scaler-servlet-name`: Scaler servlet name used in constructing IIIF image API paths

21 changes: 14 additions & 7 deletions servlet/src/main/java/digilib/servlet/ServletOps.java
Original file line number Diff line number Diff line change
Expand Up @@ -737,19 +737,26 @@ protected static void writeIiifV3Info(JsonGenerator info, Logger logger, ImageSi
* @return
*/
public static String getIiifImageUrl(DigilibServletRequest dlReq) {
String url = dlConfig.getAsString("iiif-image-base-url");
if (!url.isEmpty()) {
// create url from base-url config and undecoded PATH_INFO
String iiifPrefix = dlReq.iiifPrefix;
if (dlConfig.hasValue("iiif-image-base-url")) {
/*
* base-url is set - we're behind a proxy and can't use getRequestURL directly.
* We need to re-create the outside url from iiif-image-base-url config and undecoded
* getRequestURI (getPathInfo decodes encoded symbols in the path).
*/
String url = dlConfig.getAsString("iiif-image-base-url");
// get configured iiif-prefix (not prefix+version in dlReq)
String iiifPrefix = dlConfig.getAsString("iiif-prefix");
url = url.substring(0, url.lastIndexOf(iiifPrefix) - 1);
// we can't just take pathInfo because it decodes encoded symbols in the path
// get undecoded internal uri
String uri = dlReq.getServletRequest().getRequestURI();
// add end of internal uri to external base url
url += uri.substring(uri.lastIndexOf(iiifPrefix) - 1, uri.length());
return url;
} else {
// create url from request
url = dlReq.getServletRequest().getRequestURL().toString();
String url = dlReq.getServletRequest().getRequestURL().toString();
return url;
}
return url;
}

/**
Expand Down

0 comments on commit 9115105

Please sign in to comment.