Updated README.md for AppBundle plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/0ae80c8b Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/0ae80c8b Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/0ae80c8b Branch: refs/heads/master Commit: 0ae80c8bef0971ebe4728e63187e430d507f9276 Parents: 9946d32 Author: Andrew Grieve <[email protected]> Authored: Tue Oct 22 22:27:37 2013 -0400 Committer: Andrew Grieve <[email protected]> Committed: Wed Oct 23 21:55:18 2013 -0400 ---------------------------------------------------------------------- AppBundle/README.md | 47 ++++++++++------------------------------------- 1 file changed, 10 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/0ae80c8b/AppBundle/README.md ---------------------------------------------------------------------- diff --git a/AppBundle/README.md b/AppBundle/README.md index d1b55e0..4acc9dd 100644 --- a/AppBundle/README.md +++ b/AppBundle/README.md @@ -1,23 +1,23 @@ AppBundle ========= -Enables dynamic rerouting or URLs. +Enables dynamic rerouting of URLs. -##AppBundle Uri's -This plugin allows the use of "app-bundle://" instead of platform specific urls such "file:///android_asset" etc. -For example, to refer to an index.html file in the "www" folder with an absolute path, you can use +# iOS Quirks - "app-bundle:///index.html" +- Top-level navigations to file:/// URLs cannot be remapped while preserving history.back() functionality (OS bug). -This will navigate you to "file:///android_asset/www/index.html" on android and similarly for ios. +# Android Quirks -##Custom Uri replacement schemes -You can add your own url replacements to this plugin as well. +- Requires Android 3.0 or greater. +- Cannot remap file:/// URLs when the target file exists on the filesystem (OS bug). -###Api +## Api appBundle.addAlias(string matchRegex, string replaceRegex, string replaceString, boolean redirect, function callback(succeeded){}); - appBundle.clearAllAliases(function callback(succeeded){}); + appBundle.setResetUrl(string matchRegex, callback(){}); + appBundle.injectJsForUrl(string matchRegex, string jsToInject, callback(){}); + appBundle.clearAllAliases(function callback(){}); * matchRegex -> allows you to specify a regex that determines which url's are replaced. * replaceRegex -> allows you to specify what part of the url's are replaced. @@ -41,30 +41,3 @@ The algorithm operates as follows } continue loading 'url' -###Examples - -Map http requests to file - - appBundle.addAlias("^http://mysite\.com/.*", "^http://mysite\.com/", "file://storage_card/", false, function(succeded){}); - -Map http requests to another http location, or file to file - - appBundle.addAlias("^http://mysite\.com/.*", "^http://mysite\.com/", "http:///mysiteproxy.com/", false, function(succeded){}); - -Map http requests to your bundle - - appBundle.addAlias("^http://mysite\.com/.*", "^http://mysite\.com/", "app-bundle:///", false, function(succeded){}); - -Map bundle requests to http or file. Note the usage of the "{BUNDLE_WWW}" param here. This is replaced by "file:///android_asset/" on android and similarly on ios. - -Why use "BUNDLE_WWW" and not "app-bundle:///"? "app-bundle:" uri's always point to your bundle and CANNOT be redirected. Also other parts of your program may make requests to to "file://android_assets/www" directly (which many plugins actually do). You would expect all requests to get redirected. The "BUNDLE_WWW" takes care of this. - - appBundle.addAlias("^{BUNDLE_WWW}.*", "^{BUNDLE_WWW}", "http://mysite\.com", false, function(succeded){}); - -Apply recursive replacements. A request to http://mysite.com/blah should give http:///mysiteproxy2.com/blah as the recursive replacements apply the rules last to first. - - appBundle.addAlias("^http://mysite\.com/.*", "^http://mysite\.com/", "{BUNDLE_WWW}", false, function(succeded){}); - appBundle.addAlias("^{BUNDLE_WWW}.*", "^{BUNDLE_WWW}", "file://storage/www/", false, function(succeded){}); - appBundle.addAlias("^http://mysite\.com/.*", "^http://mysite\.com/", "http:///mysiteproxy.com/", false, function(succeded){}); - appBundle.addAlias("^http:///mysiteproxy\.com/.*", "^http:///mysiteproxy\.com/", "http:///mysiteproxy2.com/", false, function(succeded){}); -
