Remove express-handlebars, read manifest.json to get theme-color

This commit is contained in:
Pavel Djundik 2017-11-12 20:24:21 +02:00
parent c30f4aaaeb
commit e86a155ec2
4 changed files with 19 additions and 16 deletions

View File

@ -9,23 +9,23 @@
<link rel="preload" as="script" href="js/bundle.js"> <link rel="preload" as="script" href="js/bundle.js">
<link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/style.css">
<link id="theme" rel="stylesheet" href="{{ theme }}"> <link id="theme" rel="stylesheet" href="<%- theme %>">
<style id="user-specified-css"></style> <style id="user-specified-css"></style>
<title>The Lounge</title> <title>The Lounge</title>
<link rel="shortcut icon" href="img/favicon.png" data-other="img/favicon-notification.png" data-toggled="false" id="favicon"> <link rel="shortcut icon" href="img/favicon.png" data-other="img/favicon-notification.png" data-toggled="false" id="favicon">
<link rel="apple-touch-icon" sizes="120x120" href="img/apple-touch-icon-120x120.png"> <link rel="apple-touch-icon" sizes="120x120" href="img/apple-touch-icon-120x120.png">
<link rel="mask-icon" href="img/logo.svg" color="#455164"> <link rel="mask-icon" href="img/logo.svg" color="<%- themeColor %>">
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#455164"> <meta name="theme-color" content="<%- themeColor %>">
</head> </head>
<body class="signed-out {{#if public}}public{{/if}}" data-transports="{{tojson transports}}"> <body class="signed-out<%- public ? " public" : "" %>" data-transports="<%- JSON.stringify(transports) %>">
<div id="wrap"> <div id="wrap">
<div id="viewport"> <div id="viewport">

View File

@ -43,7 +43,6 @@
"colors": "1.1.2", "colors": "1.1.2",
"commander": "2.11.0", "commander": "2.11.0",
"express": "4.16.2", "express": "4.16.2",
"express-handlebars": "3.0.0",
"fs-extra": "4.0.2", "fs-extra": "4.0.2",
"irc-framework": "2.9.1", "irc-framework": "2.9.1",
"ldapjs": "1.0.1", "ldapjs": "1.0.1",

View File

@ -78,6 +78,10 @@ function setHome(homePath) {
log.warn(`${colors.bold("displayNetwork")} and ${colors.bold("lockNetwork")} are false, setting ${colors.bold("lockNetwork")} to true.`); log.warn(`${colors.bold("displayNetwork")} and ${colors.bold("lockNetwork")} are false, setting ${colors.bold("lockNetwork")} to true.`);
} }
// Load theme color from manifest.json
const manifest = require("../public/manifest.json");
this.config.themeColor = manifest.theme_color;
// TODO: Remove in future release // TODO: Remove in future release
if (this.config.debug === true) { if (this.config.debug === true) {
log.warn("debug option is now an object, see defaults file for more information."); log.warn("debug option is now an object, see defaults file for more information.");

View File

@ -5,7 +5,6 @@ var pkg = require("../package.json");
var Client = require("./client"); var Client = require("./client");
var ClientManager = require("./clientManager"); var ClientManager = require("./clientManager");
var express = require("express"); var express = require("express");
var expressHandlebars = require("express-handlebars");
var fs = require("fs"); var fs = require("fs");
var path = require("path"); var path = require("path");
var io = require("socket.io"); var io = require("socket.io");
@ -39,21 +38,14 @@ module.exports = function() {
} }
var app = express() var app = express()
.disable("x-powered-by")
.use(allRequests) .use(allRequests)
.use(index) .use(index)
.use(express.static("public")) .use(express.static("public"))
.use("/storage/", express.static(Helper.getStoragePath(), { .use("/storage/", express.static(Helper.getStoragePath(), {
redirect: false, redirect: false,
maxAge: 86400 * 1000, maxAge: 86400 * 1000,
})) }));
.engine("html", expressHandlebars({
extname: ".html",
helpers: {
tojson: (c) => JSON.stringify(c),
},
}))
.set("view engine", "html")
.set("views", path.join(__dirname, "..", "public"));
app.get("/themes/:theme.css", (req, res) => { app.get("/themes/:theme.css", (req, res) => {
const themeName = req.params.theme; const themeName = req.params.theme;
@ -221,9 +213,17 @@ function index(req, res, next) {
policies.unshift("block-all-mixed-content"); policies.unshift("block-all-mixed-content");
} }
res.setHeader("Content-Type", "text/html");
res.setHeader("Content-Security-Policy", policies.join("; ")); res.setHeader("Content-Security-Policy", policies.join("; "));
res.setHeader("Referrer-Policy", "no-referrer"); res.setHeader("Referrer-Policy", "no-referrer");
res.render("index", Helper.config);
return fs.readFile(path.join(__dirname, "..", "public", "index.html"), "utf-8", (err, file) => {
if (err) {
throw err;
}
res.send(_.template(file)(Helper.config));
});
} }
function initializeClient(socket, client, token, lastMessage) { function initializeClient(socket, client, token, lastMessage) {