From a6abb536e4cd60d1e393dcdbba90866635d5dce2 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Fri, 11 Feb 2022 19:46:12 -0800 Subject: [PATCH] theme.json is now read if present --- src/main/base/browserwindow.ts | 35 +++++++++++++++++++++++++-- src/renderer/views/pages/settings.ejs | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index ee2f206f..f3d151d4 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -397,7 +397,6 @@ export class BrowserWindow { ipcMain.on("get-themes", (event, _key) => { if (existsSync(utils.getPath("themes"))) { - // return any .less files and scan any folders in the themes folder for .less files let files = readdirSync(utils.getPath("themes")); let themes = []; for (let file of files) { @@ -412,7 +411,39 @@ export class BrowserWindow { } } } - event.returnValue = themes; + let themeObjects = []; + for (let theme of themes) { + let themePath = join(utils.getPath("themes"), theme); + let themeName = theme; + let themeDescription = ""; + if (theme.includes("/")) { + themeName = theme.split("/")[1]; + themeDescription = theme.split("/")[0]; + } + if (themePath.endsWith("index.less")) { + themePath = themePath.slice(0, -10); + } + if (existsSync(join(themePath, "theme.json"))) { + let themeJson = JSON.parse(readFileSync(join(themePath, "theme.json"), "utf8")); + themeObjects.push({ + name: themeJson.name || themeName, + description: themeJson.description || themeDescription, + path: themePath, + file: theme, + test: join(themePath, "theme.json") + }); + } else { + themeObjects.push({ + name: themeName, + description: themeDescription, + path: themePath, + file: theme, + test: join(themePath, "theme.json") + }); + } + } + event.returnValue = themeObjects; + } else { event.returnValue = []; } diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 76e1b8b5..87b23311 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -130,7 +130,7 @@