Giter Club home page Giter Club logo

js-epub-maker's Introduction

js-epub-maker

MIT License Build Status Code Climate Codacy Badge

js-epub-maker allows you to create and download epubs. It offers an API through which you can set meta info, navigation and content. js-epub-maker works by gutting IDPF's sample epub and refitting it with your content. The source epub this project is working with is The Waste Land (source code).

Demo in jsfiddle

Installing

npm install epub-maker --save

API: Sections

There is some API to set all the meta-data, but the magic is in the way you can add sections. With sections you can add either all content with just one section, or finetune all the content so that it snugly fits the epub spec (with the various epub types described in the spec) and more importantly allows you to indicate exactly what should be included in the TOC and Landmarks section of the epub. You don't need to take care of all that, js-epub-maker will do that for you.

/**
 * @epubType Optional. Allows you to add specific epub type content such as [epub:type="titlepage"]
 * @id Optional, but required if section should be included in toc and / or landmarks
 * @content Optional. Should not be empty if there will be no subsections added to this section. Format: { title, content }
 */
EpubMaker.Section = function(epubType, id, content, includeInToc, includeInLandmarks) {
    ...
}

API example

Taken from the included test page, which is reproduced in the online demo.

new EpubMaker()
    .withUuid('github.com/bbottema/js-epub-maker::it-came-from::example-using-idpf-wasteland')
    .withTemplate('idpf-wasteland')
    .withAuthor('T. Est')
    .withLanguage('en-GB')
    .withModificationDate(new Date(2015, 8, 7))
    .withRights({
        description: 'This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.',
        license: 'http://creativecommons.org/licenses/by-sa/3.0/'
    })
    .withAttributionUrl('https://github.com/bbottema/js-epub-maker')
    .withStylesheetUrl('src/test/content-for-epub/extra_styles.css')
    .withCover('src/test/content-for-epub/js-epub-maker-cover.jpg', {
        license: 'http://creativecommons.org/licenses/by-sa/3.0/',
        attributionUrl: 'http://www.webestools.com/web20-title-generator-logo-title-maker-online-web20-effect-reflect-free-photoshop.html'
    })
    .withTitle('It Came From... [Example Using Waste Land Template]')
    .withSection(new EpubMaker.Section('frontmatter', 'frontmatter', { title: 'Title page' }, false, true)
        .withSubSection(new EpubMaker.Section('titlepage', 'manuscript-header', header, false, false))
    )
    .withSection(new EpubMaker.Section('bodymatter', 'bodymatter', { title: 'Start of the story' }, false, true)
        .withSubSection(new EpubMaker.Section('preface', 'preface', preface, true, false))
        .withSubSection(new EpubMaker.Section('part', 'part-1', { title: 'Part 1' }, true, false)
            .withSubSection(new EpubMaker.Section('chapter', 'chapter-1', ch1, true, false))
            .withSubSection(new EpubMaker.Section('chapter', 'chapter-2', ch2, true, false))
        )
        .withSubSection(new EpubMaker.Section('part', 'part-2', { title: 'Part 2' }, true, false)
            .withSubSection(new EpubMaker.Section('chapter', 'chapter-3', ch3, true, false))
            .withSubSection(new EpubMaker.Section('chapter', 'chapter-4', ch4, true, false))
        )
    )
    .withSection(new EpubMaker.Section('backmatter', 'backmatter', { title: 'Notes and rest' }, false, true)
        .withSubSection(new EpubMaker.Section('rearnotes', 'rear-notes', { title: 'Notes on "It Came From"' }, true, false)
            .withSubSection(new EpubMaker.Section('rearnote', 'rearnote-1', rn1, false, false))
            .withSubSection(new EpubMaker.Section('rearnote', 'rearnote-2', rn2, false, false))
        )
    )
    .downloadEpub();

Running demo locally

To run the demo yourself:

gulp demo

Building js-epub-maker

npm install
npm install -g bower
npm install -g gulp
bower install

gulp clean build

js-epub-maker's People

Contributors

bbottema avatar lelinhtinh avatar johnmave126 avatar baivong avatar

Watchers

James Cloos avatar  avatar  avatar

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.