0.5.3 • Published 8 years ago

epub-press-js v0.5.3

Weekly downloads
11
License
GPL-3.0+
Repository
github
Last release
8 years ago

epub-press-js

npm npm

A javascript client for building books with EpubPress.

Install

npm install --save epub-press-js

Test

Unit Tests

npm test

Browser Test

open tests/browserTest.html

NodeJS Test

node tests/nodeTest.js

Build

# Single build
npm run-script build

# Build + watch
npm start

Usage

Browser
<script src="node_modules/epub-press-js/build/index.js"></script>
<script>var EpubPress = window.EpubPress;</script>
NodeJS
const EpubPress = require('epub-press-js');
Creating a Book
const ebook = new EpubPress({
    title: 'Best of HackerNews',
    description: 'Favorite articles from HackerNews in May, 2016',
    sections: [
        {
            url: 'http://medium.com/@techBlogger/why-javascript-is-dead-long-live-php',
            html: '<html><body><p>Lulz.</p></body></html>',
        }
    ]
});

// OR

const ebook = new EpubPress({
    title: 'Best of HackerNews',
    description: 'Favorite articles from HackerNews in May, 2016',
    urls: [
        'http://medium.com/@techBlogger/why-js-is-dead-long-live-php'
    ]
});
Publishing
ebook.publish().then(() =>
    ebook.download();  // Default epub
    // or ebook.email('epubpress@gmail.com')
).then(() => {
    console.log('Success!');
}).catch((error) => {
    console.log(`Error: ${error}`);
});
Checking Status
ebook.checkStatus().then((status) => {

}).catch((error) => {});
Event Listening
const onStatusUpdate = (status) => { console.log(status.message); };

// Adding callback
ebook.on('statusUpdate', onStatusUpdate);

// Removing callback
ebook.removeListener('statusUpdate', onStatusUpdate)
Check for updates
// epub-press-js updates
EpubPress.checkForUpdates().then((message) => {
    console.log(message); // Undefined if no update required
});

// epub-press-chrome updates
EpubPress.checkForUpdates('epub-press-chrome', '0.9.0').then((message) => {
    console.log(message);
});

API

new EpubPress(metadata) => ebook
  • metadata.sections: Object with the url and html for a chapter.
  • metadata.urls: Array of urls.
  • metadata.title: Title for the book.
  • metadata.description: Description for the book.
  • metadata.filetype: File format to use for downloads.
ebook.publish() => Promise
ebook.download(filetype) => Promise
  • filetype: 'mobi' or 'epub' (Default 'epub')
ebook.email(email, filetype) => Promise
  • filetype: 'mobi' or 'epub' (Default 'epub')
  • email: Email address to deliver ebook to.
ebook.checkStatus() => Promise => status
  • status.progress: Percentage complete. (0 -> 100)
  • status.message: Status message.
ebook.on('statusUpdate', (status) => {}) => callback
  • status.progress: Percentage complete. (0 -> 100)
  • status.message: Description of current step.
ebook.removeListener(eventName, callback)
  • eventName: Name of the event callback exists on.
  • callback: Listener to be removed.
EpubPress.checkForUpdates(clientName, clientVersion) => Promise => Update Message | undefined
  • clientName: EpubPress client library to check. (Default: epub-press-js)
  • clientVersion: Version of client. (Default: EpubPress.VERSION)

Issues

  • Safari downloads the file as Unknown. You then must manually add the file extension (eg. .epub or .mobi)

Feel free to report any other issues:

Related

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.3

10 years ago

0.0.1

10 years ago