mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Allow icons to be bundled with nodes
This commit is contained in:
parent
bbe37dd944
commit
5e8e35e6fa
@ -241,8 +241,10 @@ module.exports.load = function() {
|
|||||||
}
|
}
|
||||||
} else if (stats.isDirectory()) {
|
} else if (stats.isDirectory()) {
|
||||||
// Ignore /.dirs/ and /lib/
|
// Ignore /.dirs/ and /lib/
|
||||||
if (!/^(\..*|lib)$/.test(fn)) {
|
if (!/^(\..*|lib|icons)$/.test(fn)) {
|
||||||
loadNodes(dir+"/"+fn);
|
loadNodes(dir+"/"+fn);
|
||||||
|
} else if (fn === "icons") {
|
||||||
|
events.emit("node-icon-dir",dir+"/"+fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,7 @@ var fs = require('fs');
|
|||||||
var util = require('util');
|
var util = require('util');
|
||||||
var createUI = require("./ui");
|
var createUI = require("./ui");
|
||||||
var redNodes = require("./nodes");
|
var redNodes = require("./nodes");
|
||||||
|
|
||||||
//TODO: relocated user dir
|
//TODO: relocated user dir
|
||||||
|
|
||||||
var flowfile = '';
|
var flowfile = '';
|
||||||
@ -74,6 +75,7 @@ function createServer(_server,settings) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
console.log("\nWelcome to Node-RED\n===================\n");
|
console.log("\nWelcome to Node-RED\n===================\n");
|
||||||
util.log("[red] Loading palette nodes");
|
util.log("[red] Loading palette nodes");
|
||||||
|
26
red/ui.js
26
red/ui.js
@ -18,7 +18,17 @@ var util = require('util');
|
|||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var app = express();
|
var app = express();
|
||||||
|
var events = require("./events");
|
||||||
|
var path = require("path");
|
||||||
|
|
||||||
|
var icon_paths = [path.resolve(__dirname + '/../public/icons')];
|
||||||
|
|
||||||
|
events.on("node-icon-dir",function(dir) {
|
||||||
|
icon_paths.push(path.resolve(dir));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: nothing here uses settings... so does this need to be a function?
|
||||||
function setupUI(settings) {
|
function setupUI(settings) {
|
||||||
|
|
||||||
// Need to ensure the url ends with a '/' so the static serving works
|
// Need to ensure the url ends with a '/' so the static serving works
|
||||||
@ -31,10 +41,26 @@ function setupUI(settings) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/icons/:icon",function(req,res) {
|
||||||
|
for (var p in icon_paths) {
|
||||||
|
if (fs.existsSync(icon_paths[p]+'/'+req.params.icon)) {
|
||||||
|
res.sendfile(icon_paths[p]+'/'+req.params.icon);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//TODO: create a default icon
|
||||||
|
res.sendfile(path.resolve(__dirname + '/../public/icons/arrow-in.png'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
app.use("/",express.static(__dirname + '/../public'));
|
app.use("/",express.static(__dirname + '/../public'));
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = setupUI;
|
module.exports = setupUI;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user