Merge pull request #343 from nickwynja/theme-config

Load theme using existing config mechanisms
This commit is contained in:
Christian Bundy 2020-03-24 11:25:27 -07:00 committed by GitHub
commit 519fc499ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -43,4 +43,9 @@ module.exports = (presets, defaultConfigFile) =>
default: _.get(presets, "debug", false),
type: "boolean"
})
.options("theme", {
describe: "The theme to use, if a theme hasn't been set in the cookies",
default: _.get(presets, "theme", "atelier-sulphurPool-light"),
type: "string"
})
.epilog(`The defaults can be configured in ${defaultConfigFile}.`).argv;

View File

@ -173,8 +173,6 @@ try {
// Optional dependency
}
const defaultTheme = "atelier-sulphurPool-light".toLowerCase();
const readmePath = path.join(__dirname, "..", "README.md");
const packagePath = path.join(__dirname, "..", "package.json");
@ -320,7 +318,7 @@ router
ctx.body = await hashtagView({ hashtag, messages });
})
.get("/theme.css", ctx => {
const theme = ctx.cookies.get("theme") || defaultTheme;
const theme = ctx.cookies.get("theme") || config.theme;
const packageName = "@fraction/base16-css";
const filePath = `${packageName}/src/base16-${theme}.css`;
@ -500,7 +498,7 @@ router
ctx.body = await image({ blobId, imageSize: Number(imageSize) });
})
.get("/settings/", async ctx => {
const theme = ctx.cookies.get("theme") || defaultTheme;
const theme = ctx.cookies.get("theme") || config.theme;
const getMeta = async ({ theme }) => {
const status = await meta.status();
const peers = await meta.peers();

View File

@ -125,7 +125,7 @@ module.exports = {
],
theme: "Theme",
themeIntro:
"Choose from any theme you'd like. The default theme is Atelier-SulphurPool-Light.",
"Choose from any theme you'd like. The default theme is Atelier-SulphurPool-Light. You can also set your theme in the default configuration file.",
setTheme: "Set theme",
language: "Language",
languageDescription: