lib/main.js
function(project) {
        if(project.slug.toLowerCase() === 'obs'
            || project.slug.toLowerCase() === 'bible-obs'
            || project.slug.toLowerCase() === 'bible'
            || !project.chunks_url) return Promise.resolve();


        return request.read(project.chunks_url)
            .then(function(response) {
                // consume chunk data
                if(response.status !== 200) return Promise.reject(response);

                let data;
                try {
                    data = JSON.parse(response.data);
                } catch(err) {
                    console.log(project);
                    return Promise.reject(err);
                }

                try {
                    let language_id = library.addSourceLanguage({
                        slug: 'en',
                        name: 'English',
                        direction: 'ltr'
                    });

                    // TODO: retrieve the correct versification name(s) from the source language
                    let versification_id = library.addVersification({
                        slug: 'en-US',
                        name: 'American English'
                    }, language_id);


                    if (versification_id > 0) {
                        for (let chunk of data) {
                            library.addChunkMarker({
                                chapter: padSlug(chunk.chp, 2),
                                verse: padSlug(chunk.firstvs, 2)
                            }, project.slug, versification_id);
                        }
                    }
                } catch (err) {
                    return Promise.reject(err);
                }
            });
    }
function(project) {
        if(project.slug.toLowerCase() === 'obs'
            || project.slug.toLowerCase() === 'bible-obs'
            || project.slug.toLowerCase() === 'bible'
            || !project.chunks_url) return Promise.resolve();


        return request.read(project.chunks_url)
            .then(function(response) {
                // consume chunk data
                if(response.status !== 200) return Promise.reject(response);

                let data;
                try {
                    data = JSON.parse(response.data);
                } catch(err) {
                    console.log(project);
                    return Promise.reject(err);
                }

                try {
                    let language_id = library.addSourceLanguage({
                        slug: 'en',
                        name: 'English',
                        direction: 'ltr'
                    });

                    // TODO: retrieve the correct versification name(s) from the source language
                    let versification_id = library.addVersification({
                        slug: 'en-US',
                        name: 'American English'
                    }, language_id);


                    if (versification_id > 0) {
                        for (let chunk of data) {
                            library.addChunkMarker({
                                chapter: padSlug(chunk.chp, 2),
                                verse: padSlug(chunk.firstvs, 2)
                            }, project.slug, versification_id);
                        }
                    }
                } catch (err) {
                    return Promise.reject(err);
                }
            });
    }
function ( project ) { if ( project . slug . toLowerCase ( ) === 'obs' || project . slug . toLowerCase ( ) === 'bible-obs' || project . slug . toLowerCase ( ) === 'bible' || ! project . chunks_url ) return Promise . resolve ( ) ; return request . read ( project . chunks_url ) . then ( function ( response ) { // consume chunk data if ( response . status !== 200 ) return Promise . reject ( response ) ; let data ; try { data = JSON . parse ( response . data ) ; } catch ( err ) { console . log ( project ) ; return Promise . reject ( err ) ; } try { let language_id = library . addSourceLanguage ( { slug : 'en' , name : 'English' , direction : 'ltr' } ) ; // TODO: retrieve the correct versification name(s) from the source language let versification_id = library . addVersification ( { slug : 'en-US' , name : 'American English' } , language_id ) ; if ( versification_id > 0 ) { for ( let chunk of data ) { library . addChunkMarker ( { chapter : padSlug ( chunk . chp , 2 ) , verse : padSlug ( chunk . firstvs , 2 ) } , project . slug , versification_id ) ; } } } catch ( err ) { return Promise . reject ( err ) ; } } ) ; }
Downloads the chunks for a project
@param project {{}}
Downloads the chunks for a project