Skip to content

Commit

Permalink
Now locks the served ocfl version to HEAD unless there's a config line
Browse files Browse the repository at this point in the history
setting ocfl_versions to "on" for a repo
  • Loading branch information
spikelynch committed Aug 16, 2019
1 parent 4e89a1b commit 5cb9bcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions conf.d/ocfl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ server {
location /staging/ {
set $ocfl_repo staging_ocfl;
set $ocfl_path staging;
set $ocfl_versions on;
js_content ocfl;
}

location /public/ {
set $ocfl_repo public_ocfl;
set $ocfl_path public;
set $ocfl_versions on;
js_content ocfl;
}

Expand Down
10 changes: 8 additions & 2 deletions js/ocfl.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function ocfl(req) {
var ocfl_repo = req.variables.ocfl_repo;
var ocfl_files = req.variables.ocfl_files;
var index_file = req.variables.ocfl_index_file;
var ocfl_versions = req.variables.ocfl_versions;

var pattern = new RegExp(url_path + '/([^/\\.]+)(\\.v\\d+)?/(.*)$');
var match = req.uri.match(pattern);
if( !match ) {
Expand All @@ -25,8 +27,12 @@ function ocfl(req) {
var object = pairtree(oid);
var opath = [ ocfl_repo ].concat(object).join('/');

if( v ) {
v = v.substr(1);
if( ocfl_versions !== "on" ) {
v = undefined
} else {
if( v ) {
v = v.substr(1);
}
}
var vpath = version(req, ocfl_files + '/' + opath, content, v);
if( vpath ) {
Expand Down

0 comments on commit 5cb9bcd

Please sign in to comment.