Rename manifest.json to thelounge.webmanifest

This makes express serve it with correct content-type of application/manifest+json

Refs:
- https://w3c.github.io/manifest/#media-type-registration
- https://webhint.io/docs/user-guide/hints/hint-manifest-file-extension/
This commit is contained in:
Pavel Djundik 2018-11-13 13:21:19 +02:00
parent eb522e9208
commit e033010841
5 changed files with 13 additions and 17 deletions

View File

@ -24,7 +24,7 @@
<!-- Safari pinned tab icon --> <!-- Safari pinned tab icon -->
<link rel="mask-icon" href="img/icon-black-transparent-bg.svg" color="#415363"> <link rel="mask-icon" href="img/icon-black-transparent-bg.svg" color="#415363">
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="thelounge.webmanifest">
<!-- iPhone 4, iPhone 4s, iPhone 5, iPhone 5c, iPhone 5s, iPhone 6, iPhone 6s, iPhone 7, iPhone 7s, iPhone8 --> <!-- iPhone 4, iPhone 4s, iPhone 5, iPhone 5c, iPhone 5s, iPhone 6, iPhone 6s, iPhone 7, iPhone 7s, iPhone8 -->
<link rel="apple-touch-icon" sizes="120x120" href="img/logo-grey-bg-120x120px.png"> <link rel="apple-touch-icon" sizes="120x120" href="img/logo-grey-bg-120x120px.png">

View File

@ -5,7 +5,6 @@ const log = require("../log");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const program = require("commander"); const program = require("commander");
const colors = require("chalk");
const Helper = require("../helper"); const Helper = require("../helper");
const Utils = require("./utils"); const Utils = require("./utils");
@ -20,18 +19,6 @@ program.version(Helper.getVersion(), "-v, --version")
// Parse options from `argv` returning `argv` void of these options. // Parse options from `argv` returning `argv` void of these options.
const argvWithoutOptions = program.parseOptions(process.argv); const argvWithoutOptions = program.parseOptions(process.argv);
// Check if the app was built before calling setHome as it wants to load manifest.json from the public folder
if (!fs.existsSync(path.join(
__dirname,
"..",
"..",
"public",
"manifest.json"
))) {
log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production yarn build")} to resolve this.`);
process.exit(1);
}
Helper.setHome(process.env.THELOUNGE_HOME || Utils.defaultHome()); Helper.setHome(process.env.THELOUNGE_HOME || Utils.defaultHome());
// Check config file owner and warn if we're running under a different user // Check config file owner and warn if we're running under a different user

View File

@ -117,8 +117,16 @@ function setHome(newPath) {
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 manifestPath = path.resolve(path.join(__dirname, "..", "public", "thelounge.webmanifest"));
const manifest = require("../public/manifest.json");
// Check if manifest exists, if not, the app most likely was not built
if (!fs.existsSync(manifestPath)) {
log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production yarn build")} to resolve this.`);
process.exit(1);
}
// Load theme color from the web manifest
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
this.config.themeColor = manifest.theme_color; this.config.themeColor = manifest.theme_color;
// TODO: Remove in future release // TODO: Remove in future release

View File

@ -41,11 +41,12 @@ describe("Server", function() {
}); });
it("should serve static content correctly", (done) => { it("should serve static content correctly", (done) => {
request(webURL + "manifest.json", (error, response, body) => { request(webURL + "thelounge.webmanifest", (error, response, body) => {
expect(error).to.be.null; expect(error).to.be.null;
body = JSON.parse(body); body = JSON.parse(body);
expect(body.name).to.equal("The Lounge"); expect(body.name).to.equal("The Lounge");
expect(response.headers["content-type"]).to.equal("application/manifest+json");
done(); done();
}); });