Next 0.9.7 #427

Merged
merged 47 commits into from Jul 11, 2012
Commits
Jump to file
+2,286 −358
Split
View
@@ -64,7 +64,8 @@
"sinon",
"setInterval", "clearInterval", "setTimeout", "clearTimeout",
"require", "Contact", "Position", "Coordinates", "Node",
- "OpenLayers"
+ "OpenLayers",
+ "cordova"
],
"node" : true,
View
@@ -35,6 +35,17 @@ To test ripple as an extension in chrome/chromium just load the chromium folder
This will describe all the available commands for building and running the tests
+## Running as a Chrome Extension
+
+- go to the extension management page (chrome://chrome/extensions/) in chrome.
+- Ensure that you have selected the developer mode checkbox
+- click the Load Unpacked extension button
+- select the chromium or chromestore folders in the pkg/ folder.
+
+NOTE: for development you should be fine to just build with jake and refresh your browser. If
+you end up editing anything in the ext folder you will need to refresh the extension from
+the extension management page.
+
## Running Inside Other Web Browsers
Ripple is (by-design) browser agnostic, and is able to run inside any web browser (with disabled web security).
@@ -45,6 +56,8 @@ To get it running inside Chrome you should start it with these [command line](ht
--disable-web-security
--user-data-dir=/path/to/dummy/profile
+This has only really be tested in chrome.
+
## Code Guidelines
* 4 spaces per editor tab
View
@@ -24,27 +24,21 @@ module.exports = function () {
doc,
modules,
specs,
- openlayers,
- app = connect(
- connect.static(__dirname + "/../lib/"),
- connect.static(__dirname + "/../"),
- connect.router(function (app) {
- app.get('/', function (req, res) {
- res.writeHead(200, {
- "Cache-Control": "no-cache",
- "Content-Type": "text/html"
- });
- res.end(doc);
+ app = connect()
+ .use(connect.static(__dirname + "/../lib/"))
+ .use(connect.static(__dirname + "/../"))
+ .use('/', function (req, res) {
+ res.writeHead(200, {
+ "Cache-Control": "max-age=0",
+ "Content-Type": "text/html"
});
- })
- );
+ res.end(doc);
+ });
- //HACK: Openlayers causes weird stuff with the browser runner, so lets pop it off the list until we fix it
- openlayers = conf.thirdpartyIncludes.pop();
- if (openlayers !== "OpenLayers.js") {
- //HACK: just a safe check to make sure our hack is still valid
- console.log("HACK: we wanted to pop OpenLayers off but it looks like it wasn't the last one anymore");
- }
+ //HACK: Openlayers causes weird stuff with the browser runner, so lets remove it from the list until we fix it
+ conf.thirdpartyIncludes = conf.thirdpartyIncludes.filter(function (filename) {
+ return !filename.match(/openlayers\.js/i);
+ });
modules = pack();
@@ -24,7 +24,8 @@ module.exports = function (src, baton) {
'cp -r ' + _c.ASSETS + "images " + _c.DEPLOY + "chromestore/ &&" +
'cp -r ' + _c.ASSETS + "themes " + _c.DEPLOY + "chromestore/ &&" +
'cp ' + _c.EXT + "chromestore/manifest.json " + _c.DEPLOY + "chromestore/manifest.json &&" +
- 'cp ' + _c.EXT + "chromestore/controllers/Background.js " + _c.DEPLOY + "chromestore/controllers/Background.js";
+ 'cp ' + _c.EXT + "chromestore/controllers/Background.js " + _c.DEPLOY + "chromestore/controllers/Background.js" +
+ 'cp ' + _c.EXT + "chromestore/views/background.html " + _c.DEPLOY + "chromestore/views/background.html";
childProcess.exec(copy, function () {
var css = _c.ASSETS + "ripple.css",
View
@@ -22,7 +22,8 @@ module.exports = function (src, baton) {
var copy = 'cp -r ' + _c.EXT + "chromium " + _c.DEPLOY + " && " +
'cp -r ' + _c.ASSETS + "images " + _c.DEPLOY + "chromium/ &&" +
- 'cp -r ' + _c.ASSETS + "themes " + _c.DEPLOY + "chromium/";
+ 'cp -r ' + _c.ASSETS + "themes " + _c.DEPLOY + "chromium/" +
+ 'cp -r ' + _c.ROOT + "plugins " + _c.DEPLOY + "chromium/";
childProcess.exec(copy, function () {
var css = _c.ASSETS + "ripple.css",
View
@@ -38,7 +38,7 @@ function _lintJS(files, done) {
function _lintCSS(files, done) {
var rules = JSON.parse(fs.readFileSync(__dirname + "/../.csslintrc", "utf-8")),
- options = ["--rules=" + rules, "--format=compact"];
+ options = ["--errors=" + rules, "--format=compact", "--quiet"];
_spawn('csslint', files.concat(options), done);
}
@@ -0,0 +1,23 @@
+<!--
+ * Copyright 2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<html>
+ <head>
+ <script type="text/javascript" src="../controllers/jquery.js"></script>
+ <script type="text/javascript" src="../controllers/Background.js"></script>
+ </head>
+ <body>
+ </body>
+</html>
@@ -56,6 +56,8 @@ tinyHippos.Background = (function () {
xhr.send();
chrome.extension.onRequest.addListener(function (request, sender, sendResponse) {
+ var xhr, postData, data, plugin;
+console.log(request);
switch (request.action) {
case "isEnabled":
console.log("isEnabled? ==> " + request.tabURL);
@@ -67,16 +69,16 @@ tinyHippos.Background = (function () {
sendResponse();
break;
case "userAgent":
- console.log("user agent ==> " + userAgent);
+ console.log("user agent ==> " + request.data);
userAgent = request.data;
break;
case "version":
sendResponse(version);
break;
case "xhr":
- var xhr = new XMLHttpRequest(),
- postData = new FormData(),
- data = JSON.parse(request.data);
+ xhr = new XMLHttpRequest();
+ postData = new FormData();
+ data = JSON.parse(request.data);
console.log("xhr ==> " + data.url);
@@ -99,8 +101,29 @@ tinyHippos.Background = (function () {
}
});
break;
+ case "services":
+ console.log("services", request.data);
+ if (request.data === '"start"') {
+ plugin = document.getElementById("pluginRippleBD");
+ console.log("plugin", plugin);
+ if (plugin) {
+ console.log("return from startBD", plugin.startBD(9910));
+ sendResponse();
+ }
+ }
+ else if (request.data === '"stop"') {
+ xhr = new XMLHTTPRequest();
+ try {
+ xhr.open("GET", "http://127.0.0.1:9910/ripple/shutdown", false);
+ xhr.send();
+ }
+ catch (e) {
+ console.log(e);
+ }
+ }
+ break;
default:
- throw {name: "MethodNotImplemented", message: "Requested action is not supported!"};
+ throw {name: "MethodNotImplemented", message: "Requested action is not supported! "};
break;
};
});
@@ -212,7 +235,7 @@ tinyHippos.Background = (function () {
},
isEnabled: function (url, enabledURIs) {
- if (url.match(/enableripple=true/i)) {
+ if (url.match(/enableripple=/i)) {
_persistEnabled(url);
return true;
}
@@ -22,7 +22,8 @@
break;
case "disable":
localStorage.removeItem("tinyhippos-enabled-uri");
- uri = uri.replace(/\?enableripple\=true/, "").replace(/\&enableripple\=true/, "");
+ //HACK: ummm .... I am sorry
+ uri = uri.replace(/enableripple=[^&]*[&]?/i, "").replace(/[\?&]*$/, "");
break;
default:
@@ -1,6 +1,21 @@
+/*
+ * Copyright 2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
if (!document.getElementById("emulator-booting") && !document.getElementById("tinyhippos-injected")) {
var script = document.createElement("script");
script.id = "tinyhippos-injected";
- script.src = chrome.extension.getURL("controllers/injector.js");
+ script.innerText = 'if (window.top.require) { window.top.require("ripple/bootstrap").inject(window, document); }';
document.documentElement.appendChild(script);
}
@@ -1,9 +0,0 @@
-if (window.top.require) {
- //HACK: make this work better and handle iframes in the app!
- window.top.require('ripple/bootstrap').inject(window, document);
- window.top.onbeforeunload = function () {
- if (!window.top.tinyHipposReload) {
- return "Are you sure you want to exit Ripple?";
- }
- };
-}
@@ -2,6 +2,10 @@
"version": "",
"name": "Ripple Emulator (Beta)",
"background_page":"views/background.html",
+ "plugins": [
+ { "path": "plugins/npRippleBD.dll" },
+ { "path": "plugins/RippleBD.plugin" }
+ ],
"icons":{
"16":"images/Icon_16x16.png",
"128":"images/Icon_128x128.png",
@@ -19,5 +19,6 @@
<script type="text/javascript" src="../controllers/Background.js"></script>
</head>
<body>
+ <embed type="application/x-ripplebd" id="pluginRippleBD" hidden="true" width="0" height="0" />
</body>
</html>
View
@@ -57,6 +57,25 @@ var omgwtf = require('ripple/omgwtf'),
}
});
+ window.onbeforeunload = function () {
+ if (!window.tinyHipposReload) {
+ return "Are you sure you want to exit Ripple?";
+ }
+ };
+
+ //HACK: need to find a better way to do this since it's
+ //WebWorks specific!!!
+ window.onunload = function () {
+ var bus = require('ripple/bus');
+ bus.ajax(
+ "GET",
+ "http://127.0.0.1:9910/ripple/shutdown",
+ null,
+ null,
+ null
+ );
+ };
+
jWorkflow.order(omgwtf.initialize, omgwtf)
.andThen(appcache.initialize, appcache)
.andThen(db.initialize, db)
View
@@ -118,7 +118,7 @@ function _bootstrap() {
tinyHippos.boot(function () {
var uri = ui.registered('omnibar') ?
db.retrieve(_CURRENT_URL) || "about:blank" :
- document.documentURI.replace(/enableripple=true[&]/i, "").replace(/[\?&]$/, "");
+ document.documentURI.replace(/enableripple=[^&]*[&]?/i, "").replace(/[\?&]*$/, "");
_post(uri);
delete tinyHippos.boot;
@@ -78,12 +78,15 @@ module.exports = {
var marshal = function (obj, key) {
window[key] = win[key] = obj;
},
+ currentPlatform = platform.current(),
sandbox = {};
marshal(window.tinyHippos, "tinyHippos");
marshal(window.XMLHttpRequest, "XMLHttpRequest");
- platform.current().initialize(win);
+ if (currentPlatform.initialize) {
+ currentPlatform.initialize(win);
+ }
builder.build(platform.current().objects).into(sandbox);
utils.forEach(sandbox, marshal);
View
@@ -23,13 +23,30 @@ var _current,
spec = require('ripple/platform/spec'),
_self;
-function _checkForDeprecatedPlatforms(replacement) {
- if (!spec[_current.name] ||
- !spec[_current.name][_current.version] ||
- (spec[_current.name][_current.version] && !spec[_current.name][_current.version].objects)) {
- _current = replacement;
- db.saveObject("api-key", _current);
+function _getRequestedPlatform() {
+ var requestedPlatform = null,
+ enableRippleArg = utils.queryString().enableripple,
+ platform;
+
+ if (enableRippleArg) {
+ enableRippleArg = enableRippleArg.split('-');
+ platform = spec.get(enableRippleArg[0], enableRippleArg[1]);
+ if (platform) {
+ requestedPlatform = { name: platform.id, version: platform.version };
+ }
+ }
+
+ return requestedPlatform;
+}
+
+function _validatePlatform(platform, defaultPlatform) {
+ if (!platform ||
+ !spec[platform.name] ||
+ !spec[platform.name][platform.version] ||
+ (spec[platform.name][platform.version] && !spec[platform.name][platform.version].objects)) {
+ return defaultPlatform;
}
+ return platform;
}
function _getPlatform() {
@@ -39,20 +56,16 @@ function _getPlatform() {
_self = {
initialize: function () {
var firstAvailablePlatform = utils.map(this.getList(), function (platform) {
- return utils.map(platform, function (details, version) {
- return {name: details.id, version: version};
- })[0];
- })[0];
-
- _current = db.retrieveObject("api-key");
+ return utils.map(platform, function (details, version) {
+ return {name: details.id, version: version};
+ })[0];
+ })[0];
- if (_current) {
- _checkForDeprecatedPlatforms(firstAvailablePlatform);
- } else {
- _current = firstAvailablePlatform;
- }
+ _current = _getRequestedPlatform() || db.retrieveObject("api-key") || firstAvailablePlatform;
+ _current = _validatePlatform(_current, firstAvailablePlatform);
+ db.saveObject("api-key", _current);
- _console.prefix = _getPlatform().name;
+ _console.prefix = _current.name;
},
getList: function () {
Oops, something went wrong.