diff --git a/data/themes.json b/data/themes.json index c027b47..e3cc583 100644 --- a/data/themes.json +++ b/data/themes.json @@ -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" } - } + ] } \ No newline at end of file diff --git a/data/themes/dark.zip b/data/themes/dark.zip new file mode 100644 index 0000000..96aeb98 Binary files /dev/null and b/data/themes/dark.zip differ diff --git a/data/themes/light.zip b/data/themes/light.zip new file mode 100644 index 0000000..3cb2873 Binary files /dev/null and b/data/themes/light.zip differ diff --git a/src/getThemeDetails.ts b/src/getThemeDetails.ts index a4435f1..604b680 100644 --- a/src/getThemeDetails.ts +++ b/src/getThemeDetails.ts @@ -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; \ No newline at end of file diff --git a/src/getThemeList.ts b/src/getThemeList.ts index b0fcd82..6c9375e 100644 --- a/src/getThemeList.ts +++ b/src/getThemeList.ts @@ -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 = []; - // 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; \ No newline at end of file diff --git a/src/themeServer.ts b/src/themeServer.ts index e5f0590..97f4839 100644 --- a/src/themeServer.ts +++ b/src/themeServer.ts @@ -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)); });