Skip to content

Commit

Permalink
0.8.1 Release - New feature: Obsidian Protocol Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
TfTHacker committed Dec 10, 2023
1 parent 0a83ecd commit 3ff1213
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 39 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 0.8.1

### New

- Obsidian Protocol handler for making installing plugins and themes easier by using Obsidian's protocol feature. See https://tfthacker.com/brat-protocol for more information.
This new feature contributed by @mProjectsCode (Thank you!).
- chore: updated all dependencies.

### Fix

- Bug introduced with 8.02 when manifest-beta.json is used that a plugin will not installed. (https://github.com/TfTHacker/obsidian42-brat/issues/71) Thank you for reporting this @mProjectsCode.

# 0.8.0

### New
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian42-brat",
"name": "BRAT",
"version": "0.8.0",
"version": "0.8.1",
"minAppVersion": "1.4.16",
"description": "Easily install a beta version of a plugin for testing.",
"author": "TfTHacker",
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@
"url": "git://github.com/TfTHacker/obsidian42-brat.git"
},
"devDependencies": {
"typescript": "5.3.2",
"typescript": "5.3.3",
"tslib": "^2.6.2",
"@types/node": "^20.10.3",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@typescript-eslint/utils": "^6.13.1",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"@typescript-eslint/utils": "^6.13.2",
"builtin-modules": "3.3.0",
"esbuild": "0.19.8",
"esbuild": "0.19.9",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-css": "^0.8.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsonc": "^2.10.0",
"eslint-plugin-mdx": "^2.2.0",
"eslint-plugin-mdx": "^3.0.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-yml": "^1.10.0",
"@html-eslint/eslint-plugin": "^0.21.0",
"@html-eslint/parser": "^0.21.0",
"@html-eslint/eslint-plugin": "^0.22.0",
"@html-eslint/parser": "^0.22.0",
"husky": "^8.0.3",
"jsdom": "^23.0.0",
"lint-staged": "^15.2.0",
"prettier": "^3.1.0",
"prettier": "^3.1.1",
"remark-preset-lint-consistent": "^5.1.2",
"remark-preset-lint-markdown-style-guide": "^5.1.3",
"remark-preset-lint-recommended": "^6.1.3",
"remark-preset-prettier": "^2.0.1",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"typedoc": "^0.25.3",
"@types/obsidian-typings": "github:Fevol/obsidian-typings",
"obsidian": "1.4.11"
Expand Down
26 changes: 15 additions & 11 deletions src/features/BetaPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ export default class BetaPlugins {
specifyVersion = '',
forceReinstall = false
): Promise<boolean> {
console.log(
'BRAT: addPlugin',
repositoryPath,
updatePluginFiles,
seeIfUpdatedOnly,
reportIfNotUpdted,
specifyVersion,
forceReinstall
);
if (this.plugin.settings.debuggingMode)
console.log(
'BRAT: addPlugin',
repositoryPath,
updatePluginFiles,
seeIfUpdatedOnly,
reportIfNotUpdted,
specifyVersion,
forceReinstall
);

const noticeTimeout = 10;
// attempt to get manifest-beta.json
Expand Down Expand Up @@ -266,7 +267,10 @@ export default class BetaPlugins {
if (usingBetaManifest || rFiles.manifest === '')
rFiles.manifest = JSON.stringify(primaryManifest);

if (usingBetaManifest || rFiles.mainJs === null) {
if (this.plugin.settings.debuggingMode)
console.log('BRAT: rFiles.manifest', usingBetaManifest, rFiles);

if (rFiles.mainJs === null) {
const msg = `${repositoryPath}\nThe release is not complete and cannot be download. main.js is missing from the Release`;
await this.plugin.log(msg, true);
toastMessage(this.plugin, `${msg}`, noticeTimeout);
Expand Down Expand Up @@ -512,4 +516,4 @@ export default class BetaPlugins {
!enabledPlugins.find((pluginName) => manifest.id === pluginName.id)
);
}
}
}
3 changes: 3 additions & 0 deletions src/features/githubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ export const grabManifestJsonFromRepository = async (
GITHUB_RAW_USERCONTENT_PATH +
repositoryPath +
(rootManifest ? '/HEAD/manifest.json' : '/HEAD/manifest-beta.json');
if (debugLogging)
console.log('grabManifestJsonFromRepository manifestJsonPath', manifestJsonPath);
try {
const response: string = await request({ url: manifestJsonPath });
if (debugLogging) console.log('grabManifestJsonFromRepository response', response);
return response === '404: Not Found' ? null : (
((await JSON.parse(response)) as PluginManifest)
);
Expand Down
22 changes: 11 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ObsidianProtocolData, Plugin } from 'obsidian';
import { Plugin } from 'obsidian';
import type { ObsidianProtocolData } from 'obsidian';
import { BratSettingsTab } from './ui/SettingsTab';
import type { Settings } from './settings';
import { DEFAULT_SETTINGS } from './settings';
Expand All @@ -13,15 +14,15 @@ import AddNewTheme from './ui/AddNewTheme';
import AddNewPluginModal from './ui/AddNewPluginModal';

export default class ThePlugin extends Plugin {
APP_NAME = "Obsidian42 - Beta Reviewer's Auto-update Tool (BRAT)";
APP_NAME = 'BRAT';
APP_ID = 'obsidian42-brat';
settings: Settings = DEFAULT_SETTINGS;
betaPlugins = new BetaPlugins(this);
commands: PluginCommands = new PluginCommands(this);
bratApi: BratAPI = new BratAPI(this);

async onload(): Promise<void> {
console.log('loading Obsidian42 - BRAT');
console.log('loading ' + this.APP_NAME);

await this.loadSettings();
this.addSettingTab(new BratSettingsTab(this.app, this));
Expand Down Expand Up @@ -70,23 +71,22 @@ export default class ThePlugin extends Plugin {
await this.saveData(this.settings);
}

obsidianProtocolHandler = async (params: ObsidianProtocolData) => {
obsidianProtocolHandler = (params: ObsidianProtocolData) => {
if (!params.plugin && !params.theme) {
toastMessage(
this,
`Could not locate the repository from the URL.`,
10
);
toastMessage(this, `Could not locate the repository from the URL.`, 10);
return;
}

for (const which of ['plugin', 'theme']) {
if (params[which]) {
const modal = which === 'plugin' ? new AddNewPluginModal(this, this.betaPlugins) : new AddNewTheme(this);
const modal =
which === 'plugin' ?
new AddNewPluginModal(this, this.betaPlugins)
: new AddNewTheme(this);
modal.address = params[which];
modal.open();
return;
}
}
}
};
}
6 changes: 1 addition & 5 deletions src/ui/AddNewTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ export default class AddNewTheme extends Modal {
if (this.address === '') return;
const scrubbedAddress = this.address.replace('https://github.com/', '');
if (existBetaThemeinInList(this.plugin, scrubbedAddress)) {
toastMessage(
this.plugin,
`This theme is already in the list for beta testing`,
10
);
toastMessage(this.plugin, `This theme is already in the list for beta testing`, 10);
return;
}

Expand Down

0 comments on commit 3ff1213

Please sign in to comment.