Skip to content

Commit

Permalink
adjust writer usfm book downloads for nt to incrmeent by one accordin…
Browse files Browse the repository at this point in the history
…g to conventions for NT
  • Loading branch information
wkelly17 committed Nov 15, 2023
1 parent a114c71 commit c6aec8e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
7 changes: 6 additions & 1 deletion functions/api/getUsfmSrcDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ export const onRequestPost: PagesFunction = async (context) => {
const finalUrl = `${baseUrl}/${user}/${repo}/source.usfm`
const response = await fetch(finalUrl)

// @ NOTE! There is a convention in bible translation world (at least told to me) of NT matthew starting at 41 instead of 40: So, if the bibleBookSortOrder[book?.toUpperCase()] is > = 40, we need to plus 1 it.
let sortOrder = bibleBookSortOrder[book?.toUpperCase()];
if (sortOrder >= 40) {
sortOrder = sortOrder += 1;
}
const fileName = `${
bibleBookSortOrder[book?.toUpperCase()]
sortOrder
}-${book?.toUpperCase()}`
const newResp = new Response(response.body, {
headers: {
Expand Down
11 changes: 6 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/components/Settings/DownloadSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export function DownloadSection(props: IDownloadSection) {
const [bookOrResource, setBookOrResource] = createSignal("BOOK")
const [fileType, setFileType] = createSignal(".PDF")
let printWholeUsfmRef: HTMLAnchorElement | undefined
let bttWriterSinglUsfmForm: HTMLFormElement | undefined
let bttWriterSingleUsfmForm: HTMLFormElement | undefined

function buttonIsDisabled() {
function buttonStatus() {
const singleUsfmFileNotSupported =
bookOrResource() === "BOOK" &&
fileType() === ".USFM" &&
Expand Down Expand Up @@ -84,7 +84,7 @@ export function DownloadSection(props: IDownloadSection) {

function downloadSingleUsfm() {
if (props.downloadSourceUsfmArr.length) {
bttWriterSinglUsfmForm && bttWriterSinglUsfmForm.submiprops.t()
bttWriterSingleUsfmForm && bttWriterSingleUsfmForm.submit()
}
}
function downloadWholeUsfm() {
Expand Down Expand Up @@ -183,9 +183,9 @@ export function DownloadSection(props: IDownloadSection) {
<Button.Root
onClick={handleDownloadSubmission}
class="mt-4 flex w-full items-center justify-center gap-4 rounded-2xl border border-gray-200 py-3 text-center hover:bg-gray-100 focus:outline-2 focus:outline-accent disabled:border-red-200 disabled:opacity-70"
disabled={buttonIsDisabled().enabled}
disabled={buttonStatus().enabled}
>
{buttonIsDisabled().text}
{buttonStatus().text}
</Button.Root>

<div data-role="hiddenControls" class="hidden h-0 w-0">
Expand All @@ -195,7 +195,7 @@ export function DownloadSection(props: IDownloadSection) {
href={`https://content.bibletranslationtools.org/${props.user}/${props.repo}/archive/master.zip`}
/>
<form
ref={bttWriterSinglUsfmForm}
ref={bttWriterSingleUsfmForm}
action={FUNCTIONS_ROUTES.downloadUsfmSrc({
user: props.user,
repo: props.repo,
Expand Down

0 comments on commit c6aec8e

Please sign in to comment.