Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The OrigL scripture pane moved to 3rd default scripture pane #173

Merged
merged 10 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "scripture-resources-rcl",
"description": "A React Component Library for Rendering Scripture Resources.",
"version": "5.5.3",
"version": "5.5.5",
"homepage": "https://scripture-resources-rcl.netlify.com/",
"repository": {
"type": "git",
Expand Down Expand Up @@ -49,7 +49,7 @@
"use-deep-compare-effect": "^1.3.1",
"usfm-js": "^3.4.2",
"uw-quote-helpers": "^1.0.0",
"word-aligner": "^1.0.0",
"word-aligner": "^1.0.0",
"xregexp": "^4.1.1"
},
"devDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion src/components/parallel-scripture/ParallelScripture.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function ParallelScripture({
const [open, setOpen] = useState(_open);

const { state } = React.useContext(ResourcesContext);
const { resources, books } = state;
const { resources, books, resourceLinks, ORIGINAL_LANG_POSITION } = state;
const defaultOriginalLangPostion = ORIGINAL_LANG_POSITION == 0 ? resourceLinks?.length - 1 : ORIGINAL_LANG_POSITION - 1 // ("-1" becoz array starts from 0)

console.log({defaultOriginalLangPostion, ORIGINAL_LANG_POSITION, resourceLinks})

useEffect(() => {
setOpen(_open);
Expand Down Expand Up @@ -114,6 +117,7 @@ function ParallelScripture({
buttons={buttons}
open={open}
onOpen={setOpen}
defaultOriginalLangPostion={defaultOriginalLangPostion}
/>
)) || <></>
);
Expand Down
18 changes: 16 additions & 2 deletions src/components/parallel-scripture/ParallelScripture.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const bookId = "tit";
const occurrence = -1;
const defaultQuote = "ἐφανέρωσεν & τὸν λόγον αὐτοῦ"

// for changing the postion of resource in scripture RCL
// to display the orginal language to first, ORIGINAL_LANG_POSITION = 1 also read line no 46
// default "0" - orignal language will be displayed last
const ORIGINAL_LANG_POSITION = 0;

const bcvQuery = {
book: {
[bookId]: {
Expand All @@ -38,10 +43,12 @@ const bcvQuery = {
},
}
const path = { ot: "hbo/uhb", nt: "el-x-koine/ugnt" };
// To change the position of scripture resource in the panel, move the elements in different index in allResourceLinks
// eg move "originalLink" to the last index to move hebrew / greek to last
const defaultResourceLinks = [
`unfoldingWord/${path.nt}/master/${bookId}`,
`unfoldingWord/en/ult/master/${bookId}`,
`https://git.door43.org/unfoldingWord/en_ust/src/branch/master`,
`unfoldingWord/${path.nt}/master/${bookId}`,
];

// Usage
Expand All @@ -61,6 +68,7 @@ function Component() {
resources={resources}
onResources={setResources}
config={config}
ORIGINAL_LANG_POSITION = {ORIGINAL_LANG_POSITION}
>
<p>Quote: {quote}</p>
<p>Occurrence: {occurrence}</p>
Expand Down Expand Up @@ -119,6 +127,11 @@ function Component({ }) {
return v
},{}), [verse])

// for changing the postion of resource in scripture RCL
// to display the orginal language to first, ORIGINAL_LANG_POSITION = 1 also read line no 46
// default "0" - orignal language will be displayed last
const ORIGINAL_LANG_POSITION = 0;

const bcvQuery = React.useMemo(() => ({
book: {
[bookId]: {
Expand All @@ -134,9 +147,9 @@ function Component({ }) {
const reference = React.useMemo(() => ({ bookId, chapter: Number(chapter), verse, bcvQuery }), [bookId, bcvQuery, chapter, verse]);

const defaultResourceLinks = React.useMemo(() => [
`unfoldingWord/${path[lang]}/master/${bookId}`,
`unfoldingWord/en/ult/master/${bookId}`,
`https://git.door43.org/unfoldingWord/en_ust/src/branch/master`,
`unfoldingWord/${path[lang]}/master/${bookId}`,
],[bookId,lang,path]);

const [resourceLinks, setResourceLinks] = React.useState(defaultResourceLinks);
Expand All @@ -151,6 +164,7 @@ function Component({ }) {
resources={resources}
onResources={setResources}
config={config}
ORIGINAL_LANG_POSITION = {ORIGINAL_LANG_POSITION}
>
<ExampleUiForm
bookId={bookId}
Expand Down
7 changes: 4 additions & 3 deletions src/components/parallel-scripture/ScriptureTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function ScriptureTable({
renderOffscreen = {},
open = true,
onOpen,
defaultOriginalLangPostion,
}) {
const classes = useStyles();
const [filter, setFilter] = useState(!!reference);
Expand Down Expand Up @@ -107,8 +108,8 @@ function ScriptureTable({

const rows = useMemo(
() => () =>
_referenceIds.map((referenceId) => {
const verses = versesFromReferenceIdAndBooks({ referenceId, books });
_referenceIds.map((referenceId) => {
const verses = versesFromReferenceIdAndBooks({ referenceId, books, defaultOriginalLangPostion});

const row = (
<Row
Expand Down Expand Up @@ -145,7 +146,7 @@ function ScriptureTable({
// onQuote={onQuote} // disable until round trip is working
occurrence={occurrence}
hasSingleVerse={!reference?.bcvQuery}
bookObject={books?.[0]?.json?.chapters}
bookObject={books?.[defaultOriginalLangPostion]?.json?.chapters}
refString={`${reference?.chapter}:${reference?.verse}`}
selections={selections}
onSelections={setSelections}
Expand Down
9 changes: 7 additions & 2 deletions src/components/parallel-scripture/ScriptureTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function Component ({reference}) {

const resourcesContext = React.useContext(ResourcesContext);
const resources = resourcesContext.state;
const resourceLinks = resourcesContext.state;
const defaultOriginalLangPostion = resources.resourceLinks.length - 1;

const [title, setTitle] = React.useState('');
const [titles, setTitles] = React.useState([]);
Expand Down Expand Up @@ -58,6 +60,7 @@ function Component ({reference}) {
onQuote={setQuote}
occurrence={occurrence}
height='250px'
defaultOriginalLangPostion={defaultOriginalLangPostion}
/>
</div>
</>
Expand Down Expand Up @@ -99,18 +102,18 @@ const occurrence=1;
import {ScriptureTable} from "scripture-resources-rcl";
import usfmJS from 'usfm-js';

import ugnt_tit from '../mocks/ugnt_tit.usfm.js';
import en_aligned_tit from '../mocks/en_aligned_tit.usfm.js';
import hi_aligned_tit from '../mocks/hi_aligned_tit.usfm.js';
import hi_tit from '../mocks/hi_tit.usfm.js';
import bhd_tit from '../mocks/bhd_tit.usfm.js';
import ugnt_tit from '../mocks/ugnt_tit.usfm.js';

const titles = [
'UGNT - Greek',
'English - ULT (aligned)',
'Hindi - IRV (aligned)',
'Hindi - ULB',
'Bhadrawahi - ULB',
'UGNT - Greek',
];

const books = [
Expand All @@ -126,6 +129,7 @@ const reference = {
chapter: 1,
verse: 3,
};
const defaultOriginalLangPostion = 0;

const [component, setComponent] = React.useState(<></>)
const [quote, setQuote] = React.useState("τοῦ σωτῆρος ἡμῶν θεοῦ");
Expand All @@ -142,6 +146,7 @@ React.useEffect(() => {
onQuote={setQuote}
occurrence={occurrence}
height='250px'
defaultOriginalLangPostion={defaultOriginalLangPostion}
/>
);
}, []);
Expand Down
4 changes: 2 additions & 2 deletions src/components/parallel-scripture/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const rangeFromVerseAndVerseKeys = (({ verseKeys, verseKey }) => {
return range;
});

export const versesFromReferenceIdAndBooks = ({ referenceId, books }) => {
export const versesFromReferenceIdAndBooks = ({ referenceId, books, defaultOriginalLangPostion }) => {
// console.log("versesFromReferenceIdAndBooks() referenceId,books=", referenceId,books)
const versesData = books.map((book, index) => {
const reference = referenceFromReferenceId(referenceId);
Expand Down Expand Up @@ -89,7 +89,7 @@ export const versesFromReferenceIdAndBooks = ({ referenceId, books }) => {
verseData = chapterData[range];
}

if (index === 0 && verseData && verseData.verseObjects && verseData.verseObjects.length) {
if (index === defaultOriginalLangPostion && verseData && verseData.verseObjects && verseData.verseObjects.length) {
const _verseData = { ...verseData };
_verseData.verseObjects = occurrenceInjectVerseObjects(_verseData.verseObjects);
verseData = _verseData;
Expand Down
2 changes: 2 additions & 0 deletions src/components/resources/Resources.context.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function ResourcesContextProvider({
config,
onResources,
children,
ORIGINAL_LANG_POSITION
}) {
const val = useResources({
resources: resources || [],
Expand All @@ -25,6 +26,7 @@ export function ResourcesContextProvider({
reference,
config,
onResources,
ORIGINAL_LANG_POSITION
});

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/resources/useResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function useResources({
config,
onResources,
onResourceLinks = () => { },
ORIGINAL_LANG_POSITION,
}) {
const [projectIdentifier, setProjectIdentifier] = useState();
const [usfmJsonArray, setUsfmJsonArray] = useState();
Expand Down Expand Up @@ -99,7 +100,7 @@ function useResources({
}, [parseUsfm, projectIdentifier]);

return {
state: { resources, books },
state: { resources, books, resourceLinks, ORIGINAL_LANG_POSITION},
actions: {
addResourceLink,
isDefaultResourceLink,
Expand Down