Skip to content
Snippets Groups Projects
Unverified Commit aff24731 authored by Matthias Lindinger's avatar Matthias Lindinger Committed by GitHub
Browse files

Merge branch 'develop' into minor-ui-improvement

parents edccddc5 8ea48886
No related branches found
No related tags found
No related merge requests found
module.exports = function(grunt) {
// ----------
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks("gruntify-eslint");
......@@ -185,25 +184,6 @@ module.exports = function(grunt) {
}
},
compress: {
zip: {
options: {
archive: 'build/mirador.zip'
},
files: [
{ expand: true, cwd: 'build/', src: ['mirador/**'] }
]
},
tar: {
options: {
archive: 'build/mirador.tar'
},
files: [
{ expand: true, cwd: 'build/', src: [ 'mirador/**' ] }
]
}
},
connect: {
server: {
options: {
......@@ -289,28 +269,18 @@ module.exports = function(grunt) {
});
// ----------
// Lint task
grunt.registerTask('lint', ['jshint', 'eslint'])
grunt.registerTask('lint', ['jshint', 'eslint']);
// ----------
// Build task.
// Cleans out the build folder and builds the code and images into it, checking lint.
grunt.registerTask('build', [ 'clean:build', 'git-describe', 'lint', 'less', 'concat:css', 'uglify', 'cssmin', 'copy']);
grunt.registerTask('build', [ 'clean:build', 'git-describe', 'lint', 'less', 'concat', 'uglify', 'cssmin', 'copy']);
// ----------
// Dev Build task.
// Build, but skip the time-consuming and obscurantist minification and uglification.
grunt.registerTask('dev_build', [ 'clean:build', 'git-describe', 'lint', 'less', 'concat', 'copy']);
// ----------
// Package task.
// Builds and creates the .zip and .tar files.
grunt.registerTask('package', ['build', 'compress']);
// ----------
// Publish task.
// Cleans the built files out of the release folder and copies newly built ones over.
grunt.registerTask('publish', ['package', 'clean:release', 'copy:release']);
// ----------
// Default task.
// Does a normal build.
......
......@@ -2,24 +2,26 @@
[![Stories in Ready](https://badge.waffle.io/ProjectMirador/mirador.svg?label=ready&title=Ready)](http://waffle.io/iiif/mirador)
# Mirador
![mirador banner](http://projectmirador.github.io/mirador/img/banner.jpg)
![mirador banner](https://projectmirador.github.io/mirador/img/banner.jpg)
**Mirador is a multi-repository, configurable, extensible, and easy-to-integrate viewer and annotation creation and comparison environment for IIIF resources, ranging from deep-zooming artwork, to complex manuscript objects. It provides a tiling windowed environment for comparing multiple image-based resources, synchronised structural and visual navigation of content using openSeadragon, Open Annotation compliant annotation creation and viewing on deep-zoomable canvases, metadata display, bookreading, and bookmarking.**
### [See a Demo](http://projectmirador.org/demo/)
### [Getting Started](http://projectmirador.org/docs/docs/getting-started.html)
### Run in Development
Mirador uses [node.js](http://nodejs.org/) and a build system to assemble, test, and manage the development resources. If you have never used these tools before, you may need to install them.
Mirador uses [Node.js](https://nodejs.org/) and a build system to assemble, test, and manage the development resources. If you have never used these tools before, you may need to install them.
1. Install Node, if you haven't already (available at the link above)
1. Clone the mirador repository (if you haven't already done so above)
1. On the command line, go into the mirador folder
1. Install all dependencies with `npm install`. Run `npm start'.
1. Install [Node.js](https://nodejs.org/)
2. Install the Grunt command line runner i.e. `npm install -g grunt-cli`
3. Install the Bower command line utility i.e. `npm install -g bower`
1. Clone the Mirador repository
1. Change into the Mirador directory
1. Install all dependencies with `npm install`. Run `npm start`.
### Run Tests
`npm test`
For more information, see the [Docs](http://projectmirador.org/docs/docs/getting-started.html), submit an [issue](https://github.com/projectmirador/mirador/issues), or ask on [slack](http://bit.ly/iiif-slack).
For more information, see the [Docs](http://projectmirador.org/docs/docs/getting-started.html), submit an [issue](https://github.com/projectmirador/mirador/issues), or ask on [Slack](http://bit.ly/iiif-slack).
### Project Diagnostics
[![Coverage Status](https://coveralls.io/repos/github/ProjectMirador/mirador/badge.svg?branch=master&upToDate=true)](https://coveralls.io/github/ProjectMirador/mirador?branch=master&upToDate=true)
# remove previous packages
rm -rf build/mirador*
rm -rf build dist
# build package
node_modules/.bin/grunt package
node_modules/.bin/grunt build
# mk tmp release dir
mkdir -p build/tmp/build/mirador
# unzip build
unzip build/mirador.zip -d build/tmp/build
# copy mirador build into tmp folder
cp -r build/mirador/* build/tmp/build/mirador
# add example
# add example(s)
cp examples/example.html build/tmp/build
cd build/tmp
......@@ -22,4 +22,10 @@ mv build/build.zip ../
tar -czvf build/build.tar.gz build/
mv build/build.tar.gz ../
cd -
# remove temporary files
cd .. && rm -rf tmp
# make npm dist directory
cd ..
mkdir dist
cp -r build/mirador/* dist
......@@ -2,7 +2,7 @@
rm -rf build/mirador*
# build package
node_modules/.bin/grunt package
node_modules/.bin/grunt build
# mk tmp release dir
mkdir build/tmp
......@@ -27,6 +27,7 @@ cp -R build/tmp/mirador/themes demo
# Copy over files
cp build/tmp/mirador/mirador.min.js demo
cp build/tmp/mirador/mirador.js demo
cp build/tmp/mirador/ZeroClipboard.swf demo
# Clean up extra files
......
......@@ -109,6 +109,8 @@
if (shapeArray.length > 0) {
_this.svgOverlay.restoreLastView(shapeArray);
_this.annotationsToShapesMap[annotation['@id']] = shapeArray;
} else {
console.log("ERROR couldn't find a strategy for " + annotation["@id"]);
}
} catch(e) {
console.log('ERROR OsdRegionDrawTool#render anno:', annotation, 'error:', e);
......
/*
* Edited version of https://github.com/IIIF/mirador/blob/9e3c6bbb894e044d01ad51aae1b70309939de5a9/js/src/annotations/catchEndpoint.js
* This module tries to store the annotation as is in a RDF store but some fiddeling is required. Fidles are:
*
* This module tries to store the annotation as is in a RDF store but some fiddeling is required.
* Fidles are:
* - delete annotation fails if id has a / in it so have to send sanatised ids to mirador
* - mirador requires an endpoint variable in the annotation pointing to this class.
*
......@@ -15,9 +15,6 @@
* create(oaAnnotation, returnSuccess, returnError)
* update(oaAnnotation, returnSuccess, returnError)
* deleteAnnotation(annotationID, returnSuccess, returnError) (delete is a reserved word)
* TODO:
* There is a bug in that if you create an annotation and then delete it (without moving pages) then click either the write annotation button
* or try to create a new annotation the deleted annotation re-appears. Changing pages fixes the issue as the annoation is delete from the annotation store
*
*/
(function ($){
......@@ -30,8 +27,10 @@
uri: null,
url: options.url,
dfd: null,
annotationsList: [], //OA list for Mirador use
idMapper: {} // internal list for module use to map id to URI
// OA list for Mirador use
annotationsList: [],
// internal list for module use to map id to URI
idMapper: {}
}, options);
this.init();
......@@ -60,125 +59,155 @@
this.annotationsList = []; // clear out current list
jQuery.ajax({
url: _this.url + "/search", // this.prefix+
url: _this.url + '/search', // this.prefix+
cache: false,
type: 'GET',
dataType: 'json',
headers: {
//"x-annotator-auth-token": this.token
// 'x-annotator-auth-token': this.token
},
data: {
uri: options.uri,
APIKey: _this.APIKey,
media: "image",
media: 'image',
limit: 10000
},
contentType: "application/json; charset=utf-8",
contentType: 'application/json; charset=utf-8',
success: function(data) {
if (typeof successCallback === "function") {
successCallback(data);
} else {
_this.annotationsList = data; // gmr
jQuery.each(_this.annotationsList, function(index, value) {
value.fullId = value["@id"];
value["@id"] = $.genUUID();
_this.idMapper[value["@id"]] = value.fullId;
// Swap out URI of anno to shorter ID
value.fullId = value['@id'];
value['@id'] = $.genUUID();
_this.idMapper[value['@id']] = value.fullId;
value.endpoint = _this;
// Ensure on is an array
_this.fixOn(value);
});
_this.dfd.resolve(false);
if (typeof successCallback === 'function') {
successCallback(data);
} else {
_this.dfd.resolve(true);
}
},
error: function() {
if (typeof errorCallback === "function") {
error: function(xhr, statusText, err) {
if (typeof errorCallback === 'function') {
errorCallback();
} else {
console.log("The request for annotations has caused an error for endpoint: "+ options.uri);
_this.dfd.reject();
console.log('The request for annotations has caused an error for endpoint: ' + options.uri + ' due to ' + statusText);
}
}
});
},
fixOn: function (annotation) {
var oldOn;
if (annotation && annotation.on && !jQuery.isArray(annotation.on) && annotation.on.selector && annotation.on.selector.default) {
oldOn = annotation.on;
annotation.on = [oldOn];
}
},
deleteAnnotation: function (annotationID, returnSuccess, returnError) {
var _this = this;
jQuery.ajax({
url: _this.url + "/destroy?uri=" + encodeURIComponent(_this.idMapper[annotationID]) + "&APIKey=" + _this.APIKey, // this.prefix+
url: _this.url + '/destroy?uri=' + encodeURIComponent(_this.idMapper[annotationID]) + '&APIKey=' + _this.APIKey, // this.prefix+
type: 'DELETE',
dataType: 'json',
headers: {
//"x-annotator-auth-token": this.token
// 'x-annotator-auth-token': this.token
},
data: {
uri: annotationID,
},
contentType: "application/json; charset=utf-8",
contentType: 'application/json; charset=utf-8',
success: function(data) {
if (typeof returnSuccess === 'function') {
returnSuccess();
}
},
error: function() {
error: function(xhr, statusText, err) {
if (typeof returnError === 'function') {
returnError();
} else {
console.log('Failed to delete annotation ' + annotationID + ' due to ' + statusText);
}
}
});
},
update: function (oaAnnotation, returnSuccess, returnError) {
var annotation = oaAnnotation,
_this = this;
var annotation = oaAnnotation;
var _this = this;
// slashes don't work in JQuery.find which is used for delete
// so need to switch http:// id to full id and back again for delete.
shortId = annotation["@id"];
annotation["@id"] = annotation.fullId;
annotationID = annotation.fullId;//annotation["@id"];
var shortId = annotation['@id'];
var annotationID = annotation.fullId;// annotation['@id'];
annotation['@id'] = annotation.fullId;
delete annotation.fullId;
delete annotation.endpoint;
jQuery.ajax({
url: _this.url + "/update/"+encodeURIComponent(annotationID) + "?APIKey=" + _this.APIKey, //this.prefix+
url: _this.url + '/update/' + encodeURIComponent(annotationID) + '?APIKey=' + _this.APIKey, // this.prefix+
type: 'POST',
dataType: 'json',
headers: {
//"x-annotator-auth-token": this.token
// 'x-annotator-auth-token': this.token
},
data: JSON.stringify(annotation),
contentType: "application/json; charset=utf-8",
contentType: 'application/json; charset=utf-8',
success: function(data) {
/* this returned data doesn't seem to be used anywhere */
returnSuccess();
_this.fixOn(data);
if (typeof returnSuccess === 'function') {
returnSuccess(data);
}
},
error: function() {
error: function(xhr, statusText, err) {
if (typeof returnError === 'function') {
returnError();
} else {
console.log('Failed to update annotation: ' + oaAnnotation['@id'] + ' due to ' + statusText);
}
}
});
// this is what updates the viewer
annotation.endpoint = _this;
annotation.fullId = annotation["@id"];
annotation["@id"] = shortId;
annotation.fullId = annotation['@id'];
annotation['@id'] = shortId;
},
create: function (oaAnnotation, returnSuccess, returnError) {
var annotation = oaAnnotation,
_this = this;
var annotation = oaAnnotation;
var _this = this;
jQuery.ajax({
url: _this.url + "/create?APIKey=" + _this.APIKey, //this.prefix+
url: _this.url + '/create?APIKey=' + _this.APIKey, // this.prefix+
type: 'POST',
dataType: 'json',
headers: {
//"x-annotator-auth-token": this.token
// 'x-annotator-auth-token': this.token
},
data: JSON.stringify(annotation),
contentType: "application/json; charset=utf-8",
contentType: 'application/json; charset=utf-8',
success: function(data) {
data.fullId = data["@id"];
data["@id"] = $.genUUID();
data.fullId = data['@id'];
data['@id'] = $.genUUID();
data.endpoint = _this;
_this.idMapper[data["@id"]] = data.fullId;
_this.idMapper[data['@id']] = data.fullId;
_this.fixOn(data);
if (typeof returnSuccess === 'function') {
returnSuccess(data);
}
},
error: function() {
error: function(xhr, statusText, err) {
if (typeof returnError === 'function') {
returnError();
} else {
console.log('Failed to create annotation: ' + oaAnnotation['@id'] + ' due to ' + statusText);
}
}
});
},
......
{
"name": "mirador",
"version": "2.5.1",
"version": "2.6.1",
"description": "Multi-window image viewer, a web-based tool to support researcher goals",
"files": ["dist/*"],
"repository": {
"type": "git",
"url": "https://github.com/ProjectMirador/mirador"
......@@ -52,6 +53,7 @@
"test": "./node_modules/.bin/karma start ./karma.conf.js",
"travis": "./node_modules/.bin/grunt ci --verbose --force & npm run test",
"update_demo": "./bin/update_demo.sh",
"release": "./bin/create_release.sh",
"lint": "./node_modules/.bin/eslint js/src"
},
"dependencies": {
......
......@@ -75,7 +75,7 @@ describe('SimpleASEndpoint', function() {
subject.search({uri: "http://sas.example.net"});
expect(successCallback).not.toHaveBeenCalled();
expect(errorCallback).not.toHaveBeenCalled();
expect(console.log).toHaveBeenCalledWith("The request for annotations has caused an error for endpoint: http://sas.example.net");
expect(console.log).toHaveBeenCalledWith("The request for annotations has caused an error for endpoint: http://sas.example.net due to undefined");
});
it('should run callback on failure if provided', function() {
ajaxSuccess = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment