kindlerb 0.1.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -1
- data/Gemfile +3 -3
- data/MIT-LICENSE.txt +21 -21
- data/{README.markdown → README.md} +139 -111
- data/Rakefile +71 -71
- data/_document.yml.sample +7 -7
- data/bin/setupkindlerb +6 -0
- data/kindlerb.gemspec +25 -26
- data/lib/kindlerb.rb +232 -146
- data/templates/contents.mustache +19 -19
- data/templates/ncx.mustache +37 -37
- data/templates/opf.mustache +42 -42
- data/templates/section.mustache +15 -15
- metadata +18 -22
- data/bin/kindlerb +0 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4cab5c3ffc932e8c475b229d29b77fcd403cedc0
|
4
|
+
data.tar.gz: 55c0bceb12bb7e190b65ce1a2450229c5fb2ff55
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45f6cad989b027854eaa0f788f3290f2749ec206bd785917cc1c79c77d1a58499a9d6727fcd4236801573ef83ee8cb8b8e021aee3b3c258fe6fa733476a3bc0f
|
7
|
+
data.tar.gz: a2124e7d8f7ebc1dcb2765ecd95addfa6b0b64bd52ca830a66e528001c306d91cadc90faf0390c6ae2aca0b520235c1520332ea0bd4c5aff58a28b97d5635e05
|
data/.gitignore
CHANGED
@@ -1 +1 @@
|
|
1
|
-
testtree/
|
1
|
+
testtree/
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
gem 'nokogiri'
|
3
|
-
gem 'mustache'
|
1
|
+
|
2
|
+
gem 'nokogiri'
|
3
|
+
gem 'mustache'
|
data/MIT-LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
Copyright (c) 2010 Daniel Choi, http://danielchoi.com/software/
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|
1
|
+
Copyright (c) 2010 Daniel Choi, http://danielchoi.com/software/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
@@ -1,111 +1,139 @@
|
|
1
|
-
# kindlerb
|
2
|
-
|
3
|
-
kindlerb is a Ruby Kindle periodical-format ebook generator.
|
4
|
-
|
5
|
-
top of kindlerb.
|
6
|
-
|
7
|
-
[kf1]:http://kindlefeeder.com
|
8
|
-
[kf2]:https://github.com/danchoi/kindlefodder
|
9
|
-
|
10
|
-
kindlerb converts a file tree of sections, articles, images, and metadata into
|
11
|
-
a MOBI periodical-formatted document for the Kindle. It is a wrapper around the
|
12
|
-
`kindlegen` program from Amazon that hides the details for templating OPF and NCX
|
13
|
-
files.
|
14
|
-
|
15
|
-
## Requirements
|
16
|
-
|
17
|
-
* Ruby 1.9.x.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
1
|
+
# kindlerb
|
2
|
+
|
3
|
+
kindlerb is a Ruby Kindle periodical-format ebook generator. This tool was initially extracted from
|
4
|
+
[kindlefeeder.com][kf1]. [Kindlefodder][kf2] was also built on
|
5
|
+
top of kindlerb.
|
6
|
+
|
7
|
+
[kf1]:http://kindlefeeder.com
|
8
|
+
[kf2]:https://github.com/danchoi/kindlefodder
|
9
|
+
|
10
|
+
kindlerb converts a file tree of sections, articles, images, and metadata into
|
11
|
+
a MOBI periodical-formatted document for the Kindle. It is a wrapper around the
|
12
|
+
`kindlegen` program from Amazon that hides the details for templating OPF and NCX
|
13
|
+
files.
|
14
|
+
|
15
|
+
## Requirements
|
16
|
+
|
17
|
+
* Ruby 1.9.x.
|
18
|
+
|
19
|
+
## Installation and Setup
|
20
|
+
|
21
|
+
Add `gem 'kindlerb', github: 'danchoi/kindlerb'` to your Gemfile then run
|
22
|
+
```
|
23
|
+
bundle install
|
24
|
+
bundle binstubs kindlerb
|
25
|
+
```
|
26
|
+
Then **cd** into your app root and then run the below command - this will install the required Kindlegen package:
|
27
|
+
`./bin/setupkindlerb`
|
28
|
+
|
29
|
+
You're good to go!
|
30
|
+
|
31
|
+
**OR**
|
32
|
+
|
33
|
+
run `gem install kindlerb`
|
34
|
+
|
35
|
+
Then **cd** into your app root and then run the below command - this will install the required Kindlegen package:
|
36
|
+
`setupkindlerb`
|
37
|
+
|
38
|
+
You're good to go!
|
39
|
+
|
40
|
+
## How to use it
|
41
|
+
|
42
|
+
Require kindlerb in your project.
|
43
|
+
|
44
|
+
require 'kindlerb'
|
45
|
+
|
46
|
+
### Kindlerb.run(target_dir, verbose, compression_method)
|
47
|
+
|
48
|
+
Only the first argument is mandatory, everything else will use default values if no arguments are provided.
|
49
|
+
|
50
|
+
**target_dir** = Put the directory that contains your ebook files
|
51
|
+
|
52
|
+
**verbose** = true or false. Default is false.
|
53
|
+
|
54
|
+
**compression_method** = 'c0' (no compression) OR 'c1' (standard DOC compression) OR 'c2' (Kindle huffdic compression). Default is 'c2'.
|
55
|
+
|
56
|
+
The output will be a mobi document.
|
57
|
+
|
58
|
+
**target_dir** should include the below files and structure:
|
59
|
+
|
60
|
+
_document.yml
|
61
|
+
sections/
|
62
|
+
000/
|
63
|
+
_section.txt # contains section title
|
64
|
+
000.html # an article
|
65
|
+
001.html
|
66
|
+
001/
|
67
|
+
_section.txt
|
68
|
+
000.html
|
69
|
+
001.html
|
70
|
+
002.html
|
71
|
+
|
72
|
+
kindlerb will extract article titles from the `<title>` (in `<head>`) tag in
|
73
|
+
the *.html files .
|
74
|
+
|
75
|
+
The _document.yml is a YAML document. It should look like something like this:
|
76
|
+
|
77
|
+
---
|
78
|
+
doc_uuid: kindlerb.21395-2011-12-19
|
79
|
+
title: my-ebook
|
80
|
+
author: my-ebook
|
81
|
+
publisher: me
|
82
|
+
subject: News
|
83
|
+
date: "2011-12-19"
|
84
|
+
masthead: /home/choi/Desktop/masthead.gif
|
85
|
+
cover: /home/choi/Desktop/cover.gif
|
86
|
+
mobi_outfile: my-ebook.mobi
|
87
|
+
|
88
|
+
kindlerb uses the the file tree and _document.yml to construct these additional
|
89
|
+
resource required by Amazon's `kindlegen` program:
|
90
|
+
|
91
|
+
* nav-contents.ncx
|
92
|
+
* contents.html
|
93
|
+
* kindlerb.opf
|
94
|
+
|
95
|
+
After that, kindlerb will exec the kindlegen program to generate your mobi
|
96
|
+
document. The filename the output document is specified by the 'mobi_outfile'
|
97
|
+
value in _document.yml.
|
98
|
+
|
99
|
+
### Kindlerb.executable
|
100
|
+
Will return the full path to the Kindlegen executable file.
|
101
|
+
|
102
|
+
### Kindlerb.download
|
103
|
+
This is called when you first install the gem and call `setupkindlerb` executable. It downloads the appropriate Kindlegen version for the host OS. There should be no need to call this after initial set up.
|
104
|
+
|
105
|
+
## Images
|
106
|
+
|
107
|
+
kindlerb will incorporate images into the generated ebook by parsing all the
|
108
|
+
`src` attributes of all the `<img>` tags in your *.html files.
|
109
|
+
|
110
|
+
The `src` attributes must point to image files on the local filesystem. If the
|
111
|
+
paths are relative, they should be relative to the target file tree root.
|
112
|
+
|
113
|
+
|
114
|
+
## Encoding
|
115
|
+
|
116
|
+
Make sure all your textual source files are encoded in UTF-8.
|
117
|
+
|
118
|
+
|
119
|
+
## Authors
|
120
|
+
|
121
|
+
**Daniel Choi**
|
122
|
+
* email: dhchoi@gmail.com
|
123
|
+
* github: [danchoi][github]
|
124
|
+
* twitter: @danchoi
|
125
|
+
[github]:http://github.com/danchoi
|
126
|
+
|
127
|
+
**Emir Aydin**
|
128
|
+
* email: emir@emiraydin.com
|
129
|
+
* github: [emiraydin][github]
|
130
|
+
* twitter: @emiraydin
|
131
|
+
[github]:http://github.com/emiraydin
|
132
|
+
|
133
|
+
|
134
|
+
Indebted to [mhl][mhl] for writing the
|
135
|
+
[guardian-for-kindle][guardian-for-kindle] MOBI generator in Python. kindlerb
|
136
|
+
ported a bunch of ideas from that project over to Ruby.
|
137
|
+
|
138
|
+
[mhl]:https://github.com/mhl
|
139
|
+
[guardian-for-kindle]:https://github.com/mhl/guardian-for-kindle
|
data/Rakefile
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'bundler'
|
4
|
-
Bundler::GemHelper.install_tasks
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
7
|
-
|
8
|
-
desc "release and build and push new website"
|
9
|
-
task :push => [:release, :web]
|
10
|
-
|
11
|
-
desc "Bumps version number up one and git commits"
|
12
|
-
task :bump do
|
13
|
-
basefile = "lib/vmail/version.rb"
|
14
|
-
file = File.read(basefile)
|
15
|
-
oldver = file[/VERSION = '(\d.\d.\d)'/, 1]
|
16
|
-
newver_i = oldver.gsub(".", '').to_i + 1
|
17
|
-
newver = ("%.3d" % newver_i).split(//).join('.')
|
18
|
-
puts oldver
|
19
|
-
puts newver
|
20
|
-
puts "Bumping version: #{oldver} => #{newver}"
|
21
|
-
newfile = file.gsub("VERSION = '#{oldver}'", "VERSION = '#{newver}'")
|
22
|
-
File.open(basefile, 'w') {|f| f.write newfile}
|
23
|
-
`git commit -am 'Bump'`
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
desc "build and push website"
|
28
|
-
task :web => :build_webpage do
|
29
|
-
puts "Building and pushing website"
|
30
|
-
Dir.chdir "../project-webpages" do
|
31
|
-
`scp out/vmail.html zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
32
|
-
`rsync -avz out/images-vmail zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
33
|
-
`rsync -avz out/stylesheets zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
34
|
-
`rsync -avz out/lightbox2 zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
35
|
-
end
|
36
|
-
`open http://danielchoi.com/software/vmail.html`
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "build webpage"
|
40
|
-
task :build_webpage do
|
41
|
-
`cp README.markdown ../project-webpages/src/vmail.README.markdown`
|
42
|
-
`cp coverage.markdown ../project-webpages/src/vmail.coverage.markdown`
|
43
|
-
Dir.chdir "../project-webpages" do
|
44
|
-
puts `ruby gen.rb vmail #{Vmail::VERSION}`
|
45
|
-
#`open out/vmail.html`
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
desc "git push and rake release bumped version"
|
51
|
-
task :bumped do
|
52
|
-
puts `git push && rake release`
|
53
|
-
Rake::Task["web"].execute
|
54
|
-
end
|
55
|
-
|
56
|
-
desc "Run tests"
|
57
|
-
task :test do
|
58
|
-
$:.unshift File.expand_path("test")
|
59
|
-
require 'test_helper'
|
60
|
-
Dir.chdir("test") do
|
61
|
-
Dir['*_test.rb'].each do |x|
|
62
|
-
puts "requiring #{x}"
|
63
|
-
require x
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
MiniTest::Unit.autorun
|
68
|
-
end
|
69
|
-
|
70
|
-
task :default => :test
|
71
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
7
|
+
|
8
|
+
desc "release and build and push new website"
|
9
|
+
task :push => [:release, :web]
|
10
|
+
|
11
|
+
desc "Bumps version number up one and git commits"
|
12
|
+
task :bump do
|
13
|
+
basefile = "lib/vmail/version.rb"
|
14
|
+
file = File.read(basefile)
|
15
|
+
oldver = file[/VERSION = '(\d.\d.\d)'/, 1]
|
16
|
+
newver_i = oldver.gsub(".", '').to_i + 1
|
17
|
+
newver = ("%.3d" % newver_i).split(//).join('.')
|
18
|
+
puts oldver
|
19
|
+
puts newver
|
20
|
+
puts "Bumping version: #{oldver} => #{newver}"
|
21
|
+
newfile = file.gsub("VERSION = '#{oldver}'", "VERSION = '#{newver}'")
|
22
|
+
File.open(basefile, 'w') {|f| f.write newfile}
|
23
|
+
`git commit -am 'Bump'`
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
desc "build and push website"
|
28
|
+
task :web => :build_webpage do
|
29
|
+
puts "Building and pushing website"
|
30
|
+
Dir.chdir "../project-webpages" do
|
31
|
+
`scp out/vmail.html zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
32
|
+
`rsync -avz out/images-vmail zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
33
|
+
`rsync -avz out/stylesheets zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
34
|
+
`rsync -avz out/lightbox2 zoe2@instantwatcher.com:~/danielchoi.com/public/software/`
|
35
|
+
end
|
36
|
+
`open http://danielchoi.com/software/vmail.html`
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "build webpage"
|
40
|
+
task :build_webpage do
|
41
|
+
`cp README.markdown ../project-webpages/src/vmail.README.markdown`
|
42
|
+
`cp coverage.markdown ../project-webpages/src/vmail.coverage.markdown`
|
43
|
+
Dir.chdir "../project-webpages" do
|
44
|
+
puts `ruby gen.rb vmail #{Vmail::VERSION}`
|
45
|
+
#`open out/vmail.html`
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
desc "git push and rake release bumped version"
|
51
|
+
task :bumped do
|
52
|
+
puts `git push && rake release`
|
53
|
+
Rake::Task["web"].execute
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Run tests"
|
57
|
+
task :test do
|
58
|
+
$:.unshift File.expand_path("test")
|
59
|
+
require 'test_helper'
|
60
|
+
Dir.chdir("test") do
|
61
|
+
Dir['*_test.rb'].each do |x|
|
62
|
+
puts "requiring #{x}"
|
63
|
+
require x
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
MiniTest::Unit.autorun
|
68
|
+
end
|
69
|
+
|
70
|
+
task :default => :test
|
71
|
+
|