fix: scope tokens per host, harden Gitea support, port upstream fixes
Fork fixes: - Global token is GitHub-only; never sent to Gitea/Forgejo hosts - Gitea: download assets via browser_download_url (+token) so private repos work - Gitea URL parsing keeps port and sub-path installs, strips browser sub-pages - GitHub detected by hostname, not substring - Gitea releases: follow pagination (X-Total-Count), skip drafts - Gitea token validation against the repo; 404 is no longer "valid" - Settings tab and migration log use this plugin's own id/folder - Check-only mode no longer reinstalls/enables a missing plugin folder - reloadPlugin reports load failures (enablePlugin resolves false) - Repository / release-notes links work for both providers Ported from upstream BRAT 2.2.0: - Release sort: semver tags first, date fallback - Null-safe version comparison, JSON shape guards - Drop obsidian-daily-notes-interface (read daily note format directly) - Notice.messageEl, CSS without !important, console.debug/error
This commit is contained in:
1 parent
91247d31e2
commit
d3f3fe926a
21 files changed
+548
-495
No files matched your search
+11
-3
@@ -1,5 +1,6 @@
|
||||
import { ButtonComponent, Modal, Setting } from "obsidian";
|
||||
import { themeSave } from "../features/themes";
|
||||
import { normalizeRepoAddress } from "../providers";
|
||||
import type BratPlugin from "../main";
|
||||
import { existBetaThemeinInList } from "../settings";
|
||||
import { toastMessage } from "../utils/notifications";
|
||||
@@ -22,7 +23,15 @@ export default class AddNewTheme extends Modal {
|
||||
|
||||
async submitForm(): Promise<void> {
|
||||
if (this.address === "") return;
|
||||
const scrubbedAddress = this.address.replace("https://github.com/", "");
|
||||
const scrubbedAddress = normalizeRepoAddress(this.address);
|
||||
if (!scrubbedAddress) {
|
||||
toastMessage(
|
||||
this.plugin,
|
||||
"Invalid address. Expected: user/repo (GitHub) or https://host/user/repo (Gitea).",
|
||||
10,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (existBetaThemeinInList(this.plugin, scrubbedAddress)) {
|
||||
toastMessage(
|
||||
this.plugin,
|
||||
@@ -77,7 +86,6 @@ export default class AddNewTheme extends Modal {
|
||||
.setCta()
|
||||
.onClick((e: Event) => {
|
||||
e.preventDefault();
|
||||
console.log("Add theme button clicked");
|
||||
if (this.address !== "") void this.submitForm();
|
||||
});
|
||||
});
|
||||
@@ -113,7 +121,7 @@ export default class AddNewTheme extends Modal {
|
||||
// @ts-expect-error
|
||||
this.plugin.app.setting.openTab();
|
||||
// @ts-expect-error
|
||||
this.plugin.app.setting.openTabById(this.plugin.APP_ID);
|
||||
this.plugin.app.setting.openTabById(this.plugin.manifest.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user