cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/2] git commit: CB-2606 add launcher icon support for FirefoxOS
Date Mon, 12 May 2014 21:46:43 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master 50a050696 -> 74df777a4


CB-2606 add launcher icon support for FirefoxOS


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

Branch: refs/heads/master
Commit: 7619fbd1040723b74a5121dcef2dfe0a8c559e31
Parents: 86f7c4a
Author: ignisvulpis <axel@nennker.de>
Authored: Mon May 12 19:33:02 2014 +0200
Committer: ignisvulpis <axel@nennker.de>
Committed: Mon May 12 19:33:02 2014 +0200

----------------------------------------------------------------------
 .../src/cordova/metadata/firefoxos_parser.js    | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7619fbd1/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 351a409..becef96 100644
--- a/cordova-lib/src/cordova/metadata/firefoxos_parser.js
+++ b/cordova-lib/src/cordova/metadata/firefoxos_parser.js
@@ -19,6 +19,7 @@
 var fs = require('fs'),
     path = require('path'),
     shell = require('shelljs'),
+    events = require('../events'),
     util = require('../util'),
     events = require('../events'),
     Q = require('q'),
@@ -50,6 +51,7 @@ module.exports.prototype = {
             };
         }
 
+events.emit('verbose', "config:" + JSON.stringify(config));
         manifest.version = config.version();
         manifest.name = config.name();
         manifest.pkgName = config.packageName();
@@ -97,6 +99,33 @@ module.exports.prototype = {
             delete manifest.type;
         }
 
+        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));
+                }
+              } else {
+                events.emit('warn', "ignoring icon["+i+"] no src attribute:" + JSON.stringify(icon));
+              }
+            }
+          }
+        }
+
         fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4));
 
         return Q();


Mime
View raw message