softcover 1.4.2 → 1.4.3
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/book_manifest.rb +6 -2
- data/lib/softcover/builders/epub.rb +13 -11
- data/lib/softcover/utils.rb +6 -0
- data/lib/softcover/version.rb +1 -1
- data/spec/builders/epub_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2e434aa507ebf2c6b6dce94b8ccf31c1aba5aae
|
4
|
+
data.tar.gz: d91a6cb4c4a6c371a3ff4473483bbb8a78e62300
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c265e188dd722ccf64451332eea2616bbb769fcf104453d10f5ab65573572aef194542b9ddaf1104528dcd1645cc3224fcaf44411489a04fae43d4cda641e48
|
7
|
+
data.tar.gz: d3b1c386f6edc8c6671cbb42959fee3d27621837fdd45df0329d508ed0010e1a5d1437081797dac68d3ab04eb4b038e1a176528315eaf964572aae1563e6184a
|
@@ -21,6 +21,11 @@ class Softcover::BookManifest < OpenStruct
|
|
21
21
|
CGI.escape_html(title)
|
22
22
|
end
|
23
23
|
|
24
|
+
# Run the title through the Polytexnic pipeline to make an HTML title.
|
25
|
+
def html_title
|
26
|
+
polytexnic_html(title)
|
27
|
+
end
|
28
|
+
|
24
29
|
class NotFound < StandardError
|
25
30
|
def message
|
26
31
|
"Invalid document directory, no manifest file found!"
|
@@ -62,8 +67,7 @@ class Softcover::BookManifest < OpenStruct
|
|
62
67
|
|
63
68
|
# Run the title through the Polytexnic pipeline to make an HTML title.
|
64
69
|
def html_title
|
65
|
-
|
66
|
-
.inner_html.strip
|
70
|
+
self.polytexnic_html(title)
|
67
71
|
end
|
68
72
|
|
69
73
|
def to_hash
|
@@ -52,7 +52,7 @@ module Softcover
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# Returns a content.opf file based on a valid template.
|
55
|
-
def content_opf_template(
|
55
|
+
def content_opf_template(escaped_title, copyright, author, uuid, cover_id,
|
56
56
|
toc_chapters, manifest_chapters, images)
|
57
57
|
if cover_id
|
58
58
|
cover_meta = %(<meta name="cover" content="#{cover_id}"/>)
|
@@ -65,10 +65,10 @@ module Softcover
|
|
65
65
|
<package unique-identifier="BookID" version="3.0" xmlns="http://www.idpf.org/2007/opf">
|
66
66
|
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
|
67
67
|
xmlns:opf="http://www.idpf.org/2007/opf">
|
68
|
-
<dc:title>#{
|
68
|
+
<dc:title>#{escaped_title}</dc:title>
|
69
69
|
<dc:language>en</dc:language>
|
70
70
|
<dc:rights>Copyright (c) #{copyright} #{escape(author)}</dc:rights>
|
71
|
-
<dc:creator>#{author}</dc:creator>
|
71
|
+
<dc:creator>#{escape(author)}</dc:creator>
|
72
72
|
<dc:publisher>Softcover</dc:publisher>
|
73
73
|
<dc:identifier id="BookID">urn:uuid:#{uuid}</dc:identifier>
|
74
74
|
<meta property="dcterms:modified">#{Time.now.strftime('%Y-%m-%dT%H:%M:%S')}Z</meta>
|
@@ -96,7 +96,7 @@ module Softcover
|
|
96
96
|
end
|
97
97
|
|
98
98
|
# Returns a toc.ncx file based on a valid template.
|
99
|
-
def toc_ncx_template(
|
99
|
+
def toc_ncx_template(escaped_title, uuid, chapter_nav)
|
100
100
|
%(<?xml version="1.0" encoding="UTF-8"?>
|
101
101
|
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
102
102
|
<head>
|
@@ -106,7 +106,7 @@ module Softcover
|
|
106
106
|
<meta name="dtb:maxPageNumber" content="0"/>
|
107
107
|
</head>
|
108
108
|
<docTitle>
|
109
|
-
<text>#{
|
109
|
+
<text>#{escaped_title}</text>
|
110
110
|
</docTitle>
|
111
111
|
<navMap>
|
112
112
|
#{chapter_nav.join("\n")}
|
@@ -116,16 +116,16 @@ module Softcover
|
|
116
116
|
end
|
117
117
|
|
118
118
|
# Returns the navigation HTML based on a valid template.
|
119
|
-
def nav_html_template(
|
119
|
+
def nav_html_template(escaped_title, nav_list)
|
120
120
|
%(<?xml version="1.0" encoding="utf-8"?>
|
121
121
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
|
122
122
|
<head>
|
123
123
|
<meta charset="UTF-8" />
|
124
|
-
<title>#{
|
124
|
+
<title>#{escaped_title}</title>
|
125
125
|
</head>
|
126
126
|
<body>
|
127
127
|
<nav epub:type="toc">
|
128
|
-
<h1>#{
|
128
|
+
<h1>#{escaped_title}</h1>
|
129
129
|
<ol>
|
130
130
|
#{nav_list.join("\n")}
|
131
131
|
</ol>
|
@@ -545,7 +545,9 @@ module Softcover
|
|
545
545
|
id = "img-#{label}"
|
546
546
|
%(<item id="#{id}" href="#{href}" media-type="image/#{ext}"/>)
|
547
547
|
end
|
548
|
-
|
548
|
+
|
549
|
+
manifest.html_title
|
550
|
+
content_opf_template(manifest.html_title, manifest.copyright,
|
549
551
|
manifest.author, manifest.uuid, cover_id(options),
|
550
552
|
toc_ch, man_ch, images)
|
551
553
|
end
|
@@ -590,7 +592,7 @@ module Softcover
|
|
590
592
|
chapter_nav << %(</navPoint>)
|
591
593
|
end
|
592
594
|
end
|
593
|
-
toc_ncx_template(manifest.
|
595
|
+
toc_ncx_template(manifest.html_title, manifest.uuid, chapter_nav)
|
594
596
|
end
|
595
597
|
|
596
598
|
def chapter_name(n)
|
@@ -615,7 +617,7 @@ module Softcover
|
|
615
617
|
%(<li>#{element}</li>)
|
616
618
|
end
|
617
619
|
end
|
618
|
-
nav_html_template(manifest.
|
620
|
+
nav_html_template(manifest.html_title, nav_list)
|
619
621
|
end
|
620
622
|
|
621
623
|
# Returns a navigation link for the chapter.
|
data/lib/softcover/utils.rb
CHANGED
@@ -326,4 +326,10 @@ module Softcover::Utils
|
|
326
326
|
stream.reopen(old_stream)
|
327
327
|
old_stream.close
|
328
328
|
end
|
329
|
+
|
330
|
+
# Run text through the Polytexnic pipeline to make an HTML snippet.
|
331
|
+
def polytexnic_html(text)
|
332
|
+
Nokogiri::HTML(Polytexnic::Pipeline.new(text).to_html).at_css('p')
|
333
|
+
.inner_html.strip
|
334
|
+
end
|
329
335
|
end
|
data/lib/softcover/version.rb
CHANGED
data/spec/builders/epub_spec.rb
CHANGED
@@ -256,7 +256,7 @@ end
|
|
256
256
|
|
257
257
|
describe Softcover::EpubUtils do
|
258
258
|
let(:dummy_class) { Class.new { include Softcover::EpubUtils } }
|
259
|
-
let(:
|
259
|
+
let(:escaped_title) { 'Foo Bar & Grill' }
|
260
260
|
let(:uuid) { '550e8400-e29b-41d4-a716-446655440000' }
|
261
261
|
|
262
262
|
context "content.opf template" do
|
@@ -268,8 +268,8 @@ describe Softcover::EpubUtils do
|
|
268
268
|
let(:images) { [] }
|
269
269
|
|
270
270
|
let(:template) do
|
271
|
-
dummy_class.new.content_opf_template(
|
272
|
-
cover_id, toc_chapters,
|
271
|
+
dummy_class.new.content_opf_template(escaped_title, copyright, author,
|
272
|
+
uuid, cover_id, toc_chapters,
|
273
273
|
manifest_chapters, images)
|
274
274
|
end
|
275
275
|
|
@@ -285,7 +285,7 @@ describe Softcover::EpubUtils do
|
|
285
285
|
context "toc.ncx template" do
|
286
286
|
let(:chapter_nav) { [] }
|
287
287
|
let(:template) do
|
288
|
-
dummy_class.new.toc_ncx_template(
|
288
|
+
dummy_class.new.toc_ncx_template(escaped_title, uuid, chapter_nav)
|
289
289
|
end
|
290
290
|
|
291
291
|
it "should have the right (escaped) content" do
|
@@ -297,7 +297,7 @@ describe Softcover::EpubUtils do
|
|
297
297
|
context "nav.xhtml template" do
|
298
298
|
let(:nav_list) { [] }
|
299
299
|
let(:template) do
|
300
|
-
dummy_class.new.nav_html_template(
|
300
|
+
dummy_class.new.nav_html_template(escaped_title, nav_list)
|
301
301
|
end
|
302
302
|
|
303
303
|
it "should have the right (escaped) content" do
|
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.4.
|
4
|
+
version: 1.4.3
|
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: 2017-
|
12
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: polytexnic
|