Skip to content

Commit

Permalink
Merge pull request #21 from openseadragon/webextension
Browse files Browse the repository at this point in the history
  • Loading branch information
avandecreme committed Aug 13, 2016
2 parents e9c9670 + 858f86a commit 0754992
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 356 deletions.
62 changes: 12 additions & 50 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-compress");
grunt.loadNpmTasks("grunt-jpm");
grunt.loadNpmTasks("grunt-crx");

var releaseRoot = "../openseadragon.github.com/openseadragonizer/";

Expand All @@ -43,8 +41,7 @@ module.exports = function (grunt) {
grunt.initConfig({
clean: {
build: ["build"],
chromium: ["build/chromium"],
firefox: ["build/firefox"],
webextension: ["build/webextension"],
release: {
src: [releaseRoot],
options: {
Expand All @@ -53,32 +50,17 @@ module.exports = function (grunt) {
}
},
watch: {
files: ["Gruntfile.js", "chromium/*", "firefox/*", "common/*"],
files: ["Gruntfile.js", "webextension/*", "common/*"],
tasks: "watchTask"
},
jpm: {
options: {
src: "build/firefox",
xpi: "build"
}
},
crx: {
crx: {
"src": "build/chromium/**/*",
"dest": "build",
"options": {
"privateKey": "../openseadragonizer.pem"
}
}
},
compress: {
chromium: {
webextension: {
options: {
archive: "build/chromium.zip"
archive: "build/webextension.zip"
},
files: [{
expand: true,
cwd: "build/chromium",
cwd: "build/webextension",
src: ["**/*"],
dest: ""
}
Expand All @@ -89,16 +71,8 @@ module.exports = function (grunt) {

// ----------
// Watch task.
// Called from the watch feature; does a full build or a particular browser build,
// depending on whether you used --browsername on the command line.
grunt.registerTask("watchTask", function () {
if (grunt.option('chromium')) {
grunt.task.run("build:chromium");
} else if (grunt.option('firefox')) {
grunt.task.run("build:firefox");
} else {
grunt.task.run("build");
}
});

function copyCommonDir(destination) {
Expand All @@ -113,26 +87,14 @@ module.exports = function (grunt) {
}

// ----------
// Chromium build task.
grunt.registerTask("build:chromium", function () {
copyCommonDir("build/chromium/");
grunt.file.recurse("chromium", function (abspath, rootdir, subdir, filename) {
subdir = subdir ? subdir + "/" : "";
grunt.file.copy(abspath, "build/chromium/" + subdir + filename);
});
grunt.task.run("compress:chromium");
});

// ----------
// Firefox build task.
grunt.registerTask("build:firefox", function () {
copyCommonDir("build/firefox/data/");
grunt.file.recurse("firefox", function (abspath, rootdir, subdir, filename) {
// WebExtension build task.
grunt.registerTask("build:webextension", function () {
copyCommonDir("build/webextension/");
grunt.file.recurse("webextension", function (abspath, rootdir, subdir, filename) {
subdir = subdir ? subdir + "/" : "";
grunt.file.copy(abspath, "build/firefox/" + subdir + filename);
grunt.file.copy(abspath, "build/webextension/" + subdir + filename);
});
grunt.file.copy("build/firefox/data/logo48.png", "build/firefox/icon.png");
grunt.task.run("jpm:xpi");
grunt.task.run("compress:webextension");
});

// ----------
Expand All @@ -143,7 +105,7 @@ module.exports = function (grunt) {

// ----------
// Full build task.
grunt.registerTask("build", ["clean", "build:chromium", "build:firefox"]);
grunt.registerTask("build", ["clean", "build:webextension"]);

// ----------
// Publish task.
Expand Down
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,14 @@ If you want Grunt to watch your source files and rebuild every time you change o

1. Go to your Chrome settings and then extensions.
1. Turn on the "Developer mode" checkbox.
1. Choose "Load unpacked extension" and select build/chromium from this repository.
1. Choose "Load unpacked extension" and select build/webextension from this repository.

### Testing in Firefox

There are two ways to load the extension for testing in Firefox:
1. Type `about:debugging` in the address bar.
1. Click on "Load Temporary Add-on" and select build/webextension from this repository.

#### Using jpm
### Publishing the standalone web site

1. Install [jpm](https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm) globally with `npm install jpm -g`.
1. Run `jpm run` inside build/firefox

It will start a fresh instance of Firefox with the extension installed.

#### Loading the xpi

1. Go to the extensions list (about:addons).
1. Drag and drop the build/@openseadragonizer-[version].xpi file.
1. Run `grunt publish`.
1. Commit and push the `../openseadragon.github.com` website.
1 change: 0 additions & 1 deletion common/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@

<script src='openseadragon/openseadragon.min.js'></script>
<script src="index.js"></script>
<script src="platform-specific.js"></script>
</body>
</html>
48 changes: 23 additions & 25 deletions common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,32 @@
location.href = '?img=' + urlElt.value;
};

window.OpenSeadragonizer = {
open: function (url) {
popupElt.style.display = "none";
init();

if (!url) {
var imgUrlParameter = OpenSeadragon.getUrlParameter("img");
if (!imgUrlParameter) {
popupElt.style.display = "block";
return;
}
url = OpenSeadragon.getUrlParameter("encoded") ?
decodeURIComponent(imgUrlParameter) : imgUrlParameter;
}
function init() {
popupElt.style.display = "none";

var options = {
src: url,
container: document.getElementById("loader"),
crossOrigin: 'Anonymous'
};
loadImage(options, onImageLoaded, function (event) {
loaderElt.removeChild(event.image);
// We retry without CORS
delete options.crossOrigin;
loadImage(options, onImageLoaded, onError);
});
document.title = "OpenSeadragon " + url;
var imgUrlParameter = OpenSeadragon.getUrlParameter("img");
if (!imgUrlParameter) {
popupElt.style.display = "block";
return;
}
};
var url = OpenSeadragon.getUrlParameter("encoded") ?
decodeURIComponent(imgUrlParameter) : imgUrlParameter;

var options = {
src: url,
container: document.getElementById("loader"),
crossOrigin: 'Anonymous'
};
loadImage(options, onImageLoaded, function (event) {
loaderElt.removeChild(event.image);
// We retry without CORS
delete options.crossOrigin;
loadImage(options, onImageLoaded, onError);
});
document.title = "OpenSeadragon " + url;
}

function loadImage(options, successCallback, errorCallback) {
var image = new Image();
Expand Down
5 changes: 5 additions & 0 deletions common/openseadragon/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
OPENSEADRAGON CHANGELOG
=======================

2.2.1:

* Fixed problems with zoom/pan constraints with certain extreme settings (#965)
* Fixed an issue causing the browser to crash on iOS (#966)

2.2.0:

* BREAKING CHANGE: Viewport.homeBounds, Viewport.contentSize, Viewport.contentAspectX and
Expand Down
Loading

0 comments on commit 0754992

Please sign in to comment.