parent
4e90431a3d
commit
388835b85f
@ -1,12 +1,13 @@
|
||||
<div class="footer">
|
||||
<% if (user){ %>
|
||||
<a onclick="invert()" class="btn-primary" style="color:white;"><%=(user.theme === "default" ? "black" : "default" ) + " theme!" %></a>
|
||||
<a onclick="invert()" class="btn-primary" style="color:white;"><%=(user.theme.color === "default" ? "black" : "default" ) + " theme!" %></a>
|
||||
<script>
|
||||
async function invert() {
|
||||
return alert("disabled!")
|
||||
await fetch('/api/users/<%= user.id %>', {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({
|
||||
theme: "<%= user.theme === `default` ? `black` : `default` %>"
|
||||
theme: {color:"<%= user.theme.color === `default` ? `black` : `default` %>"}
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
@ -0,0 +1,22 @@
|
||||
const path = require('path');
|
||||
module.exports = {
|
||||
name: "default",
|
||||
colors: ["black", "white"],
|
||||
languages: ["en"],
|
||||
getFilePath(page) {
|
||||
return path.resolve(__dirname, page) ;// path of the file for ejs rendering
|
||||
},
|
||||
/**
|
||||
* Renderer function for theme
|
||||
* @param {String} file a page of forum
|
||||
* @param {{ user: Object }} data informations about page
|
||||
* @param {{ color: String, forum_name:String, description:String }} options Extra options
|
||||
* @param {Object} render request object
|
||||
*/
|
||||
render(file, data, options, req) {
|
||||
// const { color, language, forum_name, description } = options; // General informations, meta, forum name, user language and color
|
||||
// const { user } = data; // specific informations about page, user (req.user || null), and more
|
||||
|
||||
return req.render(this.getFilePath(file), { ...options, ...data });
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
const fs = require("fs");
|
||||
|
||||
for (const theme of fs.readdirSync("./themes")) {
|
||||
if (theme === "index.js") continue;
|
||||
module.exports[theme] = require(`./${theme}`);
|
||||
}
|
Loading…
Reference in new issue