Code Monkey home page Code Monkey logo

epub2web's Introduction

epub2web Epub Reading System

What it Does

All-purpose, open source library for Epub content browsing and display. Combines epub-cache with epub2html in order to make Epub content readable via a browser, without special plugins, extensions or hacks.

Installing

npm install epub2web

Usage

See the examples in the test folder. The main test will set up a rudimentary web server to illustrate what's possible. The singlebook variation is to demonstrate how you might serve a single book on one address, and the multibook variation shows how you might add directory indexing to create browsable lists of epub content for a catalog.

epub2web's People

Stargazers

aparkerdavid avatar JUNLU avatar Science而后行 avatar  avatar Jon Knebel avatar  avatar todo6 avatar  avatar 迎江 avatar Dmitry avatar Toby Callinan avatar Guy Micciche avatar Ezra Lalonde avatar  avatar Sangcheol Park avatar MOxFIVE avatar Jason Tudisco avatar  avatar SeongHyeon Cho avatar Lanhui Ou avatar Nazeeruddin Ikram avatar Marco Nucara avatar Zaenal avatar Kim Plowright avatar Ricardo Dantas avatar johannes kolbe avatar  avatar Shuhei Kagawa avatar Gambhiro avatar DJ Verlinden avatar

Watchers

Kjetil Midtlie avatar James Cloos avatar Joe (The Don) Kumoye avatar 王刚 avatar  avatar Edam avatar

epub2web's Issues

epubdir does not differentiate between two dirs

Hi,

I'm using two routes - one for reading sample and one for reading full-book. And ofcourse for sample, I don't have to worry about if user purchased the book or not. While for full-book, I have to...
hence, I'm separating the epub2web in to two cachedir - one call it as "sample" in a sample nodejs route and another one call it - "bookreader" dir in its own route.
So, a user first clicks on sample and reads the book ok - a json and book gets created under sample directory just fine and reads just fine.
Now, when a user buys a book and then clicks on read book (fullbook) - server attaches a different cachedir called - "bookreader" however the actual book and json still gets created in the old "sample" folder even though I'm attaching "bookreader" cache directory.

Any ideas why this is occuring?

Thanks-

app.get('/lookinside...) {
    var cacheDir = "./public/sample";
                        var myTemplateName = 'template1';
                        var myTemplateHtml = fs.readFileSync('./public/testreader2.html');
                        var bookfile = linkToBook;
                        var epubDir = cacheDir;
                        // add custom reading template
                        epub2web.attach(cacheDir);
                        epub2web.addTemplate(myTemplateName, myTemplateHtml.toString());
                        epub2web.attach(cacheDir);
                        // attach to any cache dir you want for cache location of exploded epubs
                        epub2web.webify(
                            linkToBook, /* full path of epub file */
                            myTemplateName, /* template name for reading system */
                            function (err, cacheId, htmlApp) { /* callback after webify complete */

                                // the htmlApp is the whole reading system,
                                // fully configured for this cacheId, so
                                // just pass it right to the browser

                                var cacheurl = '/sample/' + cacheId + '/' + req.query.eid ;
                                res.writeHead(302, {
                                    'Location': cacheurl
                                });
                                res.end();
                            });
}

app.get('/readfullbook...) {
             var cacheDir = "./public/bookreader";;
                        var myTemplateName = 'template2';
                        var myTemplateHtml = fs.readFileSync('./public/testreader.html');
                        var bookfile = linkToBook;
                        var epubDir = cacheDir;
                        // add custom reading template
                        epub2web.attach(cacheDir);
                        epub2web.addTemplate(myTemplateName, myTemplateHtml.toString());
                        // attach to any cache dir you want for cache location of exploded epubs
                        epub2web.attach(cacheDir);
                        epub2web.webify(
                            linkToBook, /* full path of epub file */
                            myTemplateName, /* template name for reading system */
                            function (err, cacheId, htmlApp) { /* callback after webify complete */

                                // the htmlApp is the whole reading system,
                                // fully configured for this cacheId, so
                                // just pass it right to the browser

                                var cacheurl = '/bookreader/' + cacheId + '/' + req.query.eid;
                                logger.verbose("/readbook cacheurl:" + cacheurl);
                                res.writeHead(302, {
                                    'Location': cacheurl
                                });
                                res.end();
                            });


}

test.js fails to start

When I run node test/test.js, or any js file in the test directory, this happens:

/Users/nick/node_modules/epub2web/lib/epub2web.js:12
var parser = cacher.getParser();
                    ^
TypeError: Object #<Object> has no method 'getParser'
    at Object.<anonymous> (/Users/nick/node_modules/epub2web/lib/epub2web.js:12:21)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/Users/nick/node_modules/epub2web/index.js:1:80)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.