diff --git a/.gitignore b/.gitignore index 48912d2..18d31cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build -node_modules \ No newline at end of file +node_modules +.idea \ No newline at end of file diff --git a/data/previews/chan-theme.png b/data/previews/chan-theme.png new file mode 100644 index 0000000..8f5f936 Binary files /dev/null and b/data/previews/chan-theme.png differ diff --git a/data/previews/dark-theme.png b/data/previews/dark-theme.png new file mode 100644 index 0000000..7d38780 Binary files /dev/null and b/data/previews/dark-theme.png differ diff --git a/data/previews/darkchans-theme.png b/data/previews/darkchans-theme.png new file mode 100644 index 0000000..ff80823 Binary files /dev/null and b/data/previews/darkchans-theme.png differ diff --git a/data/previews/forest-theme.png b/data/previews/forest-theme.png new file mode 100644 index 0000000..f8dbd50 Binary files /dev/null and b/data/previews/forest-theme.png differ diff --git a/data/previews/fruit-sorbet.png b/data/previews/fruit-sorbet.png new file mode 100644 index 0000000..7e31ca4 Binary files /dev/null and b/data/previews/fruit-sorbet.png differ diff --git a/data/previews/ocean-breeze.png b/data/previews/ocean-breeze.png new file mode 100644 index 0000000..7388aa5 Binary files /dev/null and b/data/previews/ocean-breeze.png differ diff --git a/data/previews/orange-dark-theme.png b/data/previews/orange-dark-theme.png new file mode 100644 index 0000000..9de5f34 Binary files /dev/null and b/data/previews/orange-dark-theme.png differ diff --git a/data/previews/orange-theme.png b/data/previews/orange-theme.png new file mode 100644 index 0000000..a667270 Binary files /dev/null and b/data/previews/orange-theme.png differ diff --git a/data/themes.json b/data/themes.json index c027b47..1ac5602 100644 --- a/data/themes.json +++ b/data/themes.json @@ -1,20 +1,67 @@ { - "themes": { - "dark" : { + "themes": [ + { + "name": "Chan", + "id": "chan", + "sha256": "b252dc551c292fb70984e05f48758547ffd417185c7eb810d4eae42ae94b7fe3", + "size": "61.8 MB", + "previewImageUrl": "https://themes.stackwallet.com/previews/chan-theme.png" + }, + { + "name": "Chan Dark", + "id": "dark_chan", + "sha256": "0d599eae5200c02df42e45cfa1bc016f6e2d8a5fa771e54c08a59cb4d1f8d2c3", + "size": "61.8 MB", + "previewImageUrl": "https://themes.stackwallet.com/previews/darkchans-theme.png" + }, + { "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" + "sha256": "12699563c238b04af9576ffdf6c3e57587fa697faf860f3792fcecd45d3178ac", + "size": "475.8 kB", + "previewImageUrl": "https://themes.stackwallet.com/previews/dark-theme.png" + }, + { + "name": "Forest", + "id": "forest", + "sha256": "23c72db0989efe705a77a46d60e60252ae8a49df5b5774896a0f3f6c6fdc3c4f", + "size": "762.7 kB", + "previewImageUrl": "https://themes.stackwallet.com/previews/forest-theme.png" + }, + { + "name": "Fruit Sorbet", + "id": "fruit_sorbet", + "sha256": "053b434ab6ba79d2e113aa484eb73e0bc2439c22a62e56d8edf25dd5edc2970c", + "size": "582.9 kB", + "previewImageUrl": "https://themes.stackwallet.com/previews/fruit-sorbet.png" + }, + { + "name": "Light", + "id": "light", + "sha256": "0e17e6caccf4b0561786f6cd59c94777157ee4570ec7b83a2fc7a3720a291d7f", + "size": "474.9 kB", + "previewImageUrl": "" + }, + { + "name": "Ocean Breeze", + "id": "ocean_breeze", + "sha256": "f9e64cf9855d4dd22201b7686ffc68936b500b034527f0d0006f1dbc8f5a6472", + "size": "2.8 MB", + "previewImageUrl": "https://themes.stackwallet.com/previews/ocean-breeze.png" + }, + { + "name": "OLED Black", + "id": "oled_black", + "sha256": "d6201c3374ca52a0ffeddb5425b5b2f3d6c1c23efe9da17b342061b212fdb0bf", + "size": "476.4 kB", + "previewImageUrl": "https://themes.stackwallet.com/previews/orange-dark-theme.png" + }, + { + "name": "Orange", + "id": "orange", + "sha256": "0f5d749b2a5285564c2a7f7a1d6b4fbf633144745f16098aeccf5689cccdd38c", + "size": "107.6 kB", + "previewImageUrl": "https://themes.stackwallet.com/previews/orange-theme.png" } - } + ] } \ No newline at end of file diff --git a/data/themes/chan.zip b/data/themes/chan.zip new file mode 100644 index 0000000..30e4ea2 Binary files /dev/null and b/data/themes/chan.zip differ diff --git a/data/themes/chan_dark.zip b/data/themes/chan_dark.zip new file mode 100644 index 0000000..7f32722 Binary files /dev/null and b/data/themes/chan_dark.zip differ 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/forest.zip b/data/themes/forest.zip new file mode 100644 index 0000000..b545f23 Binary files /dev/null and b/data/themes/forest.zip differ diff --git a/data/themes/fruit_sorbet.zip b/data/themes/fruit_sorbet.zip new file mode 100644 index 0000000..e97e29a Binary files /dev/null and b/data/themes/fruit_sorbet.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/data/themes/ocean_breeze.zip b/data/themes/ocean_breeze.zip new file mode 100644 index 0000000..9ce2fd7 Binary files /dev/null and b/data/themes/ocean_breeze.zip differ diff --git a/data/themes/oled_black.zip b/data/themes/oled_black.zip new file mode 100644 index 0000000..c9d9bae Binary files /dev/null and b/data/themes/oled_black.zip differ diff --git a/data/themes/orange.zip b/data/themes/orange.zip new file mode 100644 index 0000000..2460f9b Binary files /dev/null and b/data/themes/orange.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..1210352 100644 --- a/src/themeServer.ts +++ b/src/themeServer.ts @@ -8,17 +8,19 @@ function startServer(port : number) { app.use(cors()); + app.use("/previews", express.static("data/previews")); + 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)); });