diff --git a/src/githubUtils.ts b/src/githubUtils.ts index f641b1b..0779486 100644 --- a/src/githubUtils.ts +++ b/src/githubUtils.ts @@ -49,4 +49,14 @@ export const grabCommmunityPluginList = async(): Promise => { } catch (error) { console.log("error in grabCommmunityPluginList", error) } +} + +export const grabCommmunityThemesList = async(): Promise => { + const themesURL = `https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-css-themes.json`; + try { + const response = await request({ url: themesURL }); + return (response === "404: Not Found" ? null : await JSON.parse(response)); + } catch (error) { + console.log("error in grabCommmunityThemesList", error) + } } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 136ae34..71007ae 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import { SettingsTab } from "./SettingsTab"; import { Settings, DEFAULT_SETTINGS } from "./settings"; import BetaPlugins from "./BetaPlugins"; import { GenericFuzzySuggester, SuggesterItem } from "./GenericFuzzySuggester"; -import { grabCommmunityPluginList } from "./githubUtils"; +import { grabCommmunityPluginList, grabCommmunityThemesList } from "./githubUtils"; export default class ThePlugin extends Plugin { appName = "Obsidian42 - Beta Reviewer's Auto-update Tool (BRAT)"; @@ -67,12 +67,15 @@ export default class ThePlugin extends Plugin { this.addCommand({ id: "BRAT-openGitHubRepository", - name: "Open the GitHub repository for a plugin", + name: "Open the GitHub repository for a plugin or theme", callback: async () => { const communityPlugins = await grabCommmunityPluginList(); - const communityPluginList: SuggesterItem[] = Object.values(communityPlugins).map((p) => { return { display: `Community: ${p.name} (${p.repo})`, info: p.repo } }); + const communityPluginList: SuggesterItem[] = Object.values(communityPlugins).map((p) => { return { display: `Plugin: ${p.name} (${p.repo})`, info: p.repo } }); const bratList: SuggesterItem[] = Object.values(this.settings.pluginList).map((p) => { return { display: "BRAT: " + p, info: p } }); communityPluginList.forEach(si => bratList.push(si)); + const communityTheme = await grabCommmunityThemesList(); + const communityThemeList: SuggesterItem[] = Object.values(communityTheme).map((p) => { return { display: `Theme: ${p.name} (${p.repo})`, info: p.repo } }); + communityThemeList.forEach(si => bratList.push(si)); const gfs = new GenericFuzzySuggester(this); gfs.setSuggesterData(bratList); await gfs.display(async (results) => { @@ -81,6 +84,7 @@ export default class ThePlugin extends Plugin { } }); + this.addCommand({ id: "BRAT-disablePlugin", name: "Disable a plugin - toggle it off",