From cfe8bddf94b249974d3d87df28fae233f044e05a Mon Sep 17 00:00:00 2001 From: Joseph Kilgore Date: Mon, 22 May 2023 12:59:53 -0400 Subject: [PATCH 1/3] initial tagging and backlinking options This creates the basic layout for how tags and backlinks can be added to bible-reference This works, but links are based on what the user enters and should be translated to a single unified format for links and tags --- src/VerseSuggesting.ts | 16 ++++++ src/data/constants.ts | 10 ++++ src/ui/BibleReferenceSettingTab.ts | 78 +++++++++++++++++++++++++++++- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/src/VerseSuggesting.ts b/src/VerseSuggesting.ts index a39feb4..af6f9d5 100644 --- a/src/VerseSuggesting.ts +++ b/src/VerseSuggesting.ts @@ -58,6 +58,22 @@ export class VerseSuggesting implements IVerseSuggesting { ) { bottom += `> \n ${this.getVerseReference()}` } + if ( + this.settings?.bibleTagging || + this.settings?.bookTagging || + this.settings?.chapterTagging) { + bottom += ' %%' + bottom += (this.settings?.bibleTagging) ? ' #bible' : '' + bottom += (this.settings?.bookTagging) ? ` #${this.bookName}` : '' + bottom += (this.settings?.chapterTagging) ? ` #${this.bookName}_${this.chapterNumber}` : '' + bottom += ' %%' + } + if (this.settings?.bookBacklinking){ + bottom += ` [[${this.bookName}]]` + } + if (this.settings?.chapterBacklinking){ + bottom += ` [[${this.bookName}_${this.chapterNumber}]]` + } return [head, this.text, bottom].join('\n') } diff --git a/src/data/constants.ts b/src/data/constants.ts index 076781e..978f465 100644 --- a/src/data/constants.ts +++ b/src/data/constants.ts @@ -16,6 +16,11 @@ export interface BibleReferencePluginSettings { verseFormatting?: BibleVerseFormat verseNumberFormatting?: BibleVerseNumberFormat collapsibleVerses?: boolean + bibleTagging?: boolean + bookTagging?: boolean + chapterTagging?: boolean + bookBacklinking?: boolean + chapterBacklinking?: boolean } export const DEFAULT_SETTINGS: BibleReferencePluginSettings = { @@ -24,4 +29,9 @@ export const DEFAULT_SETTINGS: BibleReferencePluginSettings = { verseFormatting: BibleVerseFormat.SingleLine, verseNumberFormatting: BibleVerseNumberFormat.Period, collapsibleVerses: false, + bibleTagging: false, + bookTagging: false, + chapterTagging: false, + bookBacklinking: false, + chapterBacklinking: false, } diff --git a/src/ui/BibleReferenceSettingTab.ts b/src/ui/BibleReferenceSettingTab.ts index 4c85052..4ef6ace 100644 --- a/src/ui/BibleReferenceSettingTab.ts +++ b/src/ui/BibleReferenceSettingTab.ts @@ -154,6 +154,76 @@ export class BibleReferenceSettingTab extends PluginSettingTab { ) } + SetUpBibleTagging = (containerEl: HTMLElement): void => { + new Setting(containerEl) + .setName('Create Bible Tags') + .setDesc('Makes hidden #bible tag') + .addToggle((toggle) => + toggle + .setValue(!!this.plugin.settings?.bibleTagging) + .onChange((value) => { + this.plugin.settings.bibleTagging = value + this.plugin.saveData(this.plugin.settings) + }) + ) + } + + SetUpBookTagging = (containerEl: HTMLElement): void => { + new Setting(containerEl) + .setName('Create Book Tags') + .setDesc('Makes hidden #{book} tag') + .addToggle((toggle) => + toggle + .setValue(!!this.plugin.settings?.bookTagging) + .onChange((value) => { + this.plugin.settings.bookTagging = value + this.plugin.saveData(this.plugin.settings) + }) + ) + } + + SetUpChapterTagging = (containerEl: HTMLElement): void => { + new Setting(containerEl) + .setName('Create Chapter Tags') + .setDesc('Makes hidden #{book_chapter} tag') + .addToggle((toggle) => + toggle + .setValue(!!this.plugin.settings?.chapterTagging) + .onChange((value) => { + this.plugin.settings.chapterTagging = value + this.plugin.saveData(this.plugin.settings) + }) + ) + } + + SetUpBookBacklinking = (containerEl: HTMLElement): void => { + new Setting(containerEl) + .setName('Create Book Backlink') + .setDesc('Makes [[{book}]] link') + .addToggle((toggle) => + toggle + .setValue(!!this.plugin.settings?.bookBacklinking) + .onChange((value) => { + this.plugin.settings.bookBacklinking = value + this.plugin.saveData(this.plugin.settings) + }) + ) + } + + SetUpChapterBacklinking = (containerEl: HTMLElement): void => { + new Setting(containerEl) + .setName('Create Chapter Tags') + .setDesc('Makes [[{book_chapter}]] link') + .addToggle((toggle) => + toggle + .setValue(!!this.plugin.settings?.chapterBacklinking) + .onChange((value) => { + this.plugin.settings.chapterBacklinking = value + this.plugin.saveData(this.plugin.settings) + }) + ) + } + display(): void { const { containerEl } = this containerEl.empty() @@ -162,12 +232,18 @@ export class BibleReferenceSettingTab extends PluginSettingTab {