Skip to content

Commit

Permalink
show information box for degraded images
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Aug 26, 2015
1 parent 662cec3 commit e99a4ce
Show file tree
Hide file tree
Showing 55 changed files with 239 additions and 185 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Inspired by https://github.com/DigitalInnovation/mns-digital-blog/blob/master/.travis.yml
language: node_js
node_js:
- '0.12.7'
Expand All @@ -17,4 +16,6 @@ before_script:
script:
- grunt build
- grunt serve &
- grunt test
- grunt test
notifications:
slack: universalviewer:0hPpv56Z7ber0j0C6KdLwFFW
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Features:
- [OpenSeadragon](https://openseadragon.github.io/) image zooming using the [IIIF image API](http://iiif.io/api/image/2.0/).
- YouTube-style embedding with deep links to specific pages/zoom regions.
- [Themable](https://stackedit.io/viewer#!provider=gist&gistId=5411c4576c2ec7387bba&filename=uv-theming-tutorial.md), fork the [UV theme](https://github.com/UniversalViewer/uv-en-GB-theme) on github to create your own.
- Highly [configurable](https://github.com/UniversalViewer/universalviewer/wiki/Configuration) and [extensible](https://stackedit.io/viewer#!provider=gist&gistId=f2067315480bcd385630&filename=uv-extensions-tutorial.md).
- Highly [configurable](https://github.com/UniversalViewer/universalviewer/wiki/Configuration) and [extensible](http://universalviewer.gitbooks.io/custom-extensions/content/).
- Supports "IxIF" out of the box, allowing [audio](http://universalviewer.azurewebsites.net/?manifest=http://wellcomelibrary.org/iiif/b17307922/manifest), [video](http://universalviewer.azurewebsites.net/?manifest=http://wellcomelibrary.org/iiif/b16659090/manifest), and [pdf](http://universalviewer.azurewebsites.net/?manifest=http://wellcomelibrary.org/iiif/b17502792/manifest) viewing experiences.
- Supports search and autocomplete service integration with overlayed search results.
- Internationalised UI using [transifex.com](https://www.transifex.com/) (currently supports English and Welsh. Volunteers for more translations gratefully accepted!)
Expand Down
34 changes: 13 additions & 21 deletions src/BootstrapParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Params = require("./Params");

class BootstrapParams {
canvasIndex: number;
collectionIndex: number;
config: string;
domain: string;
embedDomain: string;
Expand All @@ -16,7 +17,7 @@ class BootstrapParams {
locales: any[];
manifestIndex: number;
manifestUri: string;
paramMap: string[] = ['mi', 'si', 'ci', 'z', 'r'];
paramMap: string[] = ['c', 'm', 's', 'cv', 'z', 'r'];
sequenceIndex: number;

constructor() {
Expand All @@ -33,9 +34,10 @@ class BootstrapParams {
this.manifestUri = Utils.Urls.GetQuerystringParameter('manifestUri');
this.setLocale(Utils.Urls.GetQuerystringParameter('locale'));

this.manifestIndex = this.getManifestIndexParam();
this.sequenceIndex = this.getSequenceIndexParam();
this.canvasIndex = this.getCanvasIndexParam();
this.collectionIndex = this.getParam(Params.collectionIndex);
this.manifestIndex = this.getParam(Params.manifestIndex);
this.sequenceIndex = this.getParam(Params.sequenceIndex);
this.canvasIndex = this.getParam(Params.canvasIndex);
}

// parse string 'en-GB' or 'en-GB:English,cy-GB:Welsh' into array
Expand All @@ -59,28 +61,18 @@ class BootstrapParams {
return this.localeName;
}

getManifestIndexParam(): number {
// if the hash param is available and is first load
if (this.isHomeDomain && !this.isReload){
return parseInt(Utils.Urls.GetHashParameter(this.paramMap[Params.manifestIndex], parent.document)) || 0;
getParam(param: Params): any {
if (this.hashParamsAvailable()){
// get param from parent document
return parseInt(Utils.Urls.GetHashParameter(this.paramMap[param], parent.document)) || 0;
}

// get param from iframe querystring
return parseInt(Utils.Urls.GetHashParameter(this.paramMap[Params.manifestIndex])) || 0;
return parseInt(Utils.Urls.GetHashParameter(this.paramMap[param])) || 0;
}

getSequenceIndexParam(): number {
// if the hash param is available and is first load
if (this.isHomeDomain && !this.isReload){
return parseInt(Utils.Urls.GetHashParameter(this.paramMap[Params.sequenceIndex], parent.document)) || 0;
}

// get param from iframe querystring
return parseInt(Utils.Urls.GetHashParameter(this.paramMap[Params.sequenceIndex])) || 0;
}

getCanvasIndexParam(): number {
return parseInt(Utils.Urls.GetHashParameter(this.paramMap[Params.canvasIndex], parent.document)) || 0;
hashParamsAvailable(): boolean {
return (this.isHomeDomain && !this.isReload);
}
}

Expand Down
63 changes: 39 additions & 24 deletions src/Bootstrapper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BaseCommands = require("./modules/uv-shared-module/BaseCommands");
import BootstrapParams = require("BootstrapParams");
import IExtension = require("./modules/uv-shared-module/IExtension");

Expand All @@ -9,22 +10,22 @@ class Bootstrapper{
extension: IExtension;
extensions: IExtension[];
iiifResource: Manifesto.IIIIFResource;
isFullScreen: boolean = false; // persist full screen between reloads
isFullScreen: boolean = false;
manifest: Manifesto.IManifest;
params: BootstrapParams;
socket: any; // maintain the same socket between reloads
socket: any;

constructor(extensions: any) {
this.extensions = extensions;
}

bootStrap(params?: BootstrapParams): void {
var that = this;

that.params = new BootstrapParams();
this.params = new BootstrapParams();

// merge new params
if (params){
that.params = $.extend(true, that.params, params);
this.params = $.extend(true, this.params, params);
}

// empty app div
Expand All @@ -38,21 +39,21 @@ class Bootstrapper{

jQuery.support.cors = true;

that.loadManifest();
this.loadIIIFResource();
}

isCORSEnabled(): boolean {
// No jsonp setting? Then use autodetection. Otherwise, use explicit setting.
return (null === this.params.jsonp) ? Modernizr.cors : !this.params.jsonp;
}

loadManifest(): void{
loadIIIFResource(): void{
var that = this;

if (this.isCORSEnabled()){
$.getJSON(that.params.manifestUri, (manifest) => {
that.parseManifest(manifest);
this.determineExtension();
$.getJSON(that.params.manifestUri, (r) => {
this.iiifResource = that.parseIIIFResource(JSON.stringify(r));
this.loadResource();
});
} else {
// use jsonp
Expand All @@ -66,29 +67,31 @@ class Bootstrapper{

$.ajax(settings);

window.manifestCallback = (manifest: any) => {
that.parseManifest(manifest);
this.determineExtension();
window.manifestCallback = (r: any) => {
this.iiifResource = that.parseIIIFResource(JSON.stringify(r));
this.loadResource();
};
}
}

parseManifest(data: any): void {
this.iiifResource = manifesto.create(JSON.stringify(data),
parseIIIFResource(data: string): Manifesto.IIIIFResource {
return manifesto.create(data,
<Manifesto.IManifestoOptions>{
locale: this.params.localeName
});
}

determineExtension(): void {
loadResource(): void {

var manifest: Manifesto.IManifest;
var sequence: Manifesto.ISequence;
var canvas: Manifesto.ICanvas;
var extension: IExtension;

if (this.iiifResource.getIIIFResourceType().toString() === manifesto.IIIFResourceType.collection().toString()){
manifest = (<Manifesto.ICollection>this.iiifResource).getManifestByIndex(this.params.manifestIndex);
if ((<Manifesto.ICollection>this.iiifResource).collections && (<Manifesto.ICollection>this.iiifResource).collections.length){
var collection = (<Manifesto.ICollection>this.iiifResource).collections[this.params.collectionIndex];
manifest = collection.getManifestByIndex(this.params.manifestIndex);
} else {
manifest = (<Manifesto.ICollection>this.iiifResource).getManifestByIndex(this.params.manifestIndex);
}
} else {
manifest = <Manifesto.IManifest>this.iiifResource;
}
Expand All @@ -98,7 +101,20 @@ class Bootstrapper{
return;
}

sequence = manifest.getSequenceByIndex(this.params.sequenceIndex);
manifest.load().then((m: Manifesto.IManifest) => {
this.manifestLoaded(m);
});
}

manifestLoaded(manifest: Manifesto.IManifest): void {

this.manifest = manifest;

var sequence: Manifesto.ISequence;
var canvas: Manifesto.ICanvas;
var extension: IExtension;

sequence = this.manifest.getSequenceByIndex(this.params.sequenceIndex);

if (!sequence){
this.notFound();
Expand All @@ -119,7 +135,7 @@ class Bootstrapper{

// if there isn't an extension for the canvasType, try the rendering
if (!extension){
var renderings: Manifesto.IRendering[] = manifest.getRenderings(sequence);
var renderings: Manifesto.IRendering[] = this.manifest.getRenderings(sequence);
extension = this.extensions[renderings[0].toString()];
}

Expand All @@ -134,7 +150,7 @@ class Bootstrapper{

notFound(): void{
try{
parent.$(parent.document).trigger("onNotFound");
parent.$(parent.document).trigger(BaseCommands.NOT_FOUND);
return;
} catch (e) {}
}
Expand Down Expand Up @@ -202,7 +218,6 @@ class Bootstrapper{
this.config = config;

var provider = new extension.provider(this);
provider.load();

this.extension = new extension.type(this);
this.extension.name = extension.name;
Expand Down
1 change: 1 addition & 0 deletions src/Params.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// todo: zoom and rotation are not generic
enum Params {
collectionIndex,
manifestIndex,
sequenceIndex,
canvasIndex,
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/uv-mediaelement-extension/Extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BaseCommands = require("../../modules/uv-shared-module/Commands");
import BaseCommands = require("../../modules/uv-shared-module/BaseCommands");
import BaseExtension = require("../../modules/uv-shared-module/BaseExtension");
import BaseProvider = require("../../modules/uv-shared-module/BaseProvider");
import BootStrapper = require("../../Bootstrapper");
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/uv-mediaelement-extension/l10n/cy-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"localisation": {
"label": "Cymraeg"
},
"content": {
"degradedResource": "This media is degraded."
},
"modules": {
"dialogue": {
"content": {
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/uv-mediaelement-extension/l10n/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"localisation": {
"label": "English (GB)"
},
"content": {
"degradedResource": "This media is degraded."
},
"modules": {
"dialogue": {
"content": {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/uv-pdf-extension/Extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BaseCommands = require("../../modules/uv-shared-module/Commands");
import BaseCommands = require("../../modules/uv-shared-module/BaseCommands");
import BaseExtension = require("../../modules/uv-shared-module/BaseExtension");
import BaseProvider = require("../../modules/uv-shared-module/BaseProvider");
import BootStrapper = require("../../Bootstrapper");
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/uv-pdf-extension/l10n/cy-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"localisation": {
"label": "Cymraeg"
},
"content": {
"degradedResource": "This pdf is degraded."
},
"modules": {
"dialogue": {
"content": {
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/uv-pdf-extension/l10n/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"localisation": {
"label": "English (GB)"
},
"content": {
"degradedResource": "This pdf is degraded."
},
"modules": {
"dialogue": {
"content": {
Expand Down
8 changes: 4 additions & 4 deletions src/extensions/uv-pdf-extension/lib/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4703,27 +4703,27 @@ var WorkerTransport = (function WorkerTransportClosure() {
return this.passwordCallback(updatePassword,
PasswordResponses.NEED_PASSWORD);
}
this.workerReadyPromise.reject(data.exception.message, data.exception);
this.workerReadyPromise.reject(data.exception.information, data.exception);
}, this);

messageHandler.on('IncorrectPassword', function transportBadPass(data) {
if (this.passwordCallback) {
return this.passwordCallback(updatePassword,
PasswordResponses.INCORRECT_PASSWORD);
}
this.workerReadyPromise.reject(data.exception.message, data.exception);
this.workerReadyPromise.reject(data.exception.information, data.exception);
}, this);

messageHandler.on('InvalidPDF', function transportInvalidPDF(data) {
this.workerReadyPromise.reject(data.exception.name, data.exception);
}, this);

messageHandler.on('MissingPDF', function transportMissingPDF(data) {
this.workerReadyPromise.reject(data.exception.message, data.exception);
this.workerReadyPromise.reject(data.exception.information, data.exception);
}, this);

messageHandler.on('UnknownError', function transportUnknownError(data) {
this.workerReadyPromise.reject(data.exception.message, data.exception);
this.workerReadyPromise.reject(data.exception.information, data.exception);
}, this);

messageHandler.on('DataLoaded', function transportPage(data) {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/uv-pdf-extension/lib/pdf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e99a4ce

Please sign in to comment.