softcover 1.1.6 → 1.1.7
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/lib/softcover/article_template/html/stylesheets/softcover.css +10 -0
- data/lib/softcover/builders/epub.rb +15 -11
- data/lib/softcover/builders/mobi.rb +1 -1
- data/lib/softcover/builders/preview.rb +4 -0
- data/lib/softcover/cli.rb +2 -0
- data/lib/softcover/commands/deployment.rb +7 -3
- data/lib/softcover/version.rb +1 -1
- data/softcover.gemspec +1 -1
- data/spec/builders/epub_spec.rb +5 -0
- data/spec/builders/mobi_spec.rb +9 -0
- data/spec/cli_spec.rb +14 -0
- data/spec/commands/deployment_spec.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d457ce733f778fdeb848d5f889b1686f11a09ff
|
4
|
+
data.tar.gz: b9d1886ffdde15e50488dd72e1b7e71c4a8d4ed1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4692af5acbc5ce82defe290f8ce7e54d86505ba0c88db0c7bca3ad09808c38c4a03310e2a236c8362192dc8bce3e87d4065298602ccb732021f3c4d1a5eb112
|
7
|
+
data.tar.gz: e1417a3e4130571624a9150968d128a57bd53647f2dabdf8d266e9206cbd9a744e840e2c9d2421141e305841ca9c458a06a7b04da723683d41543a546272bee5
|
@@ -14,6 +14,7 @@ body #book {
|
|
14
14
|
font-size: 230%;
|
15
15
|
border-top: 2px solid #333;
|
16
16
|
padding-top: 1em;
|
17
|
+
text-align: left;
|
17
18
|
}
|
18
19
|
|
19
20
|
#book h2 {
|
@@ -326,6 +327,15 @@ body #book {
|
|
326
327
|
font-weight: bold;
|
327
328
|
}
|
328
329
|
|
330
|
+
#book ul.footnotes li {
|
331
|
+
line-height: 1.4;
|
332
|
+
margin-bottom: 1em;
|
333
|
+
}
|
334
|
+
|
335
|
+
#book ul.footnotes li p {
|
336
|
+
line-height: 1.4;
|
337
|
+
}
|
338
|
+
|
329
339
|
#book a.arrow {
|
330
340
|
text-decoration: none;
|
331
341
|
}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module Softcover
|
2
|
-
|
3
2
|
module EpubUtils
|
4
3
|
|
5
4
|
# Returns the name of the cover file.
|
@@ -17,8 +16,13 @@ module Softcover
|
|
17
16
|
return false
|
18
17
|
end
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
# Returns true when producing a cover.
|
20
|
+
# We include a cover when not producing an Amazon-specific book
|
21
|
+
# as long as there's a cover image. (When uploading a book to
|
22
|
+
# Amazon KDP, the cover gets uploaded separately, so the MOBI file itself
|
23
|
+
# should have not have a cover.)
|
24
|
+
def cover?(options={})
|
25
|
+
!options[:amazon] && cover_img
|
22
26
|
end
|
23
27
|
|
24
28
|
def cover_img_path
|
@@ -141,7 +145,7 @@ module Softcover
|
|
141
145
|
write_nav
|
142
146
|
copy_image_files
|
143
147
|
write_html(options)
|
144
|
-
write_contents
|
148
|
+
write_contents(options)
|
145
149
|
create_style_files(options)
|
146
150
|
make_epub(options)
|
147
151
|
move_epub
|
@@ -194,8 +198,8 @@ module Softcover
|
|
194
198
|
|
195
199
|
# Writes the content.opf file.
|
196
200
|
# This is required by the EPUB standard.
|
197
|
-
def write_contents
|
198
|
-
File.write(path('epub/OEBPS/content.opf'), content_opf)
|
201
|
+
def write_contents(options={})
|
202
|
+
File.write(path('epub/OEBPS/content.opf'), content_opf(options))
|
199
203
|
end
|
200
204
|
|
201
205
|
# Returns the chapters to write.
|
@@ -211,7 +215,7 @@ module Softcover
|
|
211
215
|
mkdir images_dir
|
212
216
|
mkdir texmath_dir
|
213
217
|
|
214
|
-
File.write(path('epub/OEBPS/cover.html'), cover_page) if cover?
|
218
|
+
File.write(path('epub/OEBPS/cover.html'), cover_page) if cover?(options)
|
215
219
|
|
216
220
|
pngs = []
|
217
221
|
chapters.each_with_index do |chapter, i|
|
@@ -464,7 +468,7 @@ module Softcover
|
|
464
468
|
end
|
465
469
|
|
466
470
|
# Returns the content configuration file.
|
467
|
-
def content_opf
|
471
|
+
def content_opf(options={})
|
468
472
|
man_ch = chapters.map do |chapter|
|
469
473
|
%(<item id="#{chapter.slug}" href="#{chapter.fragment_name}" media-type="application/xhtml+xml"/>)
|
470
474
|
end
|
@@ -486,7 +490,7 @@ module Softcover
|
|
486
490
|
%(<item id="#{id}" href="#{href}" media-type="image/#{ext}"/>)
|
487
491
|
end
|
488
492
|
content_opf_template(manifest.title, manifest.copyright,
|
489
|
-
manifest.author, manifest.uuid, cover_id,
|
493
|
+
manifest.author, manifest.uuid, cover_id(options),
|
490
494
|
toc_ch, man_ch, images)
|
491
495
|
end
|
492
496
|
|
@@ -506,8 +510,8 @@ module Softcover
|
|
506
510
|
)
|
507
511
|
end
|
508
512
|
|
509
|
-
def cover_id
|
510
|
-
cover? ? "img-#{cover_img.sub('.', '-')}" : nil
|
513
|
+
def cover_id(options)
|
514
|
+
cover?(options) ? "img-#{cover_img.sub('.', '-')}" : nil
|
511
515
|
end
|
512
516
|
|
513
517
|
# Returns the Table of Contents for the spine.
|
@@ -24,7 +24,7 @@ module Softcover
|
|
24
24
|
# Returns the command for making a MOBI, based on the options.
|
25
25
|
def mobi_command(filename, options={})
|
26
26
|
silent = options[:silent] || Softcover.test?
|
27
|
-
if options[:kindlegen]
|
27
|
+
if options[:kindlegen] || options[:amazon]
|
28
28
|
cmd = "#{kindlegen} ebooks/#{filename}.epub"
|
29
29
|
else
|
30
30
|
cmd = "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.mobi" +
|
@@ -3,6 +3,10 @@ module Softcover
|
|
3
3
|
class Preview < Builder
|
4
4
|
|
5
5
|
def build!
|
6
|
+
if article?
|
7
|
+
$stderr.puts "Previews not supported for articles"
|
8
|
+
exit(1)
|
9
|
+
end
|
6
10
|
# Recall that MOBI generation makes an EPUB as a side-effect.
|
7
11
|
Softcover::Builders::Mobi.new.build!(preview: true)
|
8
12
|
Softcover::Builders::Pdf.new.build!(preview: true)
|
data/lib/softcover/cli.rb
CHANGED
@@ -48,6 +48,8 @@ module Softcover
|
|
48
48
|
method_option :kindlegen, aliases: '-k',
|
49
49
|
desc: "Use KindleGen to build the MOBI",
|
50
50
|
type: :boolean
|
51
|
+
method_option :amazon, aliases: '-a',
|
52
|
+
desc: "Build for Amazon KDP", type: :boolean
|
51
53
|
end
|
52
54
|
method_option :quiet, aliases: '-q',
|
53
55
|
desc: "Quiet output", type: :boolean
|
@@ -5,7 +5,7 @@ module Softcover
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
# Deploy a book by building and publishing it.
|
8
|
-
# The deploy steps can be customized using `.
|
8
|
+
# The deploy steps can be customized using `.softcover-publish`
|
9
9
|
# in the book project's home directory.
|
10
10
|
def deploy!
|
11
11
|
if File.exist?('.softcover-deploy') && !custom_commands.empty?
|
@@ -17,8 +17,12 @@ module Softcover
|
|
17
17
|
|
18
18
|
# Returns the default commands.
|
19
19
|
def default_commands
|
20
|
-
|
21
|
-
|
20
|
+
if article?
|
21
|
+
commands(['softcover build:all', 'softcover publish'])
|
22
|
+
else
|
23
|
+
commands(['softcover build:all', 'softcover build:preview',
|
24
|
+
'softcover publish'])
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
# Returns custom commands (if any).
|
data/lib/softcover/version.rb
CHANGED
data/softcover.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency 'polytexnic', '~> 1.1.
|
21
|
+
gem.add_dependency 'polytexnic', '~> 1.1.6'
|
22
22
|
gem.add_dependency 'msgpack', '~> 0.4.2'
|
23
23
|
gem.add_dependency 'nokogiri', '~> 1.6.0'
|
24
24
|
gem.add_dependency 'thor', '~> 0.18.1'
|
data/spec/builders/epub_spec.rb
CHANGED
@@ -291,4 +291,9 @@ describe "article validation" do
|
|
291
291
|
output = `softcover epub:validate`
|
292
292
|
expect(output).to match(/No errors or warnings/)
|
293
293
|
end
|
294
|
+
|
295
|
+
it "should description" do
|
296
|
+
commands = Softcover::Commands::Deployment.default_commands
|
297
|
+
expect(commands).not_to include('preview')
|
298
|
+
end
|
294
299
|
end
|
data/spec/builders/mobi_spec.rb
CHANGED
@@ -46,6 +46,15 @@ describe Softcover::Builders::Mobi do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
context "amazon" do
|
50
|
+
let(:command) do
|
51
|
+
@builder.mobi_command(@builder.mobi_filename, amazon: true)
|
52
|
+
end
|
53
|
+
it "should use Amazon.com's kindlegen" do
|
54
|
+
expect(command).to include 'kindlegen'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
49
58
|
context "preview" do
|
50
59
|
let(:filename) do
|
51
60
|
@builder.mobi_filename(preview: true)
|
data/spec/cli_spec.rb
CHANGED
@@ -33,6 +33,20 @@ describe Softcover::CLI do
|
|
33
33
|
it { should include 'f, [--find-overfull]' }
|
34
34
|
end
|
35
35
|
|
36
|
+
context "softcover build:epub options" do
|
37
|
+
subject { `softcover help build:epub` }
|
38
|
+
it { should include '-q, [--quiet]' }
|
39
|
+
it { should include '-s, [--silent]' }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "softcover build:mobi options" do
|
43
|
+
subject { `softcover help build:mobi` }
|
44
|
+
it { should include '-q, [--quiet]' }
|
45
|
+
it { should include '-s, [--silent]' }
|
46
|
+
it { should include '-k, [--kindlegen]' }
|
47
|
+
it { should include '-a, [--amazon]' }
|
48
|
+
end
|
49
|
+
|
36
50
|
context "softcover new options" do
|
37
51
|
subject { `softcover help new` }
|
38
52
|
it { should include '-p, [--polytex]' }
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Softcover::Commands::Deployment do
|
4
4
|
|
5
5
|
describe "default commands" do
|
6
|
+
before { Softcover::Commands::Deployment.stub(:article?).and_return(false) }
|
6
7
|
subject { Softcover::Commands::Deployment.default_commands }
|
7
8
|
|
8
9
|
it { should match /softcover build:all/ }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: softcover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hartl
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: polytexnic
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.1.
|
20
|
+
version: 1.1.6
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.1.
|
27
|
+
version: 1.1.6
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: msgpack
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|