softcover 1.7.4 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +30 -28
- data/README.md +1 -1
- data/lib/softcover/article_template/latex_gitignore +0 -1
- data/lib/softcover/article_template/latex_styles/softcover.sty +1 -0
- data/lib/softcover/article_template/markdown_gitignore +0 -1
- data/lib/softcover/book_template/latex_gitignore +0 -1
- data/lib/softcover/book_template/latex_styles/softcover.sty +1 -0
- data/lib/softcover/book_template/markdown_gitignore +0 -1
- data/lib/softcover/builders/epub.rb +8 -1
- data/lib/softcover/cli.rb +4 -1
- data/lib/softcover/commands/exercises.rb +1 -1
- data/lib/softcover/commands/server.rb +24 -12
- data/lib/softcover/version.rb +1 -1
- data/softcover.gemspec +2 -2
- data/spec/commands/server_spec.rb +5 -3
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac6a3f1ecc0ba2a8ba2dc4dac7b8a480fc451acd10c563b5a5a5a55209c4d6cf
|
4
|
+
data.tar.gz: caa2837b7e97298887d0a927c84e6973bd4fe5857f29b2fc80eea0f18533417f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31e8000d8dc51018be5e76ecab96fbac5b5373c9d3a9df2a05085844d20da0ae6251dca92c09c3860f35224b9ec903c81a327e8ef78deb1ecebaa81b64049c30
|
7
|
+
data.tar.gz: c706ab7791768ea06cd05caa5c80ce34a669015425d35ba63a14df6e05b0c8234cd220c6fcf9c035d1c35d4936449119321db01fbfeeab9c5531bc80265bcd40
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
softcover (1.
|
4
|
+
softcover (1.8.0)
|
5
5
|
activesupport (~> 4.2.3)
|
6
6
|
async_sinatra (~> 1.1.0)
|
7
7
|
coffee-script (>= 2.2.0)
|
8
8
|
curb (>= 0.9.7)
|
9
9
|
i18n (>= 0.7.0)
|
10
10
|
kramdown (>= 1.6.0)
|
11
|
-
listen (~> 3.
|
11
|
+
listen (~> 3.7.1)
|
12
12
|
maruku (~> 0.7.1)
|
13
13
|
msgpack (~> 1.2.0)
|
14
14
|
nokogiri (>= 1.6.0, < 2.0)
|
15
|
-
polytexnic (~> 1.
|
15
|
+
polytexnic (~> 1.8.0)
|
16
16
|
pygments.rb (~> 2.1)
|
17
17
|
rest-client (>= 1.8.0)
|
18
18
|
ruby-progressbar (~> 1.10)
|
@@ -30,8 +30,8 @@ GEM
|
|
30
30
|
minitest (~> 5.1)
|
31
31
|
thread_safe (~> 0.3, >= 0.3.4)
|
32
32
|
tzinfo (~> 1.1)
|
33
|
-
addressable (2.8.
|
34
|
-
public_suffix (>= 2.0.2, <
|
33
|
+
addressable (2.8.1)
|
34
|
+
public_suffix (>= 2.0.2, < 6.0)
|
35
35
|
async_sinatra (1.1.0)
|
36
36
|
rack (>= 1.4.1)
|
37
37
|
sinatra (>= 1.3.2)
|
@@ -40,7 +40,7 @@ GEM
|
|
40
40
|
coffee-script-source
|
41
41
|
execjs
|
42
42
|
coffee-script-source (1.12.2)
|
43
|
-
concurrent-ruby (1.1.
|
43
|
+
concurrent-ruby (1.1.10)
|
44
44
|
coveralls (0.8.23)
|
45
45
|
json (>= 1.8, < 3)
|
46
46
|
simplecov (~> 0.16.1)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
crack (0.4.5)
|
51
51
|
rexml
|
52
52
|
crass (1.0.6)
|
53
|
-
curb (1.0.
|
53
|
+
curb (1.0.1)
|
54
54
|
daemons (1.4.1)
|
55
55
|
diff-lcs (1.5.0)
|
56
56
|
docile (1.4.0)
|
@@ -61,14 +61,14 @@ GEM
|
|
61
61
|
ffi (1.15.5)
|
62
62
|
hashdiff (1.0.1)
|
63
63
|
http-accept (1.7.0)
|
64
|
-
http-cookie (1.0.
|
64
|
+
http-cookie (1.0.5)
|
65
65
|
domain_name (~> 0.5)
|
66
66
|
i18n (0.9.5)
|
67
67
|
concurrent-ruby (~> 1.0)
|
68
68
|
json (2.3.1)
|
69
|
-
kramdown (2.
|
69
|
+
kramdown (2.4.0)
|
70
70
|
rexml
|
71
|
-
listen (3.
|
71
|
+
listen (3.7.1)
|
72
72
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
73
73
|
rb-inotify (~> 0.9, >= 0.9.10)
|
74
74
|
maruku (0.7.3)
|
@@ -76,16 +76,16 @@ GEM
|
|
76
76
|
mime-types (3.4.1)
|
77
77
|
mime-types-data (~> 3.2015)
|
78
78
|
mime-types-data (3.2022.0105)
|
79
|
-
|
80
|
-
minitest (5.15.0)
|
79
|
+
minitest (5.16.3)
|
81
80
|
msgpack (1.2.10)
|
82
81
|
netrc (0.11.0)
|
83
|
-
nokogiri (1.13.
|
84
|
-
|
82
|
+
nokogiri (1.13.10-arm64-darwin)
|
83
|
+
racc (~> 1.4)
|
84
|
+
nokogiri (1.13.10-x86_64-darwin)
|
85
85
|
racc (~> 1.4)
|
86
86
|
nokogumbo (2.0.5)
|
87
87
|
nokogiri (~> 1.8, >= 1.8.4)
|
88
|
-
polytexnic (1.
|
88
|
+
polytexnic (1.8.0)
|
89
89
|
json (~> 2.3.0)
|
90
90
|
kramdown (>= 2.0, < 3.0)
|
91
91
|
msgpack (~> 1.2.0)
|
@@ -94,16 +94,16 @@ GEM
|
|
94
94
|
pry (0.14.1)
|
95
95
|
coderay (~> 1.1)
|
96
96
|
method_source (~> 1.0)
|
97
|
-
public_suffix (
|
98
|
-
pygments.rb (2.3.
|
99
|
-
racc (1.6.
|
97
|
+
public_suffix (5.0.1)
|
98
|
+
pygments.rb (2.3.1)
|
99
|
+
racc (1.6.1)
|
100
100
|
rack (1.6.13)
|
101
101
|
rack-protection (1.5.5)
|
102
102
|
rack
|
103
|
-
rack-test (
|
104
|
-
rack (>= 1.
|
103
|
+
rack-test (2.0.2)
|
104
|
+
rack (>= 1.3)
|
105
105
|
rake (13.0.6)
|
106
|
-
rb-fsevent (0.11.
|
106
|
+
rb-fsevent (0.11.2)
|
107
107
|
rb-inotify (0.10.1)
|
108
108
|
ffi (~> 1.0)
|
109
109
|
rest-client (2.1.0)
|
@@ -147,21 +147,23 @@ GEM
|
|
147
147
|
rack (~> 1.0)
|
148
148
|
thor (1.2.1)
|
149
149
|
thread_safe (0.3.6)
|
150
|
-
tilt (2.0.
|
151
|
-
tins (1.
|
150
|
+
tilt (2.0.11)
|
151
|
+
tins (1.32.1)
|
152
152
|
sync
|
153
|
-
tzinfo (1.2.
|
153
|
+
tzinfo (1.2.10)
|
154
154
|
thread_safe (~> 0.1)
|
155
155
|
unf (0.1.4)
|
156
156
|
unf_ext
|
157
|
-
unf_ext (0.0.8)
|
158
|
-
webmock (3.
|
157
|
+
unf_ext (0.0.8.2)
|
158
|
+
webmock (3.18.1)
|
159
159
|
addressable (>= 2.8.0)
|
160
160
|
crack (>= 0.3.2)
|
161
161
|
hashdiff (>= 0.4.0, < 2.0.0)
|
162
162
|
|
163
163
|
PLATFORMS
|
164
|
-
|
164
|
+
arm64-darwin-21
|
165
|
+
x86_64-darwin-19
|
166
|
+
x86_64-darwin-21
|
165
167
|
|
166
168
|
DEPENDENCIES
|
167
169
|
coveralls
|
@@ -175,4 +177,4 @@ DEPENDENCIES
|
|
175
177
|
webmock (~> 3)
|
176
178
|
|
177
179
|
BUNDLED WITH
|
178
|
-
2.
|
180
|
+
2.3.10
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Softcover
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/softcover/softcover/badge.svg)](https://coveralls.io/github/softcover/softcover)
|
4
4
|
|
5
5
|
Softcover is an ebook typesetting system for technical authors. This is the main gem, `softcover`, which depends on `polytexnic` to convert Markdown or PolyTeX input to HTML and LaTeX, and thence to EPUB, MOBI, and PDF. Authors can use Softcover to publish and optionally sell the resulting ebooks (as well as associated digital goods such as screencasts) on the [Softcover publishing platform](http://www.softcover.io/).
|
6
6
|
|
@@ -273,6 +273,12 @@ module Softcover
|
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
276
|
+
# Escapes spaces in filename directories.
|
277
|
+
# E.g., "Mobile Directory" becomes "Mobile\ Directory".
|
278
|
+
def escape_spaces(name)
|
279
|
+
name.gsub(' ', '\ ')
|
280
|
+
end
|
281
|
+
|
276
282
|
# Returns HTML for HTML source that includes math.
|
277
283
|
# As a side-effect, html_with_math creates PNGs corresponding to any
|
278
284
|
# math in the given source. The technique involves using PhantomJS to
|
@@ -285,7 +291,8 @@ module Softcover
|
|
285
291
|
content = File.read(File.join("html",
|
286
292
|
"#{chapter.slug}.#{html_extension}"))
|
287
293
|
pagejs = "#{File.dirname(__FILE__)}/utils/page.js"
|
288
|
-
|
294
|
+
dir = escape_spaces(Dir.pwd)
|
295
|
+
url = "file://" + dir + "/html/#{chapter.slug}.#{html_extension}"
|
289
296
|
cmd = "#{phantomjs} #{pagejs} #{url}"
|
290
297
|
silence { silence_stream(STDERR) { system cmd } }
|
291
298
|
# Sometimes in tests the phantomjs_source.html file is missing.
|
data/lib/softcover/cli.rb
CHANGED
@@ -99,9 +99,12 @@ module Softcover
|
|
99
99
|
desc 'server', 'Run local server'
|
100
100
|
method_option :port, type: :numeric, default: 4000, aliases: '-p'
|
101
101
|
method_option :bind, type: :string, default: '0.0.0.0', aliases: '-o'
|
102
|
+
method_option :pdf, type: :boolean, default: false
|
103
|
+
method_option :overfull, type: :boolean, default: false
|
102
104
|
def server
|
103
105
|
if Softcover::BookManifest::valid_directory?
|
104
|
-
Softcover::Commands::Server.run options[:port], options[:bind]
|
106
|
+
Softcover::Commands::Server.run options[:port], options[:bind],
|
107
|
+
options[:pdf], options[:overfull]
|
105
108
|
else
|
106
109
|
puts 'Not in a valid book directory.'
|
107
110
|
exit 1
|
@@ -7,14 +7,14 @@ module Softcover::Commands::Server
|
|
7
7
|
extend self
|
8
8
|
|
9
9
|
# Listens for changes to the book's source files.
|
10
|
-
def listen_for_changes
|
10
|
+
def listen_for_changes(is_pdf=false, overfull=false)
|
11
11
|
return if defined?(@no_listener) && @no_listener
|
12
12
|
server_pid = Process.pid
|
13
13
|
filter_regex = /(\.md|\.tex|custom\.sty|custom\.css|Book\.txt|book\.yml)$/
|
14
14
|
@listener = Listen.to('.', only: filter_regex, ignore: /html\//) do |modified|
|
15
15
|
first_modified = modified.try(:first)
|
16
16
|
unless first_modified =~ ignore_regex
|
17
|
-
rebuild first_modified
|
17
|
+
rebuild(is_pdf, modified: first_modified, overfull: overfull)
|
18
18
|
Process.kill("HUP", server_pid)
|
19
19
|
end
|
20
20
|
end
|
@@ -37,30 +37,42 @@ module Softcover::Commands::Server
|
|
37
37
|
!Dir.glob(path('chapters/*.md')).empty?
|
38
38
|
end
|
39
39
|
|
40
|
-
def rebuild(modified
|
40
|
+
def rebuild(is_pdf, modified: nil, overfull: nil)
|
41
41
|
printf modified ? "=> #{File.basename modified} changed, rebuilding... " :
|
42
42
|
'Building...'
|
43
43
|
t = Time.now
|
44
|
-
|
45
|
-
|
44
|
+
|
45
|
+
if is_pdf
|
46
|
+
if overfull
|
47
|
+
options = "--find-overfull"
|
48
|
+
else
|
49
|
+
options = "--once --nonstop --quiet"
|
50
|
+
end
|
51
|
+
system "softcover build:pdf #{options}"
|
52
|
+
else
|
53
|
+
builder = Softcover::Builders::Html.new
|
54
|
+
builder.build
|
55
|
+
end
|
46
56
|
puts "Done. (#{(Time.now - t).round(2)}s)"
|
47
57
|
|
48
58
|
rescue Softcover::BookManifest::NotFound => e
|
49
59
|
puts e.message
|
50
60
|
end
|
51
61
|
|
52
|
-
def start_server(port, bind)
|
62
|
+
def start_server(port, bind, is_pdf)
|
53
63
|
require 'softcover/server/app'
|
54
|
-
puts "Running Softcover server on http://#{bind}:#{port}"
|
55
64
|
Softcover::App.set :port, port
|
56
|
-
|
65
|
+
unless is_pdf
|
66
|
+
puts "Running Softcover server on http://#{bind}:#{port}"
|
67
|
+
Softcover::App.set :bind, bind
|
68
|
+
end
|
57
69
|
Softcover::App.run!
|
58
70
|
end
|
59
71
|
|
60
|
-
def run(port, bind)
|
61
|
-
rebuild
|
62
|
-
listen_for_changes
|
63
|
-
start_server port, bind
|
72
|
+
def run(port, bind, is_pdf, overfull)
|
73
|
+
rebuild(is_pdf, overfull: overfull)
|
74
|
+
listen_for_changes(is_pdf, overfull)
|
75
|
+
start_server port, bind, is_pdf
|
64
76
|
end
|
65
77
|
end
|
66
78
|
|
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.
|
21
|
+
gem.add_dependency 'polytexnic', '~> 1.8.0'
|
22
22
|
gem.add_dependency 'msgpack', '~> 1.2.0'
|
23
23
|
gem.add_dependency 'nokogiri', '>= 1.6.0', '< 2.0'
|
24
24
|
gem.add_dependency 'thor', '>= 0.18.1', '< 2.0'
|
@@ -36,6 +36,6 @@ Gem::Specification.new do |gem|
|
|
36
36
|
gem.add_dependency 'async_sinatra', '~> 1.1.0'
|
37
37
|
gem.add_dependency 'sinatra-respond_to', '~> 0.9.0'
|
38
38
|
gem.add_dependency 'coffee-script', '>= 2.2.0'
|
39
|
-
gem.add_dependency 'listen', '~> 3.
|
39
|
+
gem.add_dependency 'listen', '~> 3.7.1'
|
40
40
|
gem.add_dependency 'sanitize', '>= 4.6.3', '< 5.3.0'
|
41
41
|
end
|
@@ -13,10 +13,12 @@ describe Softcover::Commands::Server do
|
|
13
13
|
it '#run' do
|
14
14
|
Softcover::App.should_receive :run!
|
15
15
|
|
16
|
-
port
|
17
|
-
bind
|
16
|
+
port = 5000
|
17
|
+
bind = "localhost"
|
18
|
+
pdf = false
|
19
|
+
overfull = false
|
18
20
|
|
19
|
-
subject.run port, bind
|
21
|
+
subject.run port, bind, pdf, overfull
|
20
22
|
|
21
23
|
expect(Softcover::App.port).to eq port
|
22
24
|
expect(Softcover::App.bind).to eq bind
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: softcover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hartl
|
8
8
|
- Nick Merwin
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-12-16 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.
|
20
|
+
version: 1.8.0
|
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.
|
27
|
+
version: 1.8.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: msgpack
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,14 +267,14 @@ dependencies:
|
|
267
267
|
requirements:
|
268
268
|
- - "~>"
|
269
269
|
- !ruby/object:Gem::Version
|
270
|
-
version: 3.
|
270
|
+
version: 3.7.1
|
271
271
|
type: :runtime
|
272
272
|
prerelease: false
|
273
273
|
version_requirements: !ruby/object:Gem::Requirement
|
274
274
|
requirements:
|
275
275
|
- - "~>"
|
276
276
|
- !ruby/object:Gem::Version
|
277
|
-
version: 3.
|
277
|
+
version: 3.7.1
|
278
278
|
- !ruby/object:Gem::Dependency
|
279
279
|
name: sanitize
|
280
280
|
requirement: !ruby/object:Gem::Requirement
|
@@ -604,7 +604,7 @@ homepage: https://github.com/softcover/softcover
|
|
604
604
|
licenses:
|
605
605
|
- MIT
|
606
606
|
metadata: {}
|
607
|
-
post_install_message:
|
607
|
+
post_install_message:
|
608
608
|
rdoc_options: []
|
609
609
|
require_paths:
|
610
610
|
- lib
|
@@ -619,8 +619,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
619
619
|
- !ruby/object:Gem::Version
|
620
620
|
version: '0'
|
621
621
|
requirements: []
|
622
|
-
rubygems_version: 3.
|
623
|
-
signing_key:
|
622
|
+
rubygems_version: 3.3.7
|
623
|
+
signing_key:
|
624
624
|
specification_version: 4
|
625
625
|
summary: An ebook production system & sales and marketing platform for technical authors
|
626
626
|
test_files:
|