You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ripple.apache.org by gt...@apache.org on 2013/03/11 16:11:05 UTC

[31/50] [abbrv] git commit: The `pkg/web` build target is no longer warranted.

The `pkg/web` build target is no longer warranted.

This build target is no longer (primarily) used, and now that there is a
hosted build target, which can function without the chrome extension
(i.e. standalone) this is no longer needed, and should be removed.

This also cleans up some hacky (complexity inducing) code (such as the
omnibar checks) that has never felt right.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/716a30a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/716a30a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/716a30a3

Branch: refs/heads/master
Commit: 716a30a3393789378b0f3954fa22615842fa793a
Parents: 237a12e
Author: Brent Lintner <br...@gmail.com>
Authored: Sun Dec 16 00:01:50 2012 -0500
Committer: Brent Lintner <br...@gmail.com>
Committed: Thu Feb 7 12:03:32 2013 -0500

----------------------------------------------------------------------
 HACKING.md                       |    6 --
 assets/client/index.html         |    2 +-
 build/build.js                   |    7 +--
 build/targets/web.js             |   78 ----------------------
 lib/client/bootstrap.js          |   41 +-----------
 lib/client/ui/plugins/omnibar.js |  116 ---------------------------------
 lib/client/utils.js              |   27 --------
 lib/client/xhr.js                |    3 +-
 targets/web/cache.manifest       |    5 --
 test/unit/client/utils.js        |   67 ++-----------------
 10 files changed, 11 insertions(+), 341 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/HACKING.md
----------------------------------------------------------------------
diff --git a/HACKING.md b/HACKING.md
index 68ba743..c6673dc 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -166,12 +166,6 @@ Currently, there is support for the Chrome extension framework. You can install
 
 You can also (as an alternative) use the NPM package to host your app (remotely _or_ locally), as it can inject the client UI (i.e. what the Chrome extension does) without needing the Extension. (See the NPM and Hosted Injection sections below for details).
 
-### Standalone UI
-
-This was created when there was need to have the ability to run a "standalone" version that did not require an extension framework.
-
-Essentially, it has its own navigation bar, and can be loaded as a static web page (see README and `pkg/web`).
-
 ### NPM Package
 
 You can package the `cli` and `server` components into an NPM package, and also allows you to do other things, such as inject ripple without the extension (using the `hosted` build target).

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/assets/client/index.html
----------------------------------------------------------------------
diff --git a/assets/client/index.html b/assets/client/index.html
index 23fff20..47ade52 100644
--- a/assets/client/index.html
+++ b/assets/client/index.html
@@ -14,7 +14,7 @@
  * limitations under the License.
 -->
 <!DOCTYPE html>
-<html manifest="cache.manifest">
+<html>
     <head>
         <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
         <link href="#URL_PREFIX#ripple.css" type="text/css" rel="stylesheet" />

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/build/build.js
----------------------------------------------------------------------
diff --git a/build/build.js b/build/build.js
index 19789cc..dfd2943 100644
--- a/build/build.js
+++ b/build/build.js
@@ -22,8 +22,7 @@ var fs = require('fs'),
     compress = require('./compress'),
     chromeExt = require('./targets/chrome.extension'),
     rimChromeExt = require('./targets/rim.chrome.extension'),
-    hosted = require('./targets/hosted'),
-    web = require('./targets/web');
+    hosted = require('./targets/hosted');
 
 function _done(error) {
     if (error) {
@@ -54,9 +53,6 @@ module.exports = _handle(function (ext, opts) {
                          .andThen(pack);
 
     switch (ext) {
-    case 'web':
-        build.andThen(web);
-        break;
     case 'chrome.extension':
         build.andThen(chromeExt);
         break;
@@ -69,7 +65,6 @@ module.exports = _handle(function (ext, opts) {
     default:
         build.andThen(chromeExt)
              .andThen(rimChromeExt)
-             .andThen(web)
              .andThen(hosted);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/build/targets/web.js
----------------------------------------------------------------------
diff --git a/build/targets/web.js b/build/targets/web.js
deleted file mode 100644
index 1496ef4..0000000
--- a/build/targets/web.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- *  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.
- */
-var childProcess = require('child_process'),
-    fs = require('fs'),
-    path = require('path'),
-    utils = require('./../utils'),
-    _c = require('./../conf');
-
-function copy(from, callback) {
-    var cmd = 'cp -r ' + from + ' ' + _c.DEPLOY + "web";
-    childProcess.exec(cmd, callback);
-}
-
-function _cache() {
-    var files = [],
-        cache = "";
-
-    utils.collect(_c.DEPLOY, files, function (path) {
-        if (path.indexOf("/web/") > 0 && path.indexOf("/.") === -1) {
-            return true;
-        }
-        return false;
-    });
-
-    files.forEach(function (file) {
-        var prefix = path.normalize(_c.DEPLOY) + "web/",
-            parts = file.split(prefix);
-        if (parts && parts.length > 1) {
-            cache += parts[1] + "\n";
-        }
-    });
-
-    cache += "# Manifest build date: " + new Date();
-    return cache;
-}
-
-module.exports = function (src, baton) {
-    baton.take();
-
-    copy(_c.ASSETS + "client", function () {
-        var css = _c.ASSETS + "client/ripple.css",
-            cssDeploy = _c.DEPLOY + "web/ripple.css",
-            cacheDeploy = _c.DEPLOY + "web/cache.manifest",
-            cacheTarget = _c.EXT + "web/cache.manifest",
-            cacheData = fs.readFileSync(cacheTarget, "utf-8"),
-            index = _c.DEPLOY + "web/index.html",
-            js = _c.DEPLOY + "web/ripple.js",
-            doc = src.html.replace(/#URL_PREFIX#/g, "")
-                          .replace(/#OVERLAY_VIEWS#/g, src.overlays)
-                          .replace(/#DIALOG_VIEWS#/g, src.dialogs)
-                          .replace(/#PANEL_VIEWS#/g, src.panels);
-
-        fs.writeFileSync(cssDeploy, fs.readFileSync(css, "utf-8") + src.skins);
-        fs.writeFileSync(index, doc);
-        fs.writeFileSync(js, src.js +
-            "ripple('ui').register('omnibar');" +
-            "ripple('bootstrap').bootstrap();");
-
-        fs.writeFileSync(cacheDeploy, cacheData + _cache());
-
-        copy(_c.PACKAGE_JSON, function () {
-            baton.pass(src);
-        });
-    });
-};

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/lib/client/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/client/bootstrap.js b/lib/client/bootstrap.js
index a48e071..a67a9b6 100644
--- a/lib/client/bootstrap.js
+++ b/lib/client/bootstrap.js
@@ -14,10 +14,7 @@
  * limitations under the License.
  */
 var _bound,
-    _console = ripple('console'),
-    ui = ripple('ui'),
-    db = ripple('db'),
-    _CURRENT_URL = "current-url";
+    _console = ripple('console');
 
 function _bindObjects(win, doc) {
     if (!win.tinyHippos) {
@@ -34,21 +31,6 @@ function _createFrame(src) {
     var frame = document.createElement("iframe");
     frame.setAttribute("id", "document");
     frame.src = src;
-
-    if (ui.registered("omnibar")) {
-        frame.addEventListener("beforeload", function () {
-            _bound = false;
-            _bindObjects(frame.contentWindow, frame.contentDocument);
-            var id = window.setInterval(function () {
-                if (_bound) {
-                    window.clearInterval(id);
-                } else {
-                    _bindObjects(frame.contentWindow, frame.contentDocument);
-                }
-            }, 1);
-        });
-    }
-
     return frame;
 }
 
@@ -85,22 +67,6 @@ function _post(src) {
         window.setTimeout(function () {
             window.clearInterval(id);
         }, 1200);
-
-
-        if (ui.registered("omnibar")) {
-            //reset the onload function so that when navigating we can destroy
-            //the iframe and create a new one so we can reinject the platform by
-            //calling post again.
-            frame.onload = function () {
-                var url = frame.contentWindow.location.href;
-                document.getElementById("viewport-container").removeChild(frame);
-                event.trigger("FrameHistoryChange", [url]);
-                _console.log("-----------------------------------------------------------");
-                _console.log("Pay no attention to that man behind the curtain.");
-                _console.log("Environment Warning up again (Set main batteries to auto-fire cycle)");
-                _post(url);
-            };
-        }
     };
 
     // append frame
@@ -119,10 +85,7 @@ function _bootstrap() {
     window.tinyHippos = ripple('index');
 
     tinyHippos.boot(function () {
-        var uri = ui.registered('omnibar') ?
-                db.retrieve(_CURRENT_URL) || "about:blank" :
-                document.documentURI.replace(/enableripple=[^&]*[&]?/i, "").replace(/[\?&]*$/, "");
-
+        var uri = document.documentURI.replace(/enableripple=[^&]*[&]?/i, "").replace(/[\?&]*$/, "");
         _post(uri);
         delete tinyHippos.boot;
     });

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/lib/client/ui/plugins/omnibar.js
----------------------------------------------------------------------
diff --git a/lib/client/ui/plugins/omnibar.js b/lib/client/ui/plugins/omnibar.js
deleted file mode 100644
index a33d3ab..0000000
--- a/lib/client/ui/plugins/omnibar.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *  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.
- */
-var emulatorBridge = ripple('emulatorBridge'),
-    db = ripple('db'),
-    event = ripple('event');
-
-function _omnibar() {
-    return document.querySelector(".omni-bar input");
-}
-
-function _persist(url) {
-    db.save("current-url", url);
-}
-
-function _persistRoot(url) {
-    db.save("root-url", url);
-}
-
-function _currentURL() {
-    return db.retrieve("current-url") || "about:blank";
-}
-
-function _rootURL() {
-    return db.retrieve("root-url") || "about:blank";
-}
-
-function _back() {
-    emulatorBridge.window().history.back();
-}
-
-function _forward() {
-    emulatorBridge.window().history.forward();
-}
-
-function _reload() {
-    emulatorBridge.window().location.reload();
-}
-
-event.on("FrameHistoryChange", function (url) {
-    _omnibar().value = url;
-    _persist(url);
-});
-
-module.exports = {
-    initialize: function () {
-        var omnibar = _omnibar();
-
-        jQuery(".logo, .beta, .left, .right, .left-panel-collapse, .right-panel-collapse").css({
-            "marginTop": "35px"
-        });
-
-        jQuery("#settings-xhr-proxy").parent().parent().hide();
-
-        $(".omni-bar").show();
-
-        omnibar.value = _currentURL();
-
-        omnibar.addEventListener("keydown", function (event) {
-            if (event.keyCode === '13' || event.keyCode === 13) { // enter
-                //default the protocal if not provided
-                omnibar.value = omnibar.value.indexOf("://") < 0 ? "http://" + omnibar.value : omnibar.value;
-                _persist(omnibar.value);
-                _persistRoot(omnibar.value);
-                emulatorBridge.window().location.assign(omnibar.value);
-            }
-        });
-
-        window.addEventListener("keydown", function (event) {
-            var hasMetaOrAltPressed = (event.metaKey || event.ctrlKey),
-                key = parseInt(event.keyCode, 10);
-
-            if (key === 37 && hasMetaOrAltPressed) { // cmd/ctrl + left arrow
-                event.preventDefault();
-                _back();
-            }
-
-            if (key === 39 && hasMetaOrAltPressed) { // cmd/ctrl + right arrow
-                event.preventDefault();
-                _forward();
-            }
-
-            if (key === 82 && hasMetaOrAltPressed) { // cmd/ctrl + r
-                event.preventDefault();
-                _reload();
-            }
-
-            if (key === 116) { // F5
-                event.preventDefault();
-                _reload();
-            }
-        });
-
-        document.getElementById("history-back").addEventListener("click", _back);
-        document.getElementById("history-forward").addEventListener("click", _forward);
-        document.getElementById("history-reload").addEventListener("click", _reload);
-    },
-    currentURL: function () {
-        return _currentURL();
-    },
-    rootURL: function () {
-        return _rootURL();
-    }
-};

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/lib/client/utils.js
----------------------------------------------------------------------
diff --git a/lib/client/utils.js b/lib/client/utils.js
index 7dd4b45..9d1ffdf 100644
--- a/lib/client/utils.js
+++ b/lib/client/utils.js
@@ -162,33 +162,6 @@ self = module.exports = {
     },
 
     appLocation: function () {
-        if (ripple('ui').registered("omnibar")) {
-            var path = ripple('ui/plugins/omnibar').rootURL().replace(/\/$/, ""),
-                parts;
-
-            if ((parts = path.match(/^((http[s]?|ftp):\/\/)(.+\/)?([^\/].+)$/i)) !== null && parts.length === 5) {
-                if (parts[4] === "about:blank") {
-                    path = "";
-                }
-                else if (parts[3]) {
-                    path = parts[1] + parts[3];
-                    if (parts[4].indexOf(".") === -1) {
-                        path += parts[4] + "/";
-                    }
-                }
-                else {
-                    path = parts[1] + parts[4] + "/";
-                }
-            }
-            else {
-                path = "";
-            }
-            return path;
-        }
-        return self.rippleLocation();
-    },
-
-    rippleLocation: function () {
         var loc = self.location(),
             parts = loc.pathname.split("/"),
             base = "",

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/lib/client/xhr.js
----------------------------------------------------------------------
diff --git a/lib/client/xhr.js b/lib/client/xhr.js
index 9ea7791..cde979d 100644
--- a/lib/client/xhr.js
+++ b/lib/client/xhr.js
@@ -14,14 +14,13 @@
  * limitations under the License.
  */
 var utils = ripple('utils'),
-    ui = ripple('ui'),
     helpers = ripple('xhr/helpers');
 
 module.exports = {
     initialize: function () {
         window.XMLHttpRequest = ripple('xhr/base');
 
-        if (helpers.proxyEnabled() && !ui.registered("omnibar")) {
+        if (helpers.proxyEnabled()) {
             var isFileScheme = utils.location().protocol.match(/^file:/);
             window.XMLHttpRequest = ripple(isFileScheme ? 'xhr/jsonp' : 'xhr/cors');
         }

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/targets/web/cache.manifest
----------------------------------------------------------------------
diff --git a/targets/web/cache.manifest b/targets/web/cache.manifest
deleted file mode 100644
index 40dc3d8..0000000
--- a/targets/web/cache.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-CACHE MANIFEST
-NETWORK:
-*
-CACHE:
-package.json

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/716a30a3/test/unit/client/utils.js
----------------------------------------------------------------------
diff --git a/test/unit/client/utils.js b/test/unit/client/utils.js
index 3ca6ed0..16dd462 100644
--- a/test/unit/client/utils.js
+++ b/test/unit/client/utils.js
@@ -453,62 +453,7 @@ describe("utils", function () {
         });
     });
 
-    describe("appLocation", function () {
-        var omnibar = ripple('ui/plugins/omnibar'),
-        ui = ripple('ui');
-
-        describe("properly parses the omnibar url", function () {
-            beforeEach(function () {
-                spyOn(ui, "registered").andReturn(true);
-            });
-
-            it("with a trailing slash", function () {
-                spyOn(omnibar, "rootURL").andReturn("http://127.0.0.1/UI/");
-                expect(utils.appLocation()).toBe("http://127.0.0.1/UI/");
-            });
-
-            it("without a trailing slash", function () {
-                spyOn(omnibar, "rootURL").andReturn("http://127.0.0.1/UI");
-                expect(utils.appLocation()).toBe("http://127.0.0.1/UI/");
-            });
-
-            it("with a specific file", function () {
-                spyOn(omnibar, "rootURL").andReturn("http://127.0.0.1/UI/yui.html");
-                expect(utils.appLocation()).toBe("http://127.0.0.1/UI/");
-            });
-
-            it("with a subdomain", function () {
-                spyOn(omnibar, "rootURL").andReturn("http://rippledemo.tinyhippos.com/");
-                expect(utils.appLocation()).toBe("http://rippledemo.tinyhippos.com/");
-            });
-
-            it("with simple domain", function () {
-                spyOn(omnibar, "rootURL").andReturn("http://rim.com");
-                expect(utils.appLocation()).toBe("http://rim.com/");
-            });
-
-            it("with simple domain", function () {
-                spyOn(omnibar, "rootURL").andReturn("http://rim.com");
-                expect(utils.appLocation()).toBe("http://rim.com/");
-            });
-
-            it("and returns an empty string when about:blank ", function () {
-                spyOn(omnibar, "rootURL").andReturn("http://about:blank");
-                expect(utils.appLocation()).toBe("");
-            });
-        });
-
-        describe("when omnibar is disabled", function () {
-            it("returns the window.location", function () {
-                spyOn(ui, "registered").andReturn(false);
-                spyOn(utils, "rippleLocation").andReturn("http://www.rim.com");
-                expect(utils.appLocation()).toBe("http://www.rim.com");
-            });
-        });
-    });
-
     describe("queryString", function () {
-
         it("can handle a location with no params", function () {
             spyOn(utils, "location").andReturn({
                 search: ""
@@ -543,7 +488,7 @@ describe("utils", function () {
         });
     });
 
-    describe("rippleLocation", function () {
+    describe("appLocation", function () {
         describe("properly returns the base path for ripple-ui", function () {
             it("returns the base path when index.html is used", function () {
                 spyOn(utils, "location").andReturn({
@@ -553,7 +498,7 @@ describe("utils", function () {
                     hostname: "127.0.0.1",
                     pathname: "/ripple/index.html"
                 });
-                expect(utils.rippleLocation()).toBe("http://127.0.0.1/ripple/");
+                expect(utils.appLocation()).toBe("http://127.0.0.1/ripple/");
             });
 
             it("returns the base path when index.html is not specified", function () {
@@ -564,7 +509,7 @@ describe("utils", function () {
                     hostname: "127.0.0.1",
                     pathname: "/ripple/"
                 });
-                expect(utils.rippleLocation()).toBe("http://127.0.0.1:8080/ripple/");
+                expect(utils.appLocation()).toBe("http://127.0.0.1:8080/ripple/");
             });
 
             it("returns the base path when no trailing forward slash exists", function () {
@@ -575,7 +520,7 @@ describe("utils", function () {
                     hostname: "127.0.0.1",
                     pathname: "/ripple"
                 });
-                expect(utils.rippleLocation()).toBe("http://127.0.0.1/ripple/");
+                expect(utils.appLocation()).toBe("http://127.0.0.1/ripple/");
             });
 
             it("returns the base path when hosted in multiple subdirectories", function () {
@@ -586,7 +531,7 @@ describe("utils", function () {
                     hostname: "127.0.0.1",
                     pathname: "/i/will/put/ripple/here/"
                 });
-                expect(utils.rippleLocation()).toBe("http://127.0.0.1:6767/i/will/put/ripple/here/");
+                expect(utils.appLocation()).toBe("http://127.0.0.1:6767/i/will/put/ripple/here/");
             });
 
             it("returns the correct path when folder has a . in it", function () {
@@ -597,7 +542,7 @@ describe("utils", function () {
                     hostname: "127.0.0.1",
                     pathname: "/bb10.sample/"
                 });
-                expect(utils.rippleLocation()).toBe("http://127.0.0.1/bb10.sample/");
+                expect(utils.appLocation()).toBe("http://127.0.0.1/bb10.sample/");
             });
         });
     });