Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Kindle periodical format ebook generation tool
Ruby
Branch: master
Pull request Compare This branch is 2 commits ahead, 36 commits behind danchoi:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
templates
.gitignore
Gemfile
MIT-LICENSE.txt
README.markdown
Rakefile
_document.yml.sample
kindlerb.gemspec

README.markdown

kindlerb

kindlerb is a Ruby Kindle periodical-format ebook generator. I extracted this tool from kindlefeeder.com. I also built Kindlefodder on top of kindlerb.

kindlerb converts a file tree of sections, articles, images, and metadata into a MOBI periodical-formatted document for the Kindle. It is a wrapper around the kindlegen program from Amazon that hides the details for templating OPF and NCX files.

Requirements

  • Ruby 1.9.x.
  • Make sure kindlegen is on your PATH.

You can get kindlegen here.

Install

gem install kindlerb

How to use it

Run the program at the root of the file tree:

kindlerb [filetree dir]

The output will be a mobi document.

You can also use the generator inside a Ruby script - you can use it two ways:

Kindlerb.run # will pack everything and generate a .mobi in the current directory

Kindlerb.prepare_content(path) # build all the files required by kindlegen (opf, ncx, etc).
# you can customize whatever you want here - for instance, override the 'sections.html' files, etc
Kindlerb.generate_mobi(path) # generate the .mobi file.

The file tree input structure is

_document.yml
sections/
  000/
    _section.txt # contains section title
    000.html # an article
    001.html 
  001/
    _section.txt 
    000.html
    001.html 
    002.html

kindlerb will extract article titles from the <title> (in <head>) tag in the *.html files .

The _document.yml is a YAML document. It should look like something like this:

--- 
doc_uuid: kindlerb.21395-2011-12-19
title: my-ebook
author: my-ebook
publisher: me
subject: News
date: "2011-12-19"
masthead: /home/choi/Desktop/masthead.gif
cover: /home/choi/Desktop/cover.gif
mobi_outfile: my-ebook.mobi

kindlerb uses the the file tree and _document.yml to construct these additional resource required by Amazon's kindlegen program:

  • nav-contents.ncx
  • contents.html
  • kindlerb.opf

After that, kindlerb will exec the kindlegen program to generate your mobi document. The filename the output document is specified by the 'mobi_outfile' value in _document.yml.

Images

kindlerb will incorporate images into the generated ebook by parsing all the src attributes of all the <img> tags in your *.html files.

The src attributes must point to image files on the local filesystem. If the paths are relative, they should be relative to the target file tree root.

Encoding

Make sure all your textual source files are encoded in UTF-8.

Author

Daniel Choi

I'm indebted to mhl for writing the guardian-for-kindle MOBI generator in Python. kindlerb ported a bunch of ideas from that project over to Ruby.

Something went wrong with that request. Please try again.