diff --git a/src/lib/constants.js b/src/lib/constants.js index 9955b86..a873ef4 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -68,8 +68,20 @@ let constants = { feed_disabled_max_age: 2*24*60*60 // 2 days }, + // Enabled themes. `file` is the filename without extension. `name` is the display name on the settings page. + // If you make your own theme, I encourage you to submit a pull request for it! + themes: [ + {file: "classic", name: "Classic"}, + {file: "blue", name: "Classic blue"} + ], + user_settings: [ { + name: "theme", + default: "classic", + boolean: false, + replaceEmptyWithDefault: true + },{ name: "language", default: "en", boolean: false, @@ -89,11 +101,6 @@ let constants = { default: "on", boolean: true, replaceEmptyWithDefault: false - },{ - name: "theme", - default: "classic", - boolean: false, - replaceEmptyWithDefault: true },{ name: "caption_side", default: "left", diff --git a/src/site/api/settings.js b/src/site/api/settings.js index e84c444..d5205a2 100644 --- a/src/site/api/settings.js +++ b/src/site/api/settings.js @@ -10,7 +10,7 @@ module.exports = [ const settings = getSettings(req) // console.log(settings) const saved = url.searchParams.has("saved") - return render(200, "pug/settings.pug", {saved, settings}) + return render(200, "pug/settings.pug", {saved, constants, settings}) } }, { diff --git a/src/site/pug/settings.pug b/src/site/pug/settings.pug index 0dd02fb..11c3bda 100644 --- a/src/site/pug/settings.pug +++ b/src/site/pug/settings.pug @@ -63,10 +63,7 @@ html +checkbox("spa", "Fast navigation", "Enabled", false) +fieldset("Appearance") - +select("theme", "Theme", false, [ - {value: "classic", text: "Classic"}, - {value: "blue", text: "Classic blue"} - ]) + +select("theme", "Theme", false, constants.themes.map(entry => ({value: entry.file, text: entry.name}))) +checkbox("display_top_nav", "Display top bar", "Always", false) diff --git a/src/site/server.js b/src/site/server.js index ca69801..fb20682 100644 --- a/src/site/server.js +++ b/src/site/server.js @@ -21,8 +21,9 @@ subdirs("pug", async (err, dirs) => { await require("../lib/utils/upgradedb")() pinski.setNotFoundTarget("/404") - pinski.addRoute("/static/css/classic.css", "sass/classic.sass", "sass") - pinski.addRoute("/static/css/blue.css", "sass/blue.sass", "sass") + for (const theme of constants.themes) { + pinski.addRoute(`/static/css/${theme.file}.css`, `sass/${theme.file}.sass`, "sass") + } pinski.addRoute("/settings", "pug/settings.pug", "pug") pinski.addPugDir("pug", dirs) pinski.addSassDir("sass", ["sass/includes", "sass/themes"])