You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/08/09 21:33:51 UTC
[1/2] git commit: Added partial support for "content" tag in
config.xml "cordova prepare" now correctly handles the tag. Android
only.
Updated Branches:
refs/heads/content [created] 9ac619516
Added partial support for "content" tag in config.xml
"cordova prepare" now correctly handles the <content> tag. Android only.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/89b7efda
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/89b7efda
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/89b7efda
Branch: refs/heads/content
Commit: 89b7efda51b6273513a7bc04811eb1a1d6145d60
Parents: c775d2a
Author: Germano Gabbianelli <ty...@gmail.com>
Authored: Fri Apr 19 18:45:09 2013 +0200
Committer: Fil Maj <ma...@gmail.com>
Committed: Fri Aug 9 12:32:34 2013 -0700
----------------------------------------------------------------------
src/config_parser.js | 16 ++++++++++++++++
src/metadata/android_parser.js | 3 +++
2 files changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/89b7efda/src/config_parser.js
----------------------------------------------------------------------
diff --git a/src/config_parser.js b/src/config_parser.js
index 5d1b8ed..5c5e0dc 100644
--- a/src/config_parser.js
+++ b/src/config_parser.js
@@ -45,6 +45,22 @@ config_parser.prototype = {
this.update();
} else return this.doc.getroot().attrib.version;
},
+ content: function(src) {
+ var content = this.doc.find('content');
+ if (src) {
+ content = content || new et.Element('content');
+ content.attrib.src = src;
+ this.update();
+ } else {
+ if (content === undefined) {
+ content = new et.Element('content');
+ content.attrib.src = 'index.html';
+ this.doc.getroot().append(content);
+ this.update();
+ }
+ return content.attrib.src;
+ }
+ },
update:function() {
fs.writeFileSync(this.path, this.doc.write({indent: 4}), 'utf-8');
}
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/89b7efda/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index b35b80d..3e9d680 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -119,6 +119,9 @@ module.exports.prototype = {
config.access.get().forEach(function(uri) {
android_cfg_xml.access.add(uri);
});
+
+ // Update content
+ android_cfg_xml.content(config.content());
// Update preferences
android_cfg_xml.preference.remove();
[2/2] git commit: [CB-3191] Added specs for config_parser changes to
include tag support. Updated stock template.
Posted by fi...@apache.org.
[CB-3191] Added specs for config_parser changes to include <content> tag support. Updated stock template.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/9ac61951
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/9ac61951
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/9ac61951
Branch: refs/heads/content
Commit: 9ac619516054283cbbb6802debd9cb9beaa420a0
Parents: 89b7efd
Author: Fil Maj <ma...@gmail.com>
Authored: Fri Aug 9 12:33:42 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Fri Aug 9 12:33:42 2013 -0700
----------------------------------------------------------------------
spec/config_parser.spec.js | 225 ++++++++++++++----------------
spec/metadata/android_parser.spec.js | 11 +-
src/metadata/android_parser.js | 2 +-
templates/config.xml | 2 +
4 files changed, 120 insertions(+), 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9ac61951/spec/config_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/config_parser.spec.js b/spec/config_parser.spec.js
index 018153a..544075d 100644
--- a/spec/config_parser.spec.js
+++ b/spec/config_parser.spec.js
@@ -41,145 +41,136 @@ describe('config.xml parser', function () {
expect(cfg).toBeDefined();
expect(cfg.doc).toBeDefined();
});
-
- describe('package name / id', function() {
- var cfg;
-
- beforeEach(function() {
- cfg = new config_parser(xml);
- });
-
- it('should get the (default) packagename', function() {
- expect(cfg.packageName()).toEqual('io.cordova.hellocordova');
- });
- it('should allow setting the packagename', function() {
- cfg.packageName('this.is.bat.country');
- expect(cfg.packageName()).toEqual('this.is.bat.country');
- });
- it('should write to disk after setting the packagename', function() {
- cfg.packageName('this.is.bat.country');
- expect(update).toHaveBeenCalled();
- });
- });
-
- describe('version', function() {
- var cfg;
-
- beforeEach(function() {
- cfg = new config_parser(xml);
- });
-
- it('should get the version', function() {
- expect(cfg.version()).toEqual('0.0.1');
- });
- it('should allow setting the version', function() {
- cfg.version('2.0.1');
- expect(cfg.version()).toEqual('2.0.1');
- });
- it('should write to disk after setting the version', function() {
- cfg.version('2.0.1');
- expect(update).toHaveBeenCalled();
- });
- });
-
- describe('app name', function() {
- var cfg;
-
- beforeEach(function() {
- cfg = new config_parser(xml);
- });
-
- it('should get the (default) app name', function() {
- expect(cfg.name()).toEqual('Hello Cordova');
- });
- it('should allow setting the app name', function() {
- cfg.name('this.is.bat.country');
- expect(cfg.name()).toEqual('this.is.bat.country');
- });
- it('should write to disk after setting the name', function() {
- cfg.name('one toke over the line');
- expect(update).toHaveBeenCalled();
- });
- });
-
- describe('access elements (whitelist)', function() {
+
+ describe('methods', function() {
var cfg;
-
beforeEach(function() {
cfg = new config_parser(xml);
});
- describe('getter', function() {
- it('should get the (default) access element', function() {
- expect(cfg.access.get()[0]).toEqual('*');
+ describe('package name / id', function() {
+ it('should get the (default) packagename', function() {
+ expect(cfg.packageName()).toEqual('io.cordova.hellocordova');
+ });
+ it('should allow setting the packagename', function() {
+ cfg.packageName('this.is.bat.country');
+ expect(cfg.packageName()).toEqual('this.is.bat.country');
});
- it('should return an array of all access origin uris via access()', function() {
- expect(cfg.access.get() instanceof Array).toBe(true);
+ it('should write to disk after setting the packagename', function() {
+ cfg.packageName('this.is.bat.country');
+ expect(update).toHaveBeenCalled();
});
});
- describe('setters', function() {
- it('should allow removing a uri from the access list', function() {
- cfg.access.remove('*');
- expect(cfg.access.get().length).toEqual(0);
+
+ describe('version', function() {
+ it('should get the version', function() {
+ expect(cfg.version()).toEqual('0.0.1');
});
- it('should write to disk after removing a uri', function() {
- cfg.access.remove('*');
+ it('should allow setting the version', function() {
+ cfg.version('2.0.1');
+ expect(cfg.version()).toEqual('2.0.1');
+ });
+ it('should write to disk after setting the version', function() {
+ cfg.version('2.0.1');
expect(update).toHaveBeenCalled();
});
- it('should allow adding a new uri to the access list', function() {
- cfg.access.add('http://canucks.com');
- expect(cfg.access.get().length).toEqual(2);
- expect(cfg.access.get().indexOf('http://canucks.com') > -1).toBe(true);
+ });
+
+ describe('content', function() {
+ it('should get the content src attribute', function() {
+ expect(cfg.content()).toEqual('index.html');
});
- it('should write to disk after adding a uri', function() {
- cfg.access.add('http://cordova.io');
- expect(update).toHaveBeenCalled();
+ it('should allow setting the content src attribute', function() {
+ cfg.content('main.html');
+ expect(cfg.content()).toEqual('main.html');
});
- it('should allow removing all access elements when no parameter is specified', function() {
- cfg.access.add('http://cordova.io');
- cfg.access.remove();
- expect(cfg.access.get().length).toEqual(0);
+ it('should write to disk after setting the content', function() {
+ cfg.content('batman.html');
+ expect(update).toHaveBeenCalled();
});
});
- });
- describe('preference elements', function() {
- var cfg;
-
- beforeEach(function() {
- cfg = new config_parser(xml);
+ describe('app name', function() {
+ it('should get the (default) app name', function() {
+ expect(cfg.name()).toEqual('Hello Cordova');
+ });
+ it('should allow setting the app name', function() {
+ cfg.name('this.is.bat.country');
+ expect(cfg.name()).toEqual('this.is.bat.country');
+ });
+ it('should write to disk after setting the name', function() {
+ cfg.name('one toke over the line');
+ expect(update).toHaveBeenCalled();
+ });
});
- describe('getter', function() {
- it('should get all preference elements', function() {
- expect(cfg.preference.get()[0].name).toEqual('fullscreen');
- expect(cfg.preference.get()[0].value).toEqual('true');
+ describe('access elements (whitelist)', function() {
+ describe('getter', function() {
+ it('should get the (default) access element', function() {
+ expect(cfg.access.get()[0]).toEqual('*');
+ });
+ it('should return an array of all access origin uris via access()', function() {
+ expect(cfg.access.get() instanceof Array).toBe(true);
+ });
});
- it('should return an array of all preference name/value pairs', function() {
- expect(cfg.preference.get() instanceof Array).toBe(true);
+ describe('setters', function() {
+ it('should allow removing a uri from the access list', function() {
+ cfg.access.remove('*');
+ expect(cfg.access.get().length).toEqual(0);
+ });
+ it('should write to disk after removing a uri', function() {
+ cfg.access.remove('*');
+ expect(update).toHaveBeenCalled();
+ });
+ it('should allow adding a new uri to the access list', function() {
+ cfg.access.add('http://canucks.com');
+ expect(cfg.access.get().length).toEqual(2);
+ expect(cfg.access.get().indexOf('http://canucks.com') > -1).toBe(true);
+ });
+ it('should write to disk after adding a uri', function() {
+ cfg.access.add('http://cordova.io');
+ expect(update).toHaveBeenCalled();
+ });
+ it('should allow removing all access elements when no parameter is specified', function() {
+ cfg.access.add('http://cordova.io');
+ cfg.access.remove();
+ expect(cfg.access.get().length).toEqual(0);
+ });
});
});
- describe('setters', function() {
- it('should allow removing a preference by name', function() {
- cfg.preference.remove('fullscreen');
- expect(cfg.preference.get().length).toEqual(1);
- });
- it('should write to disk after removing a preference', function() {
- cfg.preference.remove('phonegap-version');
- expect(fs.readFileSync(xml, 'utf-8')).not.toMatch(/<preference\sname="phonegap-version"/);
- });
- it('should allow adding a new preference', function() {
- cfg.preference.add({name:'UIWebViewBounce',value:'false'});
- expect(cfg.preference.get().length).toEqual(3);
- expect(cfg.preference.get()[2].value).toEqual('false');
- });
- it('should write to disk after adding a preference', function() {
- cfg.preference.add({name:'UIWebViewBounce',value:'false'});
- expect(update).toHaveBeenCalled();
+
+ describe('preference elements', function() {
+ describe('getter', function() {
+ it('should get all preference elements', function() {
+ expect(cfg.preference.get()[0].name).toEqual('fullscreen');
+ expect(cfg.preference.get()[0].value).toEqual('true');
+ });
+ it('should return an array of all preference name/value pairs', function() {
+ expect(cfg.preference.get() instanceof Array).toBe(true);
+ });
});
- it('should allow removing all preference elements when no parameter is specified', function() {
- cfg.preference.remove();
- expect(cfg.preference.get().length).toEqual(0);
+ describe('setters', function() {
+ it('should allow removing a preference by name', function() {
+ cfg.preference.remove('fullscreen');
+ expect(cfg.preference.get().length).toEqual(1);
+ });
+ it('should write to disk after removing a preference', function() {
+ cfg.preference.remove('phonegap-version');
+ expect(fs.readFileSync(xml, 'utf-8')).not.toMatch(/<preference\sname="phonegap-version"/);
+ });
+ it('should allow adding a new preference', function() {
+ cfg.preference.add({name:'UIWebViewBounce',value:'false'});
+ expect(cfg.preference.get().length).toEqual(3);
+ expect(cfg.preference.get()[2].value).toEqual('false');
+ });
+ it('should write to disk after adding a preference', function() {
+ cfg.preference.add({name:'UIWebViewBounce',value:'false'});
+ expect(update).toHaveBeenCalled();
+ });
+ it('should allow removing all preference elements when no parameter is specified', function() {
+ cfg.preference.remove();
+ expect(cfg.preference.get().length).toEqual(0);
+ });
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9ac61951/spec/metadata/android_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/android_parser.spec.js b/spec/metadata/android_parser.spec.js
index a3fcf41..228a11b 100644
--- a/spec/metadata/android_parser.spec.js
+++ b/spec/metadata/android_parser.spec.js
@@ -114,7 +114,7 @@ describe('android project parser', function() {
});
describe('update_from_config method', function() {
- var et, xml, find, write_xml, root, cfg, readdir, cfg_parser, find_obj, root_obj, cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm;
+ var et, xml, find, write_xml, root, cfg, readdir, cfg_parser, find_obj, root_obj, cfg_access_add, cfg_access_rm, cfg_pref_add, cfg_pref_rm, cfg_content;
beforeEach(function() {
find_obj = {
text:'hi'
@@ -140,11 +140,13 @@ describe('android project parser', function() {
cfg.version = function() { return 'one point oh' };
cfg.access.get = function() { return [] };
cfg.preference.get = function() { return [] };
+ cfg.content = function() { return 'index.html' };
read.andReturn('some java package');
cfg_access_add = jasmine.createSpy('config_parser access add');
cfg_access_rm = jasmine.createSpy('config_parser access rm');
cfg_pref_rm = jasmine.createSpy('config_parser pref rm');
cfg_pref_add = jasmine.createSpy('config_parser pref add');
+ cfg_content = jasmine.createSpy('config_parser content');
cfg_parser = spyOn(util, 'config_parser').andReturn({
access:{
remove:cfg_access_rm,
@@ -155,7 +157,8 @@ describe('android project parser', function() {
remove:cfg_pref_rm,
get:function(){},
add:cfg_pref_add
- }
+ },
+ content:cfg_content
});
});
@@ -197,6 +200,10 @@ describe('android project parser', function() {
expect(cfg_pref_add).toHaveBeenCalledWith({name:"useBrowserHistory",value:"true"});
expect(cfg_pref_add).toHaveBeenCalledWith({name:"exit-on-suspend",value:"false"});
});
+ it('should update the content tag', function() {
+ p.update_from_config(cfg);
+ expect(cfg_content).toHaveBeenCalledWith('index.html');
+ });
});
describe('www_dir method', function() {
it('should return assets/www', function() {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9ac61951/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index 3e9d680..722bd45 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -120,7 +120,7 @@ module.exports.prototype = {
android_cfg_xml.access.add(uri);
});
- // Update content
+ // Update content (start page)
android_cfg_xml.content(config.content());
// Update preferences
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9ac61951/templates/config.xml
----------------------------------------------------------------------
diff --git a/templates/config.xml b/templates/config.xml
index a66b224..276aae9 100644
--- a/templates/config.xml
+++ b/templates/config.xml
@@ -13,6 +13,8 @@
Apache Cordova Team
</author>
+ <content src="index.html" />
+
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />