Add current themes #2

Merged
julian-CStack merged 11 commits from staging into main 2023-05-11 16:04:37 +00:00
6 changed files with 43 additions and 44 deletions
Showing only changes of commit de48998475 - Show all commits

View File

@ -1,20 +1,40 @@
{
"themes": {
"dark" : {
"themes": [
{
"name": "Chan",
"id": "chan"
},
{
"name": "Chan Dark",
"id": "chan_dark"
},
{
"name": "Dark",
"id": "dark",
"description": "Dark",
"primary_color": "0xFF2A2D34",
"secondary_color": "0xFF4C86E9",
"tertiary_color": "0xFFFFFFFF",
"background": "0xFF2A2D34",
"overlay": "0xFF111215",
"accentColorBlue": "0xFF4C86E9",
"accentColorGreen": "0xFF4CC0A0",
"accentColorYellow": "0xFFF7D65D",
"accentColorRed": "0xFFD34E50",
"accentColorOrange": "0xFFFEA68D",
"accentColorDark": "0xFFF3F3F3"
"id": "dark"
},
{
"name": "Forest",
"id": "forest"
},
{
"name": "Fruit Sorbet",
"id": "fruit_sorbet"
},
{
"name": "Light",
"id": "light"
},
{
"name": "Ocean Breeze",
"id": "ocean_breeze"
},
{
"name": "OLED Black",
"id": "oled_black"
},
{
"name": "Orange",
"id": "orange"
}
}
]
}

BIN
data/themes/dark.zip Normal file

Binary file not shown.

BIN
data/themes/light.zip Normal file

Binary file not shown.

View File

@ -1,15 +1,7 @@
function getThemeDetails(id : string) {
const fs = require("fs");
const json_file = fs.readFileSync("data/themes.json");
const json = JSON.parse(json_file);
const themes = json.themes;
var theme = {};
Object.entries(themes).map(([key, value]) => {
if (key == id){
theme = (themes[key])
}
});
return theme
const theme_file = fs.readFileSync("data/themes/" + id + ".zip");
return theme_file;
}
module.exports = getThemeDetails;

View File

@ -3,20 +3,7 @@ function getThemeList() {
const json_file = fs.readFileSync("data/themes.json");
const json = JSON.parse(json_file);
const themes = json.themes;
var themeArray : Array<Object> = [];
// For loop that will look for all the themes in the themes.json file
Object.entries(themes).map(([key, value]) => {
var theme : Object = {
"name": themes[key].name,
"id": themes[key].id,
"description": themes[key].description,
"primary_color": themes[key].primary_color, // Primary color is background color in the theme
"secondary_color": themes[key].secondary_color, // Secondary color is the color of the buttonBackPrimary in the theme
"tertiary_color": themes[key].tertiary_color, // Tertiary color is the color of the buttonTextPrimary in the theme
}
themeArray.push(theme);
})
return themeArray;
return themes;
}
module.exports = getThemeList;

View File

@ -9,16 +9,16 @@ function startServer(port : number) {
app.use(cors());
var themeListReqCounter = 0;
app.get("/themelist", (req : any, res : any) => {
app.get("/themes", (req : any, res : any) => {
themeListReqCounter++;
console.log("Got request on /themelist, request number " + themeListReqCounter)
console.log("Got request on /themes, request number " + themeListReqCounter)
res.send(getThemeList());
});
var themeDetailsReqCounter = 0;
app.get("/themedetails/:id", (req : any, res : any) => {
app.get("/theme/:id", (req : any, res : any) => {
themeDetailsReqCounter++;
console.log("Got request on /themedetails/" + req.params.id + ", request number " + themeDetailsReqCounter)
console.log("Got request on /theme/" + req.params.id + ", request number " + themeDetailsReqCounter)
res.send(getThemeDetails(req.params.id));
});