generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added error handling - plugin properly handles markdown links - added better progress reporting - refactored plugin into multiple files - added a setting for a custom link text - improved logic for detecting already-archived links
- Loading branch information
Showing
6 changed files
with
178 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
# Intellij | ||
*.iml | ||
.idea | ||
|
||
# npm | ||
node_modules | ||
package-lock.json | ||
|
||
# build | ||
main.js | ||
*.js.map | ||
|
||
# obsidian | ||
data.json | ||
# Intellij | ||
*.iml | ||
.idea | ||
# npm | ||
node_modules | ||
package-lock.json | ||
# build | ||
main.js | ||
*.js.map | ||
# obsidian | ||
data.json | ||
/Folder.DotSettings.user | ||
.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const defaultArchiveText = "(Archived)"; | ||
export const waybackUrl = "https://web.archive.org/web/"; | ||
export const waybackSaveUrl = "https://web.archive.org/save/"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { App, PluginSettingTab, Setting } from "obsidian"; | ||
import ObsidianLinkArchivePlugin from "./main"; | ||
import { defaultArchiveText } from "./constants"; | ||
|
||
export const enum ArchiveOptions { | ||
Wayback, | ||
Archiveis, | ||
Both | ||
} | ||
|
||
// ReSharper disable once InconsistentNaming | ||
export interface LinkArchivePluginSettings { | ||
archiveOption: ArchiveOptions; | ||
archiveText: string; | ||
} | ||
|
||
export const defaultSettings: LinkArchivePluginSettings = { | ||
archiveOption: ArchiveOptions.Archiveis, | ||
archiveText: defaultArchiveText | ||
} | ||
|
||
|
||
export class LinkArchiveSettingTab extends PluginSettingTab { | ||
plugin: ObsidianLinkArchivePlugin; | ||
|
||
constructor(app: App, plugin: ObsidianLinkArchivePlugin) { | ||
super(app, plugin); | ||
this.plugin = plugin; | ||
} | ||
|
||
display(): void { | ||
const plugin: ObsidianLinkArchivePlugin = (this as any).plugin; | ||
|
||
const { containerEl } = this; | ||
|
||
containerEl.empty(); | ||
|
||
// add archive link text customization option | ||
|
||
containerEl.createEl("h2", {text: "Archive Settings"}); | ||
|
||
new Setting(containerEl) | ||
.setName("Link text") | ||
.setDesc("The text of the archive links") | ||
.addText(text => | ||
text | ||
.setValue(plugin.settings.archiveText) | ||
.onChange(async value => { | ||
console.log(`Link text: ${value}`); | ||
plugin.settings.archiveText = value; | ||
await plugin.saveSettings(); | ||
})); | ||
|
||
// new Setting(containerEl) | ||
// .setName('Archive Provider') | ||
// .setDesc('Choose a provider for the link archive') | ||
// .addDropdown((dropdown) => { | ||
// const options: Record<ArchiveOptions, string> = { | ||
// 0: "Internet Archive", | ||
// 1: "archive.is", | ||
// 2: "Both" | ||
// }; | ||
|
||
// dropdown | ||
// .addOptions(options) | ||
// .setValue(plugin.settings.archiveOption.toString()) | ||
// .onChange(async (value) => { | ||
// console.log('Archive option: ' + value); | ||
// plugin.settings.archiveOption = +value; | ||
// await plugin.saveSettings(); | ||
// this.display(); | ||
// }) | ||
// }); | ||
|
||
containerEl.createEl("h2", {text: "About Link Archive"}); | ||
|
||
containerEl.createEl("p", {text: "This plugin archives links in your note so they're available to you even if the original site goes down or gets removed."}); | ||
|
||
containerEl.createEl("a", {text: "Open GitHub repository", href: "https://github.com/tomzorz/obsidian-link-archive"}); | ||
|
||
// TODO github support and ko-fi | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* nothing to see here for now */ |