1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Move core node icons into node package

This commit is contained in:
Nick O'Leary 2018-08-15 23:12:51 +01:00
parent a3aec6b939
commit a747d8c2d5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
55 changed files with 30 additions and 26 deletions

View File

@ -25,6 +25,7 @@ var theme = require("./theme");
var runtimeAPI; var runtimeAPI;
var defaultNodeIcon = path.resolve(__dirname+"/../../src/images/icons/arrow-in.png")
var templateDir = path.resolve(__dirname+"/../../src/templates"); var templateDir = path.resolve(__dirname+"/../../src/templates");
var editorTemplate; var editorTemplate;
@ -55,10 +56,15 @@ module.exports = {
icon: icon icon: icon
} }
runtimeAPI.nodes.getIcon(opts).then(function(data) { runtimeAPI.nodes.getIcon(opts).then(function(data) {
var contentType = mime.lookup(icon); if (data) {
res.set("Content-Type", contentType); var contentType = mime.lookup(icon);
res.send(data); res.set("Content-Type", contentType);
res.send(data);
} else {
res.sendFile(defaultNodeIcon);
}
}).catch(function(err) { }).catch(function(err) {
console.log(err.stack);
apiUtils.rejectHandler(req,res,err); apiUtils.rejectHandler(req,res,err);
}) })
}, },

View File

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 393 B

View File

Before

Width:  |  Height:  |  Size: 386 B

After

Width:  |  Height:  |  Size: 386 B

View File

Before

Width:  |  Height:  |  Size: 386 B

After

Width:  |  Height:  |  Size: 386 B

View File

@ -2182,8 +2182,8 @@ RED.view = (function() {
//node.append("path").attr("class","node_error").attr("d","M 3,-3 l 10,0 l -5,-8 z"); //node.append("path").attr("class","node_error").attr("d","M 3,-3 l 10,0 l -5,-8 z");
//TODO: these ought to be SVG //TODO: these ought to be SVG
node.append("image").attr("class","node_error hidden").attr("xlink:href","icons/node-red/node-error.png").attr("x",0).attr("y",-6).attr("width",10).attr("height",9); node.append("image").attr("class","node_error hidden").attr("xlink:href","red/images/icons/node-error.png").attr("x",0).attr("y",-6).attr("width",10).attr("height",9);
node.append("image").attr("class","node_changed hidden").attr("xlink:href","icons/node-red/node-changed.png").attr("x",12).attr("y",-6).attr("width",10).attr("height",10); node.append("image").attr("class","node_changed hidden").attr("xlink:href","red/images/icons/node-changed.png").attr("x",12).attr("y",-6).attr("width",10).attr("height",10);
}); });
node.each(function(d,i) { node.each(function(d,i) {

View File

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

View File

Before

Width:  |  Height:  |  Size: 603 B

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

View File

Before

Width:  |  Height:  |  Size: 712 B

After

Width:  |  Height:  |  Size: 712 B

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 508 B

View File

Before

Width:  |  Height:  |  Size: 575 B

After

Width:  |  Height:  |  Size: 575 B

View File

Before

Width:  |  Height:  |  Size: 493 B

After

Width:  |  Height:  |  Size: 493 B

View File

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 601 B

View File

Before

Width:  |  Height:  |  Size: 459 B

After

Width:  |  Height:  |  Size: 459 B

View File

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 218 B

View File

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 324 B

View File

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 378 B

View File

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 542 B

View File

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 503 B

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 457 B

View File

Before

Width:  |  Height:  |  Size: 502 B

After

Width:  |  Height:  |  Size: 502 B

View File

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 449 B

View File

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 253 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 639 B

View File

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

View File

Before

Width:  |  Height:  |  Size: 414 B

After

Width:  |  Height:  |  Size: 414 B

View File

Before

Width:  |  Height:  |  Size: 671 B

After

Width:  |  Height:  |  Size: 671 B

View File

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 413 B

View File

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 393 B

View File

Before

Width:  |  Height:  |  Size: 467 B

After

Width:  |  Height:  |  Size: 467 B

View File

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 393 B

View File

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 423 B

View File

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 360 B

View File

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 736 B

View File

Before

Width:  |  Height:  |  Size: 482 B

After

Width:  |  Height:  |  Size: 482 B

View File

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 273 B

View File

Before

Width:  |  Height:  |  Size: 793 B

After

Width:  |  Height:  |  Size: 793 B

View File

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

View File

Before

Width:  |  Height:  |  Size: 439 B

After

Width:  |  Height:  |  Size: 439 B

View File

Before

Width:  |  Height:  |  Size: 592 B

After

Width:  |  Height:  |  Size: 592 B

View File

Before

Width:  |  Height:  |  Size: 509 B

After

Width:  |  Height:  |  Size: 509 B

View File

Before

Width:  |  Height:  |  Size: 488 B

After

Width:  |  Height:  |  Size: 488 B

View File

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 628 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 404 B

View File

Before

Width:  |  Height:  |  Size: 591 B

After

Width:  |  Height:  |  Size: 591 B

View File

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 707 B

View File

@ -241,14 +241,12 @@ function getNodeFiles(disableNodePathScan) {
var nodeFiles = []; var nodeFiles = [];
var results; var results;
var dir = path.resolve(__dirname + '/../../public/icons'); var dir;
var iconList = [{path:dir,icons:scanIconDir(dir)}]; var iconList = [];
if (settings.coreNodesDir) { if (settings.coreNodesDir) {
results = getLocalNodeFiles(path.resolve(settings.coreNodesDir)); results = getLocalNodeFiles(path.resolve(settings.coreNodesDir));
nodeFiles = nodeFiles.concat(results.files); nodeFiles = nodeFiles.concat(results.files);
iconList = iconList.concat(results.icons); iconList = iconList.concat(results.icons);
var defaultLocalesPath = path.join(settings.coreNodesDir,"core","locales"); var defaultLocalesPath = path.join(settings.coreNodesDir,"core","locales");
i18n.registerMessageCatalog("node-red",defaultLocalesPath,"messages.json"); i18n.registerMessageCatalog("node-red",defaultLocalesPath,"messages.json");
} }

View File

@ -555,11 +555,8 @@ function setModulePendingUpdated(module,version) {
}); });
} }
var icon_paths = { var icon_paths = { };
"node-red":[path.resolve(__dirname + '/../editor/public/icons')]
};
var iconCache = {}; var iconCache = {};
var defaultIcon = path.join(icon_paths['node-red'][0],'arrow-in.png');
function getNodeIconPath(module,icon) { function getNodeIconPath(module,icon) {
if (/\.\./.test(icon)) { if (/\.\./.test(icon)) {
@ -585,8 +582,7 @@ function getNodeIconPath(module,icon) {
if (module !== "node-red") { if (module !== "node-red") {
return getNodeIconPath("node-red", icon); return getNodeIconPath("node-red", icon);
} }
return null;
return defaultIcon;
} }
} }

View File

@ -420,19 +420,23 @@ var api = module.exports = {
* @param {User} opts.user - the user calling the api * @param {User} opts.user - the user calling the api
* @param {String} opts.module - the id of the module requesting the icon * @param {String} opts.module - the id of the module requesting the icon
* @param {String} opts.icon - the name of the icon * @param {String} opts.icon - the name of the icon
* @return {Promise<Buffer>} - the icon file as a Buffer * @return {Promise<Buffer>} - the icon file as a Buffer or null if no icon available
* @memberof RED.nodes * @memberof RED.nodes
*/ */
getIcon: function(opts) { getIcon: function(opts) {
return new Promise(function(resolve,reject) { return new Promise(function(resolve,reject) {
var iconPath = runtime.nodes.getNodeIconPath(opts.module,opts.icon); var iconPath = runtime.nodes.getNodeIconPath(opts.module,opts.icon);
fs.readFile(iconPath,function(err,data) { if (iconPath) {
if (err) { fs.readFile(iconPath,function(err,data) {
err.status = 400; if (err) {
return reject(err); err.status = 400;
} return reject(err);
return resolve(data) }
}); return resolve(data)
});
} else {
resolve(null);
}
}); });
} }
} }

View File

@ -47,8 +47,8 @@
var fs = require('fs-extra'); var fs = require('fs-extra');
var path = require("path"); var path = require("path");
var util = require("../../util"); var util = require("@node-red/util").util;
var log = require("../../log"); var log = require("@node-red/util").log;
var safeJSONStringify = require("json-stringify-safe"); var safeJSONStringify = require("json-stringify-safe");
var MemoryStore = require("./memory"); var MemoryStore = require("./memory");

View File

@ -70,7 +70,7 @@ module.exports = {
redUtil.init(userSettings); redUtil.init(userSettings);
if (userSettings.httpAdminRoot !== false) { if (userSettings.httpAdminRoot !== false) {
runtime.init(userSettings,redUtil,api); runtime.init(userSettings,redUtil,api);
api.init(httpServer,userSettings,runtime.storage,runtime); api.init(httpServer,userSettings,runtime._.storage,runtime);
apiEnabled = true; apiEnabled = true;
server = runtime._.adminApi.server; server = runtime._.adminApi.server;