Skip to content

Commit

Permalink
Merge pull request #2565 from AndBible/bugfix/2563_stepbible_link_doc…
Browse files Browse the repository at this point in the history
…ument

Fix StepBible link document (version)
  • Loading branch information
tuomas2 authored Jul 21, 2023
2 parents 470c708 + 923e943 commit 6c25f2f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/bibleview-js/src/components/StudyPadRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const bibleUrl = computed(
const osis = bookmarkItem.osisRef;

if(exportMode.value) {
return formatExportLink({ref: osis, v11n: bookmarkItem.v11n})
return formatExportLink({ref: osis, v11n: bookmarkItem.v11n, doc: bookmarkItem.bookInitials});
} else {
return `osis://?osis=${osis}&v11n=${bookmarkItem.v11n}`;
}
Expand Down
7 changes: 4 additions & 3 deletions app/bibleview-js/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ export function sprintf(format: string, ...args: any[]) {
}

export function formatExportLink({ref, v11n, doc}: {ref: string, v11n: string, doc?: string}) {
const docStr = doc ? `&document=${doc}`: ""
return `https://stepbible.org/?q=reference=${ref}&v11n=${v11n}${docStr}`
}
const docStr = doc ? `|version=${doc}`: ""
// this is parsed in MainBibleActivity::openLink(uri: Uri) function for intent parsing
return `https://stepbible.org/?q=reference=${ref}${docStr}&v11n=${v11n}`
}
Original file line number Diff line number Diff line change
Expand Up @@ -1065,18 +1065,21 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
windowControl.showLink(doc, key)
}
"stepbible.org" -> {
val docStr = uri.getQueryParameter("document")
val doc = if (docStr != null) Books.installed().getBook(docStr) else null
val qParam = uri.getQueryParameter("q") ?: return

val docRegex = Regex("""version=([^&|]+)""")
val refRegex = Regex("""reference=([^&|]+)""")

val versionMatch = docRegex.find(qParam)
val version = if (versionMatch != null) versionMatch.groups[1]?.value else null
val doc = if (version != null) Books.installed().getBook(version) else null

val defV11n = if (doc is SwordBook) doc.versification else KJVA
val v11nStr = uri.getQueryParameter("v11n")
val v11n = if (v11nStr == null) defV11n else Versifications.instance().getVersification(v11nStr) ?: defV11n

val refStr = uri.getQueryParameter("q")?:return
val refRegex = Regex("""reference=(.*)""")
val match = refRegex.find(refStr) ?: return

val keyStr = match.groups[1]?.value ?: return
val refMatch = refRegex.find(qParam) ?: return
val keyStr = refMatch.groups[1]?.value ?: return

val key = PassageKeyFactory.instance().getKey(v11n, keyStr)
windowControl.showLink(doc, key)
Expand Down

0 comments on commit 6c25f2f

Please sign in to comment.