cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [36/50] [abbrv] cordova-common git commit: [CB-11120] Allow short/display name in config.xml
Date Tue, 06 Jun 2017 05:00:04 GMT
[CB-11120] Allow short/display name in config.xml

This adds support for a "short" display name to be specified as an
attribute of the `name` element in config.xml.

This attribute is defined in the W3C Widgets spec, on which config.xml
is loosely based:
https://www.w3.org/TR/widgets/#the-short-attribute

 This closes #453


Project: http://git-wip-us.apache.org/repos/asf/cordova-common/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-common/commit/3eca1a80
Tree: http://git-wip-us.apache.org/repos/asf/cordova-common/tree/3eca1a80
Diff: http://git-wip-us.apache.org/repos/asf/cordova-common/diff/3eca1a80

Branch: refs/heads/master
Commit: 3eca1a8032370120692d22e6969c72994f7386fe
Parents: 364e39e
Author: Darryl Pogue <darryl@dpogue.ca>
Authored: Sat Jun 4 20:34:51 2016 -0700
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Thu Mar 23 21:49:57 2017 -0700

----------------------------------------------------------------------
 spec/ConfigParser/ConfigParser.spec.js | 13 +++++++++++++
 src/ConfigParser/ConfigParser.js       | 10 ++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-common/blob/3eca1a80/spec/ConfigParser/ConfigParser.spec.js
----------------------------------------------------------------------
diff --git a/spec/ConfigParser/ConfigParser.spec.js b/spec/ConfigParser/ConfigParser.spec.js
index f3e334d..fa49550 100644
--- a/spec/ConfigParser/ConfigParser.spec.js
+++ b/spec/ConfigParser/ConfigParser.spec.js
@@ -83,7 +83,20 @@ describe('config.xml parser', function () {
                 cfg.setName('this.is.bat.country');
                 expect(cfg.name()).toEqual('this.is.bat.country');
             });
+
+            describe('short name', function() {
+                it('should default to the app name', function() {
+                    expect(cfg.shortName()).toEqual('Hello Cordova');
+                });
+
+                it('should allow setting the app short name', function() {
+                    cfg.setShortName('Hi CDV');
+                    expect(cfg.name()).toEqual('Hello Cordova');
+                    expect(cfg.shortName()).toEqual('Hi CDV');
+                });
+            });
         });
+
         describe('preference', function() {
             it('Test 010 : should return the value of a global preference', function() {
                 expect(cfg.getPreference('fullscreen')).toEqual('true');

http://git-wip-us.apache.org/repos/asf/cordova-common/blob/3eca1a80/src/ConfigParser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/src/ConfigParser/ConfigParser.js b/src/ConfigParser/ConfigParser.js
index e477a89..cd718de 100644
--- a/src/ConfigParser/ConfigParser.js
+++ b/src/ConfigParser/ConfigParser.js
@@ -116,6 +116,16 @@ ConfigParser.prototype = {
         var el = findOrCreate(this.doc, 'name');
         el.text = name;
     },
+    shortName: function() {
+        return this.doc.find('name').attrib['short'] || this.name();
+    },
+    setShortName: function(shortname) {
+        var el = findOrCreate(this.doc, 'name');
+        if (!el.text) {
+            el.text = shortname;
+        }
+        el.attrib['short'] = shortname;
+    },
     description: function() {
         return getNodeTextSafe(this.doc.find('description'));
     },


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message