You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by za...@apache.org on 2014/06/13 12:45:07 UTC

[1/2] git commit: CB-6895 Add more config properties into manifest

Repository: cordova-lib
Updated Branches:
  refs/heads/master 4548595f1 -> aa070bbec


CB-6895 Add more config properties into manifest


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

Branch: refs/heads/master
Commit: c3997c279615006e21b73bcfda44368e8e1aadcf
Parents: 38068fa
Author: Rodrigo Silveira <ro...@outlook.com>
Authored: Tue Jun 10 15:29:49 2014 -0700
Committer: Rodrigo Silveira <ro...@outlook.com>
Committed: Thu Jun 12 11:30:45 2014 -0700

----------------------------------------------------------------------
 .../src/cordova/metadata/firefoxos_parser.js    | 101 +++++++++++--------
 1 file changed, 59 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/c3997c27/cordova-lib/src/cordova/metadata/firefoxos_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/firefoxos_parser.js b/cordova-lib/src/cordova/metadata/firefoxos_parser.js
index 38797f7..d21b83f 100644
--- a/cordova-lib/src/cordova/metadata/firefoxos_parser.js
+++ b/cordova-lib/src/cordova/metadata/firefoxos_parser.js
@@ -21,7 +21,6 @@ var fs = require('fs'),
     shell = require('shelljs'),
     events = require('../events'),
     util = require('../util'),
-    events = require('../events'),
     Q = require('q'),
     ConfigParser = require('../../configparser/ConfigParser');
 
@@ -39,19 +38,19 @@ module.exports.prototype = {
     update_from_config: function() {
         var config = new ConfigParser(this.config_xml());
         var manifestPath = path.join(this.www_dir(), 'manifest.webapp');
-        var manifest;
+        var manifest = {};
 
-        if(fs.existsSync(manifestPath)) {
+        // Load existing manifest
+        if (fs.existsSync(manifestPath)) {
             manifest = JSON.parse(fs.readFileSync(manifestPath));
         }
-        else {
-            manifest = {
-                launch_path: "/index.html",
-                installs_allowed_from: ["*"]
-            };
-        }
 
-events.emit('verbose', "config:" + JSON.stringify(config));
+        // overwrite properties existing in config.xml
+        var contentNode = config.doc.find('content');
+        var contentSrc = contentNode.attrib['src'];
+        manifest.launch_path = path.join("/", contentSrc) || "/index.html";
+
+        manifest.installs_allowed_from = manifest.installs_allowed_from || ["*"];
         manifest.version = config.version();
         manifest.name = config.name();
         manifest.pkgName = config.packageName();
@@ -67,28 +66,43 @@ events.emit('verbose', "config:" + JSON.stringify(config));
             manifest.developer.url = authorUrl;
         }
 
+        var fullScreen = config.getPreference('fullscreen');
+
+        if (fullScreen) {
+            manifest.fullscreen = fullScreen;
+        }
+
+        var orientations = [];
+        var preferenceNodes = config.doc.findall('preference');
+        preferenceNodes.forEach(function (preference) {
+            if (preference.attrib.name.toLowerCase() === 'orientation') {
+                orientations.push(preference.attrib.value);
+            }
+        });
+
+        if (orientations && orientations.length) {
+            manifest.orientation = orientations;
+        }
+
         var permissionNodes = config.doc.findall('permission');
         var privileged = false;
 
         if (permissionNodes.length) {
-            manifest.permissions = manifest.permissions || {};
+            manifest.permissions = {};
 
             permissionNodes.forEach(function(node) {
                 var permissionName = node.attrib['name'];
 
-                // Don't change if it was already created
-                if (!manifest.permissions[permissionName]) {
-                    manifest.permissions[permissionName] = {
-                        description: node.attrib['description']
-                    };
+                manifest.permissions[permissionName] = {
+                    description: node.attrib['description']
+                };
 
-                    if (node.attrib['access']) {
-                        manifest.permissions[permissionName].access = node.attrib['access'];
-                    }
+                if (node.attrib['access']) {
+                    manifest.permissions[permissionName].access = node.attrib['access'];
+                }
 
-                    if (node.attrib['privileged'] === "true") {
-                        privileged = true;
-                    }
+                if (node.attrib['privileged'] === "true") {
+                    privileged = true;
                 }
             });
         }
@@ -102,28 +116,31 @@ events.emit('verbose', "config:" + JSON.stringify(config));
         var icons = config.getIcons('firefoxos');
         // if there are icon elements in config.xml
         if (icons) {
-          manifest.icons = {};
-          for (var i=0; i<icons.length; i++) {
-            var icon = icons[i];
-            events.emit('verbose', "icon["+i+"]:" + JSON.stringify(icon));
-            var destfilepath;
-            var size = icon.width;
-            var sizeInt = parseInt(size);
-            if (size && sizeInt !== NaN) {
-              if (icon.src) {
-                if (!manifest.icons[sizeInt]) { // do not yet have an icon for this size
-                  var destfilepath = path.join(this.www_dir(), "icon-"+size+".png");
-                  manifest.icons[sizeInt] = "/icon-"+size+".png";
-                  events.emit('verbose', 'Copying icon from ' + icon.src + ' to ' + destfilepath);
-                  shell.cp('-f', icon.src, destfilepath);
-                } else {
-                  events.emit('warn', "ignoring icon["+i+"]:" + JSON.stringify(icon));
+            manifest.icons = {};
+            for (var i = 0; i < icons.length; i++) {
+                var icon = icons[i];
+                var size = icon.width;
+                var sizeInt = parseInt(size);
+
+                events.emit('verbose', "icon[" + i + "]:" + JSON.stringify(icon));
+
+                if (size && !isNaN(sizeInt)) {
+                    if (icon.src) {
+                        var destfilepath = path.join(this.www_dir(), "icon", "icon-" + size + ".png");
+
+                        manifest.icons[sizeInt] = "/icon/icon-" + size + ".png";
+
+                        if (!fs.existsSync(icon.src)) {
+                            events.emit('verbose', "ignoring icon[" + i + "] icon. File " + icon.src + " not found.");
+                        } else {
+                            events.emit('verbose', 'Copying icon from ' + icon.src + ' to ' + destfilepath);
+                            shell.cp('-f', icon.src, destfilepath);
+                        }
+                    } else {
+                        events.emit('warn', "ignoring icon[" + i + "] no src attribute:" + JSON.stringify(icon));
+                    }
                 }
-              } else {
-                events.emit('warn', "ignoring icon["+i+"] no src attribute:" + JSON.stringify(icon));
-              }
             }
-          }
         }
 
         fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4));


[2/2] git commit: Merge remote-tracking branch 'rodms/CB-6895'

Posted by za...@apache.org.
Merge remote-tracking branch 'rodms/CB-6895'


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

Branch: refs/heads/master
Commit: aa070bbec860d54add6683fe84784356761dfc5b
Parents: 4548595 c3997c2
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Fri Jun 13 12:44:47 2014 +0200
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Fri Jun 13 12:44:47 2014 +0200

----------------------------------------------------------------------
 .../src/cordova/metadata/firefoxos_parser.js    | 101 +++++++++++--------
 1 file changed, 59 insertions(+), 42 deletions(-)
----------------------------------------------------------------------