author 1.1.2.alpha → 1.1.3.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/author/commands/builder.rb +8 -0
- data/lib/author/exporters/base.rb +27 -0
- data/lib/author/exporters/pdf.rb +35 -0
- data/lib/author/exporters/xhtml.rb +1 -13
- data/lib/author/templates/book.css +12 -3
- data/lib/author/version.rb +1 -1
- data/test/commands/builder_test.rb +5 -1
- data/test/exporters/pdf_test.rb +41 -0
- data/test/exporters/xhtml_test.rb +1 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2FhMTUyMGU5ZTgyNjFmZjNhMGFmNzYwMTdlODZkYjg3YjVkMjA2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjVkNjk2MTI1OTlhNmNjZDUyNGY5ODU1ZWMzMTNmNThhMzI5Y2M5Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTU5Y2YyMTlhNzJmNDgyNDEwMGMxYTI2NjYyYzc2YzIzZjBmNzA3YTk2NmVm
|
10
|
+
MmRhMzI4YjVhODBhZjVkOTk1ZTkwZjg2ZGJkNDc3NDBkMzlhYjgxYzExYzM5
|
11
|
+
NjYyNDJjOGFlOTc3ZDliZGIwMmE3MThmYzNlMGQ5NWM1NzA4NmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2MzYzAwOTJjMzJmMTQ3ZGI3ODkwOTVlYzUzODEwYTFmN2VmNjliOWRjZDJm
|
14
|
+
ZTAxZTRkZGYxNmIzZmUxNmVhNDk4MjQ4NGUyYWNkYjFmNTQ0MTU3NTUwZDM3
|
15
|
+
Nzg5OGM4NTdlMDE4YTRhNjVkNTllMzg2MGMyMDVmZGIwMzJhYWY=
|
@@ -10,6 +10,14 @@ module Author
|
|
10
10
|
Author::Exporters::XHTML.export
|
11
11
|
end
|
12
12
|
|
13
|
+
desc "pdf", "Build PDF from XHTML"
|
14
|
+
def pdf
|
15
|
+
say "Building the XHTML site"
|
16
|
+
Author::Exporters::XHTML.export
|
17
|
+
say "Building PDF"
|
18
|
+
Author::Exporters::PDF.export
|
19
|
+
end
|
20
|
+
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Author
|
2
|
+
module Exporters
|
3
|
+
class Base
|
4
|
+
|
5
|
+
def root_dir
|
6
|
+
Dir.pwd
|
7
|
+
end
|
8
|
+
|
9
|
+
def source_dir
|
10
|
+
File.join(root_dir, 'chapters')
|
11
|
+
end
|
12
|
+
|
13
|
+
def export_path
|
14
|
+
File.join(source_dir, '..', 'export')
|
15
|
+
end
|
16
|
+
|
17
|
+
def output_path
|
18
|
+
File.join(export_path, 'book.xhtml')
|
19
|
+
end
|
20
|
+
|
21
|
+
def theme_path
|
22
|
+
File.join(export_path, 'book.css')
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Author
|
2
|
+
module Exporters
|
3
|
+
class PDF < Base
|
4
|
+
# 1. check that prince is installed
|
5
|
+
# 2. check that xhtml file exists
|
6
|
+
# 3. check that css file exists
|
7
|
+
# 4. run prince command
|
8
|
+
|
9
|
+
def self.export
|
10
|
+
exporter = new
|
11
|
+
exporter.prince_installed?
|
12
|
+
exporter.xhtml_exists?
|
13
|
+
exporter.css_exists?
|
14
|
+
exporter.export
|
15
|
+
end
|
16
|
+
|
17
|
+
def xhtml_exists?
|
18
|
+
raise "No book.xhtml file found" unless File.file?(output_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def css_exists?
|
22
|
+
raise "No book.css file found" unless File.file?(theme_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def prince_installed?
|
26
|
+
raise "Prince XML is not installed. This is required to build PDFs." unless `which prince` && $?.success?
|
27
|
+
end
|
28
|
+
|
29
|
+
def export
|
30
|
+
system("prince -s #{theme_path} #{output_path} -o #{File.join(export_path, 'book.pdf')}")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -4,7 +4,7 @@ require 'author/plugins/awesome_codeblock'
|
|
4
4
|
|
5
5
|
module Author
|
6
6
|
module Exporters
|
7
|
-
class XHTML
|
7
|
+
class XHTML < Base
|
8
8
|
# step 1: get file names from the outline.txt file
|
9
9
|
# step 2: create a new file called all.md
|
10
10
|
# step 3: concatenate all files and output to all.md
|
@@ -20,14 +20,6 @@ module Author
|
|
20
20
|
exporter.kramdownify
|
21
21
|
end
|
22
22
|
|
23
|
-
def root_dir
|
24
|
-
Dir.pwd
|
25
|
-
end
|
26
|
-
|
27
|
-
def source_dir
|
28
|
-
File.join(root_dir, 'chapters')
|
29
|
-
end
|
30
|
-
|
31
23
|
def outline_path
|
32
24
|
filepath = File.join(root_dir, 'outline.txt')
|
33
25
|
raise "No outline.txt file found. Make sure you are in an author project." unless File.file?(filepath)
|
@@ -46,10 +38,6 @@ module Author
|
|
46
38
|
File.join(source_dir, 'all.md')
|
47
39
|
end
|
48
40
|
|
49
|
-
def output_path
|
50
|
-
File.join(source_dir, '..', 'export', 'book.xhtml')
|
51
|
-
end
|
52
|
-
|
53
41
|
def layout_path
|
54
42
|
File.join(source_dir, '..', 'templates', 'layout.xhtml')
|
55
43
|
end
|
@@ -581,14 +581,18 @@ figure.code figcaption {
|
|
581
581
|
|
582
582
|
|
583
583
|
/*****************************************
|
584
|
-
|
584
|
+
Book Styles
|
585
585
|
*****************************************/
|
586
586
|
|
587
|
+
@page {
|
588
|
+
width: 8.5in;
|
589
|
+
height: 11in;
|
590
|
+
margin: 0.25in;
|
591
|
+
}
|
592
|
+
|
587
593
|
body {
|
588
594
|
padding: 50px;
|
589
595
|
font-weight: 100;
|
590
|
-
width: 1100px;
|
591
|
-
height: 600px;
|
592
596
|
}
|
593
597
|
|
594
598
|
p {
|
@@ -599,4 +603,9 @@ h2 {
|
|
599
603
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
600
604
|
font-weight: 100;
|
601
605
|
font-size: 42px;
|
606
|
+
page-break-before: always;
|
607
|
+
}
|
608
|
+
|
609
|
+
figure.code {
|
610
|
+
page-break-inside: avoid;
|
602
611
|
}
|
data/lib/author/version.rb
CHANGED
@@ -4,10 +4,14 @@ require 'author/commands/builder'
|
|
4
4
|
describe Author::Commands::Builder do
|
5
5
|
|
6
6
|
let(:builder) { Author::Commands::Builder }
|
7
|
+
let(:output) { capture { builder.start } }
|
7
8
|
|
8
9
|
it "should respond to xhtml" do
|
9
|
-
output = capture { builder.start }
|
10
10
|
expect(output).to_include "xhtml"
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should respond to pdf" do
|
14
|
+
expect(output).to_include "pdf"
|
15
|
+
end
|
16
|
+
|
13
17
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'author/exporters/base'
|
3
|
+
require 'author/exporters/pdf'
|
4
|
+
|
5
|
+
describe Author::Exporters::PDF do
|
6
|
+
|
7
|
+
let(:exporter) { Author::Exporters::PDF }
|
8
|
+
|
9
|
+
it "should respond to #export" do
|
10
|
+
expect(exporter).to_respond_to :export
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should raise error if no book.xhtml file exists" do
|
14
|
+
expect { exporter.export }.to_raise RuntimeError
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise error if no book.css file exists" do
|
18
|
+
expect { exporter.export }.to_raise RuntimeError
|
19
|
+
end
|
20
|
+
|
21
|
+
context "an instance" do
|
22
|
+
let(:exporter) { Author::Exporters::PDF.new }
|
23
|
+
|
24
|
+
it "should respond to #prince_installed?" do
|
25
|
+
expect(exporter).to_respond_to :prince_installed?
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should respond to #xhtml_exists?" do
|
29
|
+
expect(exporter).to_respond_to :xhtml_exists?
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should respond to #css_exists?" do
|
33
|
+
expect(exporter).to_respond_to :css_exists?
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should respond to #export" do
|
37
|
+
expect(exporter).to_respond_to :export
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: author
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Terry Schmidt
|
@@ -144,6 +144,8 @@ files:
|
|
144
144
|
- lib/author/commands/cli.rb
|
145
145
|
- lib/author/commands/generator.rb
|
146
146
|
- lib/author/commands/version.rb
|
147
|
+
- lib/author/exporters/base.rb
|
148
|
+
- lib/author/exporters/pdf.rb
|
147
149
|
- lib/author/exporters/xhtml.rb
|
148
150
|
- lib/author/plugins/awesome_codeblock.rb
|
149
151
|
- lib/author/templates/Gemfile
|
@@ -157,6 +159,7 @@ files:
|
|
157
159
|
- test/commands/cli_test.rb
|
158
160
|
- test/commands/generator_test.rb
|
159
161
|
- test/commands/version_test.rb
|
162
|
+
- test/exporters/pdf_test.rb
|
160
163
|
- test/exporters/xhtml_test.rb
|
161
164
|
- test/helper.rb
|
162
165
|
- test/liquids/highlight_lines.md
|
@@ -207,6 +210,7 @@ test_files:
|
|
207
210
|
- test/commands/cli_test.rb
|
208
211
|
- test/commands/generator_test.rb
|
209
212
|
- test/commands/version_test.rb
|
213
|
+
- test/exporters/pdf_test.rb
|
210
214
|
- test/exporters/xhtml_test.rb
|
211
215
|
- test/helper.rb
|
212
216
|
- test/liquids/highlight_lines.md
|