Skip to content

Commit

Permalink
Merge pull request #199 from AlphaHasher/master
Browse files Browse the repository at this point in the history
Added options for toggling hyperlinking and translations + LSB translation
  • Loading branch information
tim-hub authored Jun 4, 2024
2 parents 2463988 + 21efa88 commit 3effa1f
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/bible-api-and-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This plugin Bible Verse Query Functionality is currently powered by
- **NKJV**: New King James Version (Bolls Life)
- **CUV**: China Union Version (Bolls Life) (Book Names Are In English, Bible Verses Are In Chinese)
- **ESV**: English Standard Version (Bolls Life)
- **LSB**: Legacy Standard Bible (Bolls Life)
- and more

### Credits
Expand Down
7 changes: 7 additions & 0 deletions src/data/BibleVersionCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ export const BibleVersionCollection: IBibleVersion[] = [
code: 'en',
apiSource: BibleAPISourceCollection.bollsLife,
},
{
key: 'lsb',
versionName: 'Legacy Standard Bible',
language: 'English',
code: 'en',
apiSource: BibleAPISourceCollection.bollsLife,
},
{
key: 'elb',
versionName: 'Elberfelder Bibel (1871)',
Expand Down
4 changes: 4 additions & 0 deletions src/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface BibleReferencePluginSettings {
verseFormatting?: BibleVerseFormat
verseNumberFormatting?: BibleVerseNumberFormat
collapsibleVerses?: boolean // this is binging to displayBibleIconPrefixAtHeader option
enableHyperlinking?: boolean
showVerseTranslation?: boolean
bookTagging?: boolean
chapterTagging?: boolean
bookBacklinking?: OutgoingLinkPositionEnum // this is refering to outgoing link
Expand All @@ -48,6 +50,8 @@ export const DEFAULT_SETTINGS: BibleReferencePluginSettings = {
verseFormatting: BibleVerseFormat.SingleLine,
verseNumberFormatting: BibleVerseNumberFormat.Period,
collapsibleVerses: false,
enableHyperlinking: true,
showVerseTranslation: true,
bookTagging: false,
chapterTagging: false,
enableBibleVerseLookupRibbon: false,
Expand Down
60 changes: 57 additions & 3 deletions src/ui/BibleReferenceSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
this.setUpVerseFormatOptions()
this.setUpVerseNumberFormatOptions()
this.setUpBibleIconPrefixToggle()
this.setUpShowVerseTranslationOptions()
this.setUpHyperlinkingOptions()
this.setUpCollapsibleToggle()
this.setUpStatusIndicationOptions()
this.containerEl.createEl('h2', {text: 'Others'})
Expand All @@ -74,16 +76,16 @@ export class BibleReferenceSettingTab extends PluginSettingTab {
<br/>
<span class="setting-item-description">
Obsidian Bible Reference is proudly powered by
Obsidian Bible Reference is proudly powered by
<a href="https://antioch.tech/obsidian-bible-reference/">
<img src="https://antioch.tech/wp-content/uploads/2023/10/logo_128.png" alt="Antioch Tech logo" class="logo"> Antioch Tech
</a>
</a>
</span>
`
})

// this initialisation order is important
// this initialization order is important
this.expertSettingContainer = this.containerEl.createDiv()
if (this.plugin.settings.advancedSettings) {
this.displayExpertSettings()
Expand Down Expand Up @@ -347,6 +349,58 @@ Obsidian Bible Reference is proudly powered by
})
}

private setUpShowVerseTranslationOptions(): void {
const setting = new Setting(this.containerEl)
.setName('Show Verse Translation')
.setDesc('Show or hide the verse translation')
setting.setTooltip(
'This will show the verse translation verse text after the verse number'
)
setting.addToggle((toggle) => {
if (!this.plugin.settings?.displayBibleIconPrefixAtHeader) {
toggle.setDisabled(true)
toggle.setTooltip('')
}
toggle
.setValue(!!this.plugin.settings?.showVerseTranslation)
.onChange(async (value) => {
this.plugin.settings.showVerseTranslation = value
await this.plugin.saveSettings()
EventStats.logSettingChange(
'changeVerseFormatting',
{key: `show-translation-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
})
}

private setUpHyperlinkingOptions(): void {
const setting = new Setting(this.containerEl)
.setName('Enable Hyperlinking')
.setDesc('Enable or disable hyperlinking of the verses')
setting.setTooltip(
'This will make the verse number clickable and will open the verse in the Bible app'
)
setting.addToggle((toggle) => {
if (!this.plugin.settings?.displayBibleIconPrefixAtHeader) {
toggle.setDisabled(true)
toggle.setTooltip('')
}
toggle
.setValue(!!this.plugin.settings?.enableHyperlinking)
.onChange(async (value) => {
this.plugin.settings.enableHyperlinking = value
await this.plugin.saveSettings()
EventStats.logSettingChange(
'changeVerseFormatting',
{key: `hyperlinking-${value}`, value: 1},
this.plugin.settings.optOutToEvents
)
})
})
}

private setUpVerseNumberFormatOptions(): void {
new Setting(this.containerEl)
.setName('Verse Number Formatting Options')
Expand Down
14 changes: 11 additions & 3 deletions src/verse/VerseSuggesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,16 @@ export class VerseSuggesting
}

protected getVerseReferenceLink(): string {
return ` [${
this.bibleProvider.BibleReferenceHead
} - ${this.bibleVersion.toUpperCase()}](${this.bibleProvider.VerseLinkURL})`
let verseLink = ''
if (this.settings?.showVerseTranslation && this.settings?.enableHyperlinking) {
verseLink = ` [${this.bibleProvider.BibleReferenceHead} - ${this.bibleVersion.toUpperCase()}](${this.bibleProvider.VerseLinkURL})`
} else if (this.settings?.showVerseTranslation && !this.settings?.enableHyperlinking) {
verseLink = ` ${this.bibleProvider.BibleReferenceHead} - ${this.bibleVersion.toUpperCase()}`
} else if (!this.settings?.showVerseTranslation && this.settings?.enableHyperlinking) {
verseLink = ` [${this.bibleProvider.BibleReferenceHead}](${this.bibleProvider.VerseLinkURL})`
} else {
verseLink = ` ${this.bibleProvider.BibleReferenceHead}`
}
return verseLink
}
}

0 comments on commit 3effa1f

Please sign in to comment.