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

Move version number as title of NR logo

This commit is contained in:
Nick O'Leary 2016-01-08 13:36:49 +00:00
parent e873afd40b
commit 70f3e72a20
6 changed files with 105 additions and 104 deletions

View File

@ -104,7 +104,6 @@ RED.settings = (function () {
RED.settings.remove("auth-tokens"); RED.settings.remove("auth-tokens");
} }
console.log("Node-RED: " + data.version); console.log("Node-RED: " + data.version);
$('#node-red-version').text("v"+data.version);
done(); done();
}, },
error: function(jqXHR,textStatus,errorThrown) { error: function(jqXHR,textStatus,errorThrown) {

View File

@ -111,8 +111,3 @@ pre code {
background-color: transparent; background-color: transparent;
border: 0; border: 0;
} }
#node-red-version {
font-size: 0.8em;
color: #bbb;
}

View File

@ -35,7 +35,7 @@
</head> </head>
<body spellcheck="false"> <body spellcheck="false">
<div id="header"> <div id="header">
<span class="logo">{{#header.url}}<a href="{{.}}">{{/header.url}}{{#header.image}}<img src="{{.}}">{{/header.image}} <span>{{ header.title }}</span>{{#header.url}}</a>{{/header.url}}</span> <span class="logo">{{#header.url}}<a href="{{.}}">{{/header.url}}{{#header.image}}<img src="{{.}}" title="{{version}}">{{/header.image}} <span>{{ header.title }}</span>{{#header.url}}</a>{{/header.url}}</span>
<ul class="header-toolbar hide"> <ul class="header-toolbar hide">
<li><a id="btn-sidemenu" class="button" data-toggle="dropdown" href="#"><i class="fa fa-bars"></i></a></li> <li><a id="btn-sidemenu" class="button" data-toggle="dropdown" href="#"><i class="fa fa-bars"></i></a></li>
<ul> <ul>
@ -68,7 +68,7 @@
<div id="sidebar"> <div id="sidebar">
<ul id="sidebar-tabs"></ul> <ul id="sidebar-tabs"></ul>
<div id="sidebar-content"></div> <div id="sidebar-content"></div>
<div id="sidebar-footer"><span id="node-red-version"></span></div> <div id="sidebar-footer"></div>
</div> </div>
<div id="sidebar-separator"></div> <div id="sidebar-separator"></div>

View File

@ -42,7 +42,6 @@ var nodeApp;
var server; var server;
var errorHandler = function(err,req,res,next) { var errorHandler = function(err,req,res,next) {
console.log("HERE I AM");
if (err.message === "request entity too large") { if (err.message === "request entity too large") {
log.error(err); log.error(err);
} else { } else {
@ -78,8 +77,9 @@ function init(_server,runtime) {
var editorApp = express(); var editorApp = express();
editorApp.get("/",ui.ensureSlash,ui.editor); editorApp.get("/",ui.ensureSlash,ui.editor);
editorApp.get("/icons/:icon",ui.icon); editorApp.get("/icons/:icon",ui.icon);
theme.init(runtime);
if (settings.editorTheme) { if (settings.editorTheme) {
editorApp.use("/theme",theme.init(runtime)); editorApp.use("/theme",theme.app());
} }
editorApp.use("/",ui.editorResources); editorApp.use("/",ui.editorResources);
adminApp.use(editorApp); adminApp.use(editorApp);

View File

@ -34,6 +34,7 @@ var defaultContext = {
} }
}; };
var theme = null;
var themeContext = clone(defaultContext); var themeContext = clone(defaultContext);
var themeSettings = null; var themeSettings = null;
@ -58,98 +59,102 @@ module.exports = {
var i; var i;
var url; var url;
themeContext = clone(defaultContext); themeContext = clone(defaultContext);
themeSettings = null; if (runtime.version) {
themeContext.version = runtime.version();
if (settings.editorTheme) {
var theme = settings.editorTheme;
themeSettings = {};
var themeApp = express();
if (theme.page) {
if (theme.page.css) {
var styles = theme.page.css;
if (!util.isArray(styles)) {
styles = [styles];
}
themeContext.page.css = [];
for (i=0;i<styles.length;i++) {
url = serveFile(themeApp,"/css/",styles[i]);
if (url) {
themeContext.page.css.push(url);
}
}
}
if (theme.page.favicon) {
url = serveFile(themeApp,"/favicon/",theme.page.favicon)
if (url) {
themeContext.page.favicon = url;
}
}
themeContext.page.title = theme.page.title || themeContext.page.title;
}
if (theme.header) {
themeContext.header.title = theme.header.title || themeContext.header.title;
if (theme.header.hasOwnProperty("url")) {
themeContext.header.url = theme.header.url;
}
if (theme.header.hasOwnProperty("image")) {
if (theme.header.image) {
url = serveFile(themeApp,"/header/",theme.header.image);
if (url) {
themeContext.header.image = url;
}
} else {
themeContext.header.image = null;
}
}
}
if (theme.deployButton) {
if (theme.deployButton.type == "simple") {
themeSettings.deployButton = {
type: "simple"
}
if (theme.deployButton.label) {
themeSettings.deployButton.label = theme.deployButton.label;
}
if (theme.deployButton.icon) {
url = serveFile(themeApp,"/deploy/",theme.deployButton.icon);
if (url) {
themeSettings.deployButton.icon = url;
}
}
}
}
if (theme.hasOwnProperty("userMenu")) {
themeSettings.userMenu = theme.userMenu;
}
if (theme.login) {
if (theme.login.image) {
url = serveFile(themeApp,"/login/",theme.login.image);
if (url) {
themeContext.login = {
image: url
}
}
}
}
if (theme.hasOwnProperty("menu")) {
themeSettings.menu = theme.menu;
}
return themeApp;
} }
themeSettings = null;
theme = settings.editorTheme;
},
app: function() {
themeSettings = {};
var themeApp = express();
if (theme.page) {
if (theme.page.css) {
var styles = theme.page.css;
if (!util.isArray(styles)) {
styles = [styles];
}
themeContext.page.css = [];
for (i=0;i<styles.length;i++) {
url = serveFile(themeApp,"/css/",styles[i]);
if (url) {
themeContext.page.css.push(url);
}
}
}
if (theme.page.favicon) {
url = serveFile(themeApp,"/favicon/",theme.page.favicon)
if (url) {
themeContext.page.favicon = url;
}
}
themeContext.page.title = theme.page.title || themeContext.page.title;
}
if (theme.header) {
themeContext.header.title = theme.header.title || themeContext.header.title;
if (theme.header.hasOwnProperty("url")) {
themeContext.header.url = theme.header.url;
}
if (theme.header.hasOwnProperty("image")) {
if (theme.header.image) {
url = serveFile(themeApp,"/header/",theme.header.image);
if (url) {
themeContext.header.image = url;
}
} else {
themeContext.header.image = null;
}
}
}
if (theme.deployButton) {
if (theme.deployButton.type == "simple") {
themeSettings.deployButton = {
type: "simple"
}
if (theme.deployButton.label) {
themeSettings.deployButton.label = theme.deployButton.label;
}
if (theme.deployButton.icon) {
url = serveFile(themeApp,"/deploy/",theme.deployButton.icon);
if (url) {
themeSettings.deployButton.icon = url;
}
}
}
}
if (theme.hasOwnProperty("userMenu")) {
themeSettings.userMenu = theme.userMenu;
}
if (theme.login) {
if (theme.login.image) {
url = serveFile(themeApp,"/login/",theme.login.image);
if (url) {
themeContext.login = {
image: url
}
}
}
}
if (theme.hasOwnProperty("menu")) {
themeSettings.menu = theme.menu;
}
return themeApp;
}, },
context: function() { context: function() {
return themeContext; return themeContext;

View File

@ -34,7 +34,7 @@ describe("theme handler", function() {
fs.statSync.restore(); fs.statSync.restore();
}); });
it("applies the default theme", function() { it("applies the default theme", function() {
var result = theme.init({settings:{}}); var result = theme.init({settings:{},version:function() { return '123.456'}});
should.not.exist(result); should.not.exist(result);
var context = theme.context(); var context = theme.context();
@ -44,12 +44,13 @@ describe("theme handler", function() {
context.should.have.a.property("header"); context.should.have.a.property("header");
context.header.should.have.a.property("title","Node-RED"); context.header.should.have.a.property("title","Node-RED");
context.header.should.have.a.property("image","red/images/node-red.png"); context.header.should.have.a.property("image","red/images/node-red.png");
context.should.have.a.property("version","123.456");
should.not.exist(theme.settings()); should.not.exist(theme.settings());
}); });
it("picks up custom theme", function() { it("picks up custom theme", function() {
var result = theme.init({settings:{ theme.init({settings:{
editorTheme: { editorTheme: {
page: { page: {
title: "Test Page Title", title: "Test Page Title",
@ -84,8 +85,9 @@ describe("theme handler", function() {
} }
} }
}}); }});
should.exist(result);
theme.app();
var context = theme.context(); var context = theme.context();
context.should.have.a.property("page"); context.should.have.a.property("page");
context.page.should.have.a.property("title","Test Page Title"); context.page.should.have.a.property("title","Test Page Title");