Skip to content
This repository was archived by the owner on Jan 4, 2024. It is now read-only.
Open
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
296 changes: 242 additions & 54 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "autographa-lite",
"description": "A Bible translation editor for everyone.",
"version": "1.4.0-beta.2",
"version": "1.4.0-beta.3",
"main": "public/electron.js",
"author": "Friends of Agape <mail@joelmath.io>",
"license": "MIT",
Expand All @@ -14,6 +14,7 @@
"customize-cra": "^0.2.12",
"diff-match-patch": "^1.0.0",
"electron-squirrel-startup": "^1.0.0",
"electronite": "^6.0.7",
"fs-jetpack": "^1.0.0",
"jquery": "^3.3.1",
"leveldown": "^5.0.0-2",
Expand Down Expand Up @@ -48,6 +49,8 @@
"src/**/*.*",
"patterns.prop"
],
"electronVersion": "null",
"electronDist": "./node_modules/electronite/dist",
"directories": {
"buildResources": "resources"
},
Expand Down Expand Up @@ -84,16 +87,16 @@
"scripts": {
"start": "concurrently \"npm run react-start\" \"wait-on http://localhost:3000/ && cross-env NODE_ENV=development npm run electron-start\"",
"build": "npm run build:electron",
"electron-start": "electron .",
"electron-start": "electronite .",
"electron-build": "electron-packager ./build --out=dist",
"react-start": "craco start",
"react-build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
"build:electron": "craco build --config craco.config.js main=build/electron.js",
"preelectron-pack": "npm run build",
"electron-pack": "electron-builder --x64 --win --linux --mac -p never",
"deploy": "electron-builder --x64 --win --linux --mac -p always"
"electron-pack": "electron-builder -p never",
"deploy": "electron-builder -p always"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -110,7 +113,6 @@
"babel-plugin-react-intl": "^3.0.1",
"concurrently": "^5.1.0",
"cross-env": "^5.2.0",
"electron": "^6.0.9",
"electron-builder": "^21.2.0",
"electron-packager": "^13.1.1",
"electron-rebuild": "^1.8.4",
Expand Down
17 changes: 15 additions & 2 deletions src/assets/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8471,7 +8471,7 @@ ul {
background-color: #f5f5f5 !important; }

#bookdata {
padding-top: 20px; }
padding-top: 0px; }

.translation {
font-weight: bold; }
Expand Down Expand Up @@ -8528,7 +8528,12 @@ button .caret {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
color: #0b82ff;
font-weight: bold; }
font-weight: bold;
display: inline-block;
white-space: nowrap;
max-width: 12em;
overflow: hidden;
text-overflow: ellipsis; }

#chapterBtn {
color: #0b82ff;
Expand Down Expand Up @@ -8919,4 +8924,12 @@ div::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
background-color: darkgrey;
outline: 1px solid slategrey;
}
.booklistcollapse {
display: inline-block;
white-space: nowrap;
max-width: 10em;
overflow: hidden;
text-overflow: ellipsis;
font-size: 14px;
}
2 changes: 2 additions & 0 deletions src/components/AutographaStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class AutographaStore {
@observable chapterActive = 1
@observable currentRef = 'eng_ult'
@observable bookData = Constant.booksList
@observable editbookData = Constant.booksEditList
@observable translatedBookNames = null
@observable openBookNameEditor = false
@observable updatedTranslatedBookNames = ''
Expand Down Expand Up @@ -67,6 +68,7 @@ export class AutographaStore {
@observable errorFile = []
@observable warningMsg = []
@observable bookindex = null
@observable setTransfont = ''

constructor(bookId, chapterId, bookChapter, activeTab, showModalBooks, bookChapterContent, chunkGroup, content, currentRef, booksList, selectId) {

Expand Down
5 changes: 3 additions & 2 deletions src/components/BookNameEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default function BookNameEditor({ show }) {
<Modal.Body style={{ height: '150px' }}>
<span>
<TextField
style={{ marginRight: '10px' }}
style={{ marginRight: '10px', fontFamily: "Awami Nastaliq" }}
value={AutographaStore.bookName}
name='defaultValue'
id='defaultValue'
Expand All @@ -143,10 +143,11 @@ export default function BookNameEditor({ show }) {
hintText={message}
onChange={onChange}
required
style={{ fontFamily: "Awami Nastaliq" }}
value={updatedValue || ''}
name='updatedValue'
id='updatedValue'
maxLength={20}
maxLength={100}
/>
)}
</FormattedMessage>
Expand Down
43 changes: 34 additions & 9 deletions src/components/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Navbar extends React.Component {
super(props);
this.handleRefChange = this.handleRefChange.bind(this);
this.getData = this.getData.bind(this);
this.fontChange = this.fontChange.bind(this)
this.state = {
showModal: false,
showModalSettings: false,
Expand All @@ -52,6 +53,9 @@ class Navbar extends React.Component {
toggled: false,
setDiff: false,
toggleEdit: false,
setFont1: "",
setFont2: "",
setFont3: ""
};

var verses, chapter;
Expand All @@ -78,6 +82,7 @@ class Navbar extends React.Component {
this.resetDiffValue();
}
componentDidMount() {
this.fontChange()
db.get('translatedBookNames', function (err, doc) {
if (err) {
localStorage.setItem('editBookNamesMode', false);
Expand All @@ -99,6 +104,20 @@ class Navbar extends React.Component {
})
AutographaStore.editBookNamesMode = localStorage.getItem('editBookNamesMode');
}

fontChange() {
let options = ['eng_ult', 'eng_ust', 'hin_irv']
if((options.indexOf(AutographaStore.activeRefs[0]) === -1))
this.setState({setFont1: "Awami Nastaliq"})
else this.setState({ setFont1: "" })
if((options.indexOf(AutographaStore.activeRefs[1]) === -1))
this.setState({ setFont2: "Awami Nastaliq" })
else this.setState({ setFont2: "" })
if((options.indexOf(AutographaStore.activeRefs[2]) === -1))
this.setState({ setFont3: "Awami Nastaliq" })
else this.setState({ setFont3: "" })
}

getContent = (id, chapter) => {
return refDb.get(id).then((doc) => {
for (var i = 0; i < doc.chapters.length; i++) {
Expand Down Expand Up @@ -464,6 +483,7 @@ class Navbar extends React.Component {
if (error)
console.log(error);
});
this.fontChange(event.target.value);
}
isSameLanguage = async () => {
const verseLangCode = "",
Expand Down Expand Up @@ -762,18 +782,22 @@ class Navbar extends React.Component {
</div>
) : ''
}
<Tab eventKey={1} title="Book" >
<Tab eventKey={1} title="Book" style={{ height: '450px', overflow: 'auto'}}>
<div className="wrap-center"></div>
<div className="row books-li" id="bookdata">
<ul id="books-pane">
{AutographaStore.translatedBookNames !== null && (
bookData.map((item, index) => {
return <li key={index} >
<Link key={index} style={{ cursor: 'pointer' }} onClick={this.onItemClick.bind(this, item, index)}
<Link key={index} style={{ cursor: 'pointer', fontFamily: "Awami Nastaliq", padding: '0px', fontSize:"small"}} onClick={this.onItemClick.bind(this, item, index)}
value={item} onMouseEnter={this.handlepopper} className={(AutographaStore.bookName === item) ? 'link-active' : ""} >
{item}
<span className="booklistcollapse">
{item}
</span>
<Tooltip TransitionComponent={Zoom} placement="top" title="edit">
<span>
<EditIcon key={index} style={{ cursor: 'pointer', marginLeft: "9px" }} hidden={AutographaStore.bookindex !== index} onClick={this.editbooks} />
</span>
</Tooltip>
</Link>
</li>
Expand Down Expand Up @@ -833,6 +857,7 @@ class Navbar extends React.Component {
data-placement="bottom"
title="Select Book"
id="book-chapter-btn"
style={{ fontFamily: "Awami Nastaliq"}}
>
{bookName}
</a>
Expand Down Expand Up @@ -895,27 +920,27 @@ class Navbar extends React.Component {
{
AutographaStore.layout === 1 &&
<div className="parentdiv">
<div className="layoutx"> <Reference onClick={this.handleRefChange.bind(this, 0)} refIds={AutographaStore.activeRefs[0]} id={1} layout={1} /><ReferencePanel refContent={refContent} /></div>
<div className="layoutx"> <Reference onClick={this.handleRefChange.bind(this, 0)} refIds={AutographaStore.activeRefs[0]} id={1} layout={1} /><ReferencePanel refContent={refContent} font={this.state.setFont1} /></div>
<div style={{ padding: "10px" }} className="layoutx"><TranslationPanel onSave={this.saveTarget} tIns={AutographaStore.tIns[0]} tDel={AutographaStore.tDel[0]} /></div>
</div>
}
{
AutographaStore.layout === 2 &&
<div className="parentdiv">
<div className="layout2x"><Reference onClick={this.handleRefChange.bind(this, 0)} refIds={AutographaStore.activeRefs[0]} id={21} layout={1} /><ReferencePanel refContent={refContent} refIds={AutographaStore.activeRefs[0]} /></div>
<div className="layout2x"><Reference onClick={this.handleRefChange.bind(this, 0)} refIds={AutographaStore.activeRefs[0]} id={21} layout={1} /><ReferencePanel refContent={refContent} refIds={AutographaStore.activeRefs[0]} font={this.state.setFont1} /></div>

<div className="layout2x"><Reference onClick={this.handleRefChange.bind(this, 1)} refIds={AutographaStore.activeRefs[1]} id={22} layout={2} /><ReferencePanel refContent={refContentOne} refIds={AutographaStore.activeRefs[1]} tIns={AutographaStore.tIns[1]} tDel={AutographaStore.tDel[1]} /></div>
<div className="layout2x"><Reference onClick={this.handleRefChange.bind(this, 1)} refIds={AutographaStore.activeRefs[1]} id={22} layout={2} /><ReferencePanel refContent={refContentOne} refIds={AutographaStore.activeRefs[1]} tIns={AutographaStore.tIns[1]} tDel={AutographaStore.tDel[1]} font={this.state.setFont2} /></div>
<div style={{ padding: "10px" }} className="layout2x"><TranslationPanel onSave={this.saveTarget} tIns={AutographaStore.tIns[0]} tDel={AutographaStore.tDel[0]} /></div>
</div>
}
{
AutographaStore.layout === 3 &&
<div className="parentdiv">
<div className="layout3x"><Reference onClick={this.handleRefChange.bind(this, 0)} refIds={AutographaStore.activeRefs[0]} id={31} layout={1} /><ReferencePanel refContent={refContent} refIds={AutographaStore.activeRefs[0]} /></div>
<div className="layout3x"><Reference onClick={this.handleRefChange.bind(this, 0)} refIds={AutographaStore.activeRefs[0]} id={31} layout={1} /><ReferencePanel refContent={refContent} refIds={AutographaStore.activeRefs[0]} font={this.state.setFont1} /></div>

<div className="layout3x"><Reference onClick={this.handleRefChange.bind(this, 1)} refIds={AutographaStore.activeRefs[1]} id={32} layout={2} /><ReferencePanel refContent={refContentOne} refIds={AutographaStore.activeRefs[1]} tIns={AutographaStore.tIns[1]} tDel={AutographaStore.tDel[1]} /></div>
<div className="layout3x"><Reference onClick={this.handleRefChange.bind(this, 1)} refIds={AutographaStore.activeRefs[1]} id={32} layout={2} /><ReferencePanel refContent={refContentOne} refIds={AutographaStore.activeRefs[1]} tIns={AutographaStore.tIns[1]} tDel={AutographaStore.tDel[1]} font={this.state.setFont2} /></div>

<div className="layout3x"><Reference onClick={this.handleRefChange.bind(this, 2)} refIds={AutographaStore.activeRefs[2]} id={33} layout={3} /><ReferencePanel refContent={refContentTwo} refIds={AutographaStore.activeRefs[2]} tIns={AutographaStore.tIns[2]} tDel={AutographaStore.tDel[2]} /></div>
<div className="layout3x"><Reference onClick={this.handleRefChange.bind(this, 2)} refIds={AutographaStore.activeRefs[2]} id={33} layout={3} /><ReferencePanel refContent={refContentTwo} refIds={AutographaStore.activeRefs[2]} tIns={AutographaStore.tIns[2]} tDel={AutographaStore.tDel[2]} font={this.state.setFont3} /></div>
<div style={{ padding: "10px" }} className="layout3x"><TranslationPanel onSave={this.saveTarget} tIns={AutographaStore.tIns[0]} tDel={AutographaStore.tDel[0]} /></div>
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReferencePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ReferencePanel extends React.Component {
<div className="col-sm-12 col-fixed" onClick={this.copiedSelection} id="section-0">
{tIns || tDel ? <div style={{ textAlign: 'center' }}><span style={{ color: '#27b97e', fontWeight: 'bold' }}>(+) {tIns}</span> | <span style={{ color: '#f50808', fontWeight: 'bold' }}> (-) {tDel}</span></div> : ""}
<div className="row">
<div dangerouslySetInnerHTML={{ __html: this.props.refContent }} className="col-12 col-ref" style={{ whiteSpace: "pre-wrap" }}></div>
<div dangerouslySetInnerHTML={{ __html: this.props.refContent }} className="col-12 col-ref" style={{ whiteSpace: "pre-wrap", fontFamily: this.props.font }}></div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class SettingsModal extends React.Component {
targetPath: folderPath,
langScript: AutographaStore.scriptDirection.toUpperCase()
};
(AutographaStore.scriptDirection === 'RTL') ? AutographaStore.setTransfont = 'Awami Nastaliq' : AutographaStore.setTransfont = '' ;
db.get("targetBible").then(
doc => {
settingData._rev = doc._rev;
Expand Down
14 changes: 11 additions & 3 deletions src/components/TranslationPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ContextMenu, MenuItem, ContextMenuTrigger } from 'react-contextmenu';
import '../assets/stylesheets/context-menu.css';
const i18n = new(require('../translations/i18n'));
const db = require(`${__dirname}/../util/data-provider`).targetDb();
let verseId = 0;
let verseId = 0, langdir;

@observer
class TranslationPanel extends React.Component {
Expand All @@ -17,7 +17,15 @@ class TranslationPanel extends React.Component {
if(res) AutographaStore.scriptDirection = "rtl"
});
this.timeout = 0;
}
}

componentDidMount(){
db.get("targetBible").then(
doc => {
langdir = doc.langScript.toUpperCase();
(langdir === 'RTL') ? AutographaStore.setTransfont = 'Awami Nastaliq' : AutographaStore.setTransfont = '' ;
});
}

highlightRef(vId, refId, obj) {
{/*var content = ReactDOM.findDOMNode(this);
Expand Down Expand Up @@ -183,7 +191,7 @@ class TranslationPanel extends React.Component {
const toggle = AutographaStore.toggle;
for (let i = 0; i < AutographaStore.chunkGroup.length; i++) {
let vid="v"+(i+1);
verseGroup.push(<div key={i} id={`versediv${i+1}`} onClick={this.highlightRef.bind(this, vid, i)} style={{cursor: "text", whiteSpace: "pre-wrap"}}>
verseGroup.push(<div key={i} id={`versediv${i+1}`} onClick={this.highlightRef.bind(this, vid, i)} style={{cursor: "text", whiteSpace: "pre-wrap", fontFamily: AutographaStore.setTransfont}}>
<ContextMenuTrigger id={(AutographaStore.jointVerse[i] === undefined ? "true" : "false")} disable={(i+1) === 1 ? true : false } verseId = {parseInt(i,10)+1} collect = {props => props}><span className='verse-num' key={i}>{(i+1)}</span>
<span contentEditable={AutographaStore.jointVerse[i] === undefined ? true : false} suppressContentEditableWarning={true} id={vid} data-chunk-group={AutographaStore.chunkGroup[i]} onKeyUp={this.handleKeyUp}>
{AutographaStore.jointVerse[i] === undefined ? AutographaStore.translationContent[i] : <FormattedMessage id="label-joint-with-the-preceding-verse(s)"/>}
Expand Down
2 changes: 1 addition & 1 deletion src/util/export_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
${ column == 1 ? css_1_col_rtl : css_2_col_rtl }
</head>
<body class="body">
<center><h1>${currentBookname}</h1></center>
<center><h1 style="font-family: 'Awami Nastaliq'">${currentBookname}</h1></center>
<div class="newspaper">`
var contentFlag = false;
db.get(currentBook._id).then(function(doc) {
Expand Down
17 changes: 11 additions & 6 deletions src/util/usfm_to_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
refDb = require(`${__dirname}/../util/data-provider`).referenceDb(),
c = 0,
v = 0,
id='',
vnum = 0,
usfmBibleBook = false,
validLineCount = 0,
Expand All @@ -48,6 +49,7 @@ module.exports = {
} else if (splitLine[0] === '\\id') {
if (booksCodes.includes(splitLine[1].toUpperCase()))
usfmBibleBook = true;
id = splitLine[1]
book._id = id_prefix + splitLine[1].toUpperCase();
} else if (splitLine[0] === '\\c') {
book.chapters[parseInt(splitLine[1], 10) - 1] = {
Expand Down Expand Up @@ -107,10 +109,9 @@ module.exports = {

} else if (splitLine[0].match(new RegExp(/\\mt$/gm))) {
let cleanedStr = replaceMarkers(line);
let bookid = book._id.split(/_+/)
if (booksCodes.includes(bookid[2].toUpperCase())){
if (booksCodes.includes(id.toUpperCase())){
let userBookList = AutographaStore.translatedBookNames
userBookList.splice(booksCodes.indexOf(bookid[2]), 1, cleanedStr)
userBookList.splice(booksCodes.indexOf(id), 1, cleanedStr)
}
} else if (splitLine[0].startsWith('\\s')) {
//Do nothing for section headers now.
Expand All @@ -119,10 +120,13 @@ module.exports = {
} else if (splitLine[0].match(new RegExp(/\\m$/gm))) {
let cleanedStr = replaceMarkers(line);
cleanedStr = "\n" + cleanedStr;
book.chapters[c - 1].verses[vnum - 1].verse += ((cleanedStr.length === 0 ? '' : ' ') + cleanedStr);
let verseIndex = book.chapters[c - 1].verses.findIndex(val => val.verse_number === vnum);
if(book.chapters[c - 1].verses[verseIndex].verse !== undefined) {
book.chapters[c - 1].verses[verseIndex].verse += ((cleanedStr.length === 0 ? '' : ' ') + cleanedStr);
}
} else if (splitLine[0].startsWith('\\r')) {
// Do nothing here for now.
} else if (c > 0 && vnum > 0) {
} else if (c > 0 && v > 0) {
var qflag = false;
if(line.match(new RegExp(/[\\q\n]/g))){
qflag = true
Expand All @@ -131,7 +135,8 @@ module.exports = {
if(qflag === false){
cleanedStr = "\n" + cleanedStr;
}
book.chapters[c - 1].verses[vnum - 1].verse += ((cleanedStr.length === 0 ? '' : ' ') + cleanedStr);
let verseIndex = book.chapters[c - 1].verses.findIndex(val => val.verse_number === vnum);
book.chapters[c - 1].verses[verseIndex].verse += ((cleanedStr.length === 0 ? '' : ' ') + cleanedStr);
}

});
Expand Down