Skip to content

Commit

Permalink
Improve the universal viewer deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie Allinson committed Apr 26, 2019
1 parent f5c25cf commit 0e02c4a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/helpers/hyrax/iiif_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def iiif_viewer_display_partial(work_presenter)
end

def universal_viewer_base_url
"#{request&.base_url}/uv.html"
"#{request&.base_url}/uv/uv.html"
end

def universal_viewer_config_url
"#{request&.base_url}/uv_config.json"
"#{request&.base_url}/uv/uv-config.json"
end
end
end
4 changes: 2 additions & 2 deletions lib/generators/hyrax/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def riiif_image_server

def universalviewer_files
copy_file 'package.json', 'package.json'
copy_file 'uv.html', 'public/uv.html'
copy_file 'uv_config.json', 'public/uv_config.json'
copy_file 'uv.html', 'config/uv/uv.html'
copy_file 'uv-config.json', 'config/uv/uv-config.json'
end

# Blacklight::Controller will by default add an after_action filter to discard all flash messages on xhr requests.
Expand Down
14 changes: 10 additions & 4 deletions lib/generators/hyrax/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
"name": "hyrax",
"private": true,
"repository": "git@github.com:samvera/hyrax.git",
"scripts": {
"install-uv": "yarn install --modules-folder ./public/uv"
},
"dependencies": {
"universalviewer": "^3.0.16"
"universalviewer": "^3.0.16"
},
"scripts": {
"preinstall": "rm -rf ./public/uv",
"postinstall": "yarn run uv-install && yarn run uv-config",
"uv-install": "shx cp -r ./node_modules/universalviewer/uv ./public/",
"uv-config": "shx cp ./config/uv/uv.html ./public/uv/uv.html & shx cp ./config/uv/uv-config.json ./public/uv/"
},
"devDependencies": {
"shx": "^0.3.2"
}
}
10 changes: 5 additions & 5 deletions lib/generators/hyrax/templates/uv.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="uv/universalviewer/uv/uv.css">
<link rel="stylesheet" type="text/css" href="uv.css">
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script type="text/javascript" src="uv/universalviewer/uv/lib/offline.js"></script>
<script type="text/javascript" src="uv/universalviewer/uv/helpers.js"></script>
<script type="text/javascript" src="lib/offline.js"></script>
<script type="text/javascript" src="helpers.js"></script>
<style>
body {
margin: 0;
Expand Down Expand Up @@ -42,7 +42,7 @@
}

uv = createUV('#uv', {
root: './uv/universalviewer/uv',
root: '.',
iiifResourceUri: urlDataProvider.get('manifest'),
configUri: urlDataProvider.get('config'),
collectionIndex: Number(urlDataProvider.get('c', 0)),
Expand Down Expand Up @@ -82,6 +82,6 @@
});

</script>
<script type="text/javascript" src="uv/universalviewer/uv/uv.js"></script>
<script type="text/javascript" src="uv.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions spec/features/work_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@

# IIIF manifest does not include locale query param
expect(find('div.viewer-wrapper iframe')['src']).to eq(
"http://www.example.com/uv.html#?manifest=" \
"http://www.example.com/uv/uv.html#?manifest=" \
"http://www.example.com/concern/generic_works/#{work.id}/manifest&" \
"config=http://www.example.com/uv_config.json"
"config=http://www.example.com/uv/uv-config.json"
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/hyrax/iiif_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
subject { helper.universal_viewer_base_url }

it 'defaults to universal viewer base path' do
expect(subject).to eq "http://test.host/uv.html"
expect(subject).to eq "http://test.host/uv/uv.html"
end
end

describe '#universal_viewer_config_url' do
subject { helper.universal_viewer_config_url }

it 'defaults to universal viewer base path' do
expect(subject).to eq "http://test.host/uv_config.json"
expect(subject).to eq "http://test.host/uv/uv-config.json"
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def configure_action_cable_to_use_redis
end

def install_universal_viewer
system './bin/yarn run install-uv'
system './bin/yarn install'
end

end

0 comments on commit 0e02c4a

Please sign in to comment.