Skip to content

Commit

Permalink
Now distinguishes between not finding an object (which redirects to
Browse files Browse the repository at this point in the history
ocfl_err_pending) and not finding the content within an object (which
redirects to ocfl_err_not_found)
  • Loading branch information
Mike Lynch authored and Mike Lynch committed Feb 5, 2020
1 parent 09d2daa commit 08d5e05
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
7 changes: 6 additions & 1 deletion conf.d/ocfl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ server {
root /etc/share/nginx/html/;
}

location /error/ {
root /etc/share/nginx/html/;
}


set $ocfl_files /etc/share/nginx/html/ocfl;
set $ocfl_versions on;
set $ocfl_err_pending /error/pending.html;
set $ocfl_err_not_found /error/404.html;

location /trees/ {
set $ocfl_repo trees_ocfl;
set $ocfl_path trees;
set $ocfl_index_file ro-crate-preview.html;
set $ocfl_autoindex on;
js_content ocfl;
}
Expand Down
11 changes: 11 additions & 0 deletions doc/ocfl-nginx.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ Each of the locations representing the OCFL directory needs to set its `root` di

These can be configured for the whole server (all repos) or for individual repos

### $ocfl_err_pending

Relative URL to redirect to when ocfl.js can't find the requested OID. This may be different to a 'resource not found' message because the object may not have been written to the live repository yet

### $ocfl_err_not_found

Relative URL to redirect to in two cases:

- the incoming path can't be parsed by the REPO/OID(.vN)/PATH pattern
- the repo and oid are found, but the path doesn't exist at the requested version

### $ocfl_index_file

This is the equivalent of the nginx `index` directive. If a file with this name is found in the path (and exists in the requested version) it will be returned by default. If no such file is found, a 404 error is returned.
Expand Down
14 changes: 7 additions & 7 deletions js/ocfl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ocfl(req) {
var match = req.uri.match(pattern);
if( !match ) {
req.error("Match failed " + pattern);
req.internalRedirect("/50x.html");
req.internalRedirect(req.variables.ocfl_err_not_found);
} else {
var oid = match[1];
var v = match[2];
Expand All @@ -37,8 +37,8 @@ function ocfl(req) {
}
var inv = load_inventory(req, ocfl_files + '/' + opath);
if( ! inv ) {
req.error("Couldn't load inventory for " + object);
req.internalRedirect('/404.html');
req.internalRedirect(req.variables.ocfl_err_pending);
return;
}
if( !v ) {
v = inv.head;
Expand All @@ -51,7 +51,7 @@ function ocfl(req) {
req.error("Looking for version " + v);
if( ! inv.versions[v] ) {
req.error("Couldn't find version " + v);
req.internalRedirect("/404.html");
req.internalRedirect(req.variables.ocfl_err_not_found);
}
if( allow_autoindex === 'on' && ( content === '' || content.slice(-1) === '/' ) ) {
auto_index(ocfl_repo, req, oid, inv, v, content);
Expand All @@ -63,7 +63,7 @@ function ocfl(req) {
req.internalRedirect(newroute);
} else {
req.error("Version not found");
req.internalRedirect("/404.html");
req.internalRedirect(req.variables.ocfl_err_not_found);
}
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ function auto_index(repo, req, oid, inv, v, path) {
send_html(req, page_html(oid + '.' + v + '/' + path, links, null));
} else {
req.error("No match found for path " + path);
req.internalRedirect("/404.html");
req.internalRedirect(req.variables.ocfl_err_not_found);
}
}

Expand All @@ -136,7 +136,7 @@ function history(repo_url, req, oid, inv, path) {
return state[h].includes(path);
});
if( hash.length > 0 ) {
req.error("Adding " + hash + " to versions");
req.warn("Adding " + hash + " to versions");
versions[v] = hash[0];
}
});
Expand Down

0 comments on commit 08d5e05

Please sign in to comment.