Skip to content

Commit

Permalink
Merge pull request #96 from joey-kilgore/master
Browse files Browse the repository at this point in the history
Tagging and Backlinks
  • Loading branch information
tim-hub authored Jun 1, 2023
2 parents de8a0e1 + de76cff commit e9b3d89
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/VerseSuggesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ export class VerseSuggesting implements IVerseSuggesting {
) {
bottom += `> \n ${this.getVerseReference()}`
}

// backlinks and tags use the BibleReferenceHeader
// and regex to clean book and chapters that will match
// across multiple different search queires
if (this.settings?.bookBacklinking){
head += ` [[${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}/)![0].replace(/\s+/g, '').toLowerCase()}]]`
}
if (this.settings?.chapterBacklinking){
head += ` [[${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}[ ]*[0-9]*/)![0].replace(/\s+/g, '').toLowerCase()}]]`
}
if (
this.settings?.bibleTagging ||
this.settings?.bookTagging ||
this.settings?.chapterTagging) {
bottom += ' %%'
bottom += (this.settings?.bibleTagging) ? ' #bible' : ''
bottom += (this.settings?.bookTagging) ? ` #${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}/)![0].replace(/\s+/g, '').toLowerCase()}` : ''
bottom += (this.settings?.chapterTagging) ? ` #${this.bibleProvider.BibleReferenceHead.match(/[123]*[ ]*[A-z]{3,}[ ]*[0-9]*/)![0].replace(/\s+/g, '').toLowerCase()}` : ''
bottom += ' %%'
}

return [head, this.text, bottom].join('\n')
}

Expand Down
10 changes: 10 additions & 0 deletions src/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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,
}
78 changes: 77 additions & 1 deletion src/ui/BibleReferenceSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -162,12 +232,18 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
<iframe src="https://github.com/sponsors/tim-hub/button" title="Sponsor Obsidian Bible Reference" width="116" height="32px" style="margin-right: 2em"/>
`

containerEl.createEl('h2', { text: 'Settings' })
containerEl.createEl('h2', { text: 'General Settings' })
this.SetUpVersionSettingsAndVersionOptions(containerEl)
this.SetUpReferenceLinkPositionOptions(containerEl)
this.SetUpVerseFormatOptions(containerEl)
this.SetUpVerseNumberFormatOptions(containerEl)
this.SetUpTextOptions(containerEl)
containerEl.createEl('h2', { text: 'Tagging and Linking Settings' })
this.SetUpBibleTagging(containerEl)
this.SetUpBookTagging(containerEl)
this.SetUpChapterTagging(containerEl)
this.SetUpBookBacklinking(containerEl)
this.SetUpChapterBacklinking(containerEl)

containerEl.createEl('h2', { text: 'About' })

Expand Down

0 comments on commit e9b3d89

Please sign in to comment.