jekyll-build-ebook 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -1
- data/{jekyll-e-book.gemspec → jekyll-build-ebook.gemspec} +1 -0
- data/lib/jekyll-build-ebook.rb +1 -0
- data/lib/jekyll-build-ebook/config.rb +2 -2
- data/lib/jekyll-build-ebook/generator.rb +20 -5
- data/lib/jekyll-build-ebook/version.rb +1 -1
- data/lib/jekyll/commands/build_ebook.rb +11 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ae167dec5aabb0fa3899583a0042bc2b5f43b57e346a4097279716b03e01713
|
4
|
+
data.tar.gz: d91bd0ed56d86c6765a12320c05967cae1cf2eb5e88928c71b528bcfc393e86b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a5362e8afd4661efe3e8bcd0d10c18f5e9848ad2882c11ef62d56cc2f9c9382ed5dc027513033a6d387c79a68f89007a4695fa78ef76faf707ffc62cf4bae34
|
7
|
+
data.tar.gz: da2bb097718d75b7e482b94d7dc46dcc3116cb3a56afd620b2c2d9abbbb52779a0baa32d3b517977de8c752158725614efcb4a2486dc9a167c57300c5b46e529
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jekyll-build-ebook (0.
|
4
|
+
jekyll-build-ebook (0.3.0)
|
5
5
|
gepub (~> 0.7)
|
6
6
|
jekyll (~> 3.5)
|
7
|
+
kindlegen (~> 3.0)
|
7
8
|
nokogiri (~> 1.8)
|
8
9
|
|
9
10
|
GEM
|
@@ -45,6 +46,9 @@ GEM
|
|
45
46
|
sass (~> 3.4)
|
46
47
|
jekyll-watch (2.0.0)
|
47
48
|
listen (~> 3.0)
|
49
|
+
kindlegen (3.0.3)
|
50
|
+
rake
|
51
|
+
rubyzip
|
48
52
|
kramdown (1.17.0)
|
49
53
|
liquid (4.0.0)
|
50
54
|
listen (3.1.5)
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'jekyll', '~> 3.5'
|
24
24
|
|
25
25
|
spec.add_dependency 'gepub', '~> 0.7'
|
26
|
+
spec.add_dependency 'kindlegen', '~> 3.0'
|
26
27
|
spec.add_dependency 'nokogiri', '~> 1.8'
|
27
28
|
|
28
29
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
data/lib/jekyll-build-ebook.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
module JekyllBuildEbook
|
2
2
|
class Generator
|
3
|
-
def generate(site
|
3
|
+
def generate(site)
|
4
4
|
config = Config.new(site.config)
|
5
5
|
|
6
|
+
FileUtils.mkdir_p(config['destination'])
|
7
|
+
|
8
|
+
generate_epub(site, config)
|
9
|
+
generate_kindle(config) if config['kindle']
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def generate_epub(site, config, book: GEPUB::Book.new)
|
6
15
|
book.date = config['date'] || site.time
|
7
16
|
book.identifier = config['identifier']
|
8
17
|
book.title = config['title']
|
@@ -12,7 +21,7 @@ module JekyllBuildEbook
|
|
12
21
|
|
13
22
|
site.static_files.each do |static_file|
|
14
23
|
File.open(static_file.path) do |io|
|
15
|
-
book.add_item(File.join(static_file.destination_rel_dir, static_file.name), io)
|
24
|
+
book.add_item(File.join(static_file.destination_rel_dir, static_file.name)[1..-1], io)
|
16
25
|
end
|
17
26
|
end
|
18
27
|
|
@@ -21,14 +30,20 @@ module JekyllBuildEbook
|
|
21
30
|
post.output = Jekyll::Renderer.new(site, post).run
|
22
31
|
|
23
32
|
book
|
24
|
-
.add_item(post.url)
|
33
|
+
.add_item(post.url[1..-1])
|
25
34
|
.add_content(StringIO.new(Nokogiri::HTML(post.output).to_xhtml))
|
26
35
|
.toc_text(post['title'])
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
30
|
-
|
31
|
-
|
39
|
+
book.generate_epub(config.destination_path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def generate_kindle(config, logger: Jekyll.logger)
|
43
|
+
stdout, stderr, _status = Kindlegen.run(config.destination_path, '-o', "#{config['file_name']}.mobi")
|
44
|
+
|
45
|
+
logger.debug('Kindlegen:', stdout) unless stdout.empty?
|
46
|
+
logger.error('Kindlegen:', stderr) unless stderr.empty?
|
32
47
|
end
|
33
48
|
end
|
34
49
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module Commands
|
3
3
|
class BuildEbook < Command
|
4
|
+
EBOOK_OPTIONS = %w[destination file_name kindle].freeze
|
5
|
+
|
4
6
|
# Create the Mercenary command for the Jekyll CLI for this Command
|
5
7
|
def self.init_with_program(prog)
|
6
8
|
prog.command(:'build-ebook') do |c|
|
@@ -9,7 +11,6 @@ module Jekyll
|
|
9
11
|
c.alias :be
|
10
12
|
|
11
13
|
c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file'
|
12
|
-
c.option 'destination', '-d', '--destination DESTINATION', 'The current folder will be generated into DESTINATION'
|
13
14
|
c.option 'source', '-s', '--source SOURCE', 'Custom source directory'
|
14
15
|
c.option 'future', '--future', 'Publishes posts with a future date'
|
15
16
|
c.option 'limit_posts', '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish'
|
@@ -18,7 +19,16 @@ module Jekyll
|
|
18
19
|
c.option 'quiet', '-q', '--quiet', 'Silence output.'
|
19
20
|
c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
|
20
21
|
|
22
|
+
c.option 'destination', '-d', '--destination DESTINATION', 'The current folder will be generated into DESTINATION'
|
23
|
+
c.option 'file_name', '--file_name FILE_NAME', 'Generate the ebook as FILE_NAME.epub'
|
24
|
+
c.option 'kindle', '--kindle', 'Also generate .mobi file'
|
25
|
+
|
21
26
|
c.action do |_args, options|
|
27
|
+
options['ebook'] = {}
|
28
|
+
EBOOK_OPTIONS.each do |key|
|
29
|
+
options['ebook'][key] = options[key] unless options[key].nil?
|
30
|
+
end
|
31
|
+
|
22
32
|
process(options)
|
23
33
|
end
|
24
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-build-ebook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fuji Nakahara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: kindlegen
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: nokogiri
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +141,7 @@ files:
|
|
127
141
|
- Rakefile
|
128
142
|
- bin/console
|
129
143
|
- bin/setup
|
130
|
-
- jekyll-
|
144
|
+
- jekyll-build-ebook.gemspec
|
131
145
|
- lib/jekyll-build-ebook.rb
|
132
146
|
- lib/jekyll-build-ebook/config.rb
|
133
147
|
- lib/jekyll-build-ebook/filters.rb
|