Skip to content

Commit

Permalink
0.5.12 Update - starting work on themes
Browse files Browse the repository at this point in the history
  • Loading branch information
TfTHacker committed Nov 3, 2021
1 parent 7a51ea9 commit 06598f8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ You can enable a plugin that is currently disabled or disable a plugin that is c
## Open a GitHub repository (This is way more cool than it sounds)
The command palette contains a command **BRAT: Open the GitHub repository for a plugin**. This gives you a list of all beta plugins registered with BRAT, but also all plugins from the community plugin list. By selecting a plugin from the list, the GitHub repository will be opened in your browser


<a href="https://twitter.com/TfTHacker/status/1452175686928580612" target="_blank"><img style="width:200px;" src="https://raw.githubusercontent.com/TfTHacker/obsidian42-brat/main/help/GithubOpenrepositories.png"></a> Click image for video demo!

## Working with Themes
BRAT can also open Github repositories for Obsidian Themes, in addition to switching themes from the command palette.

---

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"devDependencies": {
"@types/node": "^16.11.6",
"eslint": "^8.1.0",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"esbuild": "0.13.8",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"esbuild": "0.13.12",
"obsidian": "^0.12.17",
"tslib": "^2.3.1",
"typescript": "^4.4.4"
Expand Down
35 changes: 30 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ export default class ThePlugin extends Plugin {

this.addCommand({
id: "BRAT-openGitHubRepository",
name: "Open the GitHub repository for a plugin or theme",
name: "Open the GitHub repository for a plugin",
callback: async () => {
const communityPlugins = await grabCommmunityPluginList();
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) => {
Expand All @@ -84,7 +81,6 @@ export default class ThePlugin extends Plugin {
}
});


this.addCommand({
id: "BRAT-disablePlugin",
name: "Disable a plugin - toggle it off",
Expand Down Expand Up @@ -113,6 +109,35 @@ export default class ThePlugin extends Plugin {
}
});

this.addCommand({
id: "BRAT-openGitHubRepoTheme",
name: "Open the GitHub repository for a theme ",
callback: async () => {
const communityTheme = await grabCommmunityThemesList();
const communityThemeList: SuggesterItem[] = Object.values(communityTheme).map((p) => { return { display: `Theme: ${p.name} (${p.repo})`, info: p.repo } });
const gfs = new GenericFuzzySuggester(this);
gfs.setSuggesterData(communityThemeList);
await gfs.display(async (results) => {
if (results.info) window.open(`https://github.com/${results.info}`)
});
}
});

this.addCommand({
id: "BRAT-switchTheme",
name: "Switch Active Theme ",
callback: async () => {
// @ts-ignore
const communityThemeList: SuggesterItem[] = Object.values(this.app.customCss.themes).map((t) => { return { display: t, info: t } });
const gfs = new GenericFuzzySuggester(this);
gfs.setSuggesterData(communityThemeList);
await gfs.display(async (results) => {
// @ts-ignore
this.app.customCss.setTheme(results.info);
});
}
});

this.app.workspace.onLayoutReady((): void => {
if (this.settings.updateAtStartup) // let obsidian load and calm down before check
setTimeout(async () => { await this.betaPlugins.checkForUpdatesAndInstallUpdates(false) }, 60000);
Expand Down

0 comments on commit 06598f8

Please sign in to comment.