Skip to content

Commit

Permalink
Merge pull request #10 from scientist-softserv/add-uv-package
Browse files Browse the repository at this point in the history
Bring over package.json from ngao
  • Loading branch information
kirkkwang authored Aug 21, 2024
2 parents d1ca704 + 8ee4421 commit 9caea0c
Show file tree
Hide file tree
Showing 6 changed files with 4,373 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ capybara-*.html
/db/*.sqlite3-journal
/db/*.sqlite3-[0-9]*
/public/system
/public/uv
/coverage/
/spec/tmp
*.orig
Expand Down
2 changes: 1 addition & 1 deletion app/components/universal_viewer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>

<iframe
src="<%= uv_host %>/uv/uv.html#?manifest=<%= manifest_url %>&config=<%= uv_config_host %>/uv/uv_config.json&m=0&cv=0"
src="<%= uv_host %>/uv/uv.html#?manifest=<%= manifest_url %>&config=<%= uv_config_host %>/uv/uv-config.json&m=0&cv=0"
title="Digital content viewer" width="900" height="640" allowfullscreen frameborder="0">
</iframe>

Expand Down
13 changes: 13 additions & 0 deletions config/uv/uv-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"modules":
{
"footerPanel":
{
"options":
{
"shareEnabled": true,
"downloadEnabled": false
}
}
}
}
87 changes: 87 additions & 0 deletions config/uv/uv.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

<!--
This is what the embed iframe src links to. It doesn't need to communicate with the parent page, only fill the available space and look for #? parameters
-->

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link rel="icon" href="favicon.ico">
<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="lib/offline.js"></script>
<script type="text/javascript" src="helpers.js"></script>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
<script type="text/javascript">
window.addEventListener('uvLoaded', function(e) {
urlDataProvider = new UV.URLDataProvider(true);
var formattedLocales;
var locales = urlDataProvider.get('locales', '');

if (locales) {
var names = locales.split(',');
formattedLocales = [];

for (var i in names) {
var nameparts = String(names[i]).split(':');
formattedLocales[i] = {name: nameparts[0], label: nameparts[1]};
}

} else {
formattedLocales = [
{
name: 'en-GB'
}
]
}

uv = createUV('#uv', {
root: '.',
iiifResourceUri: urlDataProvider.get('manifest'),
configUri: urlDataProvider.get('config'),
collectionIndex: Number(urlDataProvider.get('c', 0)),
manifestIndex: Number(urlDataProvider.get('m', 0)),
sequenceIndex: Number(urlDataProvider.get('s', 0)),
canvasIndex: Number(urlDataProvider.get('cv', 0)),
rangeId: urlDataProvider.get('rid', 0),
rotation: Number(urlDataProvider.get('r', 0)),
xywh: urlDataProvider.get('xywh', ''),
embedded: true,
locales: formattedLocales
}, urlDataProvider);
}, false);
</script>
</head>
<body>

<div id="uv" class="uv"></div>

<script>
$(function() {

var $UV = $('#uv');

function resize() {
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
$UV.width(windowWidth);
$UV.height(windowHeight);
}

$(window).on('resize' ,function() {
resize();
});

resize();
});

</script>
<script type="text/javascript" src="uv.js"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "archives_online",
"private": true,
"dependencies": {
"@babel/core": "^7.12.13",
"@babel/plugin-external-helpers": "^7.12.13",
"@babel/plugin-transform-modules-umd": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"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/dist ./public/uv",
"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"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
Loading

0 comments on commit 9caea0c

Please sign in to comment.