Do not statically serve the index template prior to rendering it

Without this, going to `https://thelounge.example.com/index.html` would return the raw file. This now excludes it from the `public` folder so it cannot be rendered as is.
Renaming the file is for good measure, to indicate that this HTML file must be templated. Because it is a straight rename with no modification, rebasing PRs on it should not be to painful, as git re-applies changes on renamed files.
This commit is contained in:
Jérémie Astori 2018-01-13 19:46:59 -05:00
parent 7a691b8e6c
commit 33d82287be
No known key found for this signature in database
GPG key ID: B9A4F245CD67BDE8
5 changed files with 7 additions and 4 deletions

View file

@ -11,6 +11,7 @@
client/**
!client/js/libs/handlebars/ircmessageparser/findLinks.js
!client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js
!client/index.html.tpl
public/js/bundle.vendor.js.map
coverage/

View file

@ -251,7 +251,7 @@ function index(req, res, next) {
res.setHeader("Content-Security-Policy", policies.join("; "));
res.setHeader("Referrer-Policy", "no-referrer");
return fs.readFile(path.join(__dirname, "..", "public", "index.html"), "utf-8", (err, file) => {
return fs.readFile(path.join(__dirname, "..", "client", "index.html.tpl"), "utf-8", (err, file) => {
if (err) {
throw err;
}

View file

@ -12,8 +12,9 @@ describe("public folder", function() {
expect(fs.existsSync(path.join(publicFolder, "fonts", "fontawesome-webfont.woff2"))).to.be.true;
});
it("index.html is copied", function() {
expect(fs.existsSync(path.join(publicFolder, "index.html"))).to.be.true;
it("index HTML file is not copied", function() {
expect(fs.existsSync(path.join(publicFolder, "index.html"))).to.be.false;
expect(fs.existsSync(path.join(publicFolder, "index.html.tpl"))).to.be.false;
});
it("javascript files are built", function() {

View file

@ -70,9 +70,10 @@ const config = {
from: "./client/js/loading-error-handlers.js",
to: "js/[name].[ext]",
},
{ // TODO: Build index.html with handlebars
{
from: "./client/*",
to: "[name].[ext]",
ignore: "index.html.tpl",
},
{
from: "./client/audio/*",