softcover 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be7beabc27f27101e3e7d017ef34f9d2b2c26be0
4
- data.tar.gz: 6c5bb91b5781858278301681a211c4df20381c9f
3
+ metadata.gz: a2e434aa507ebf2c6b6dce94b8ccf31c1aba5aae
4
+ data.tar.gz: d91a6cb4c4a6c371a3ff4473483bbb8a78e62300
5
5
  SHA512:
6
- metadata.gz: 6d25b2ca9d8fe5eed7fc8f56b2318899621cccd92693b201a007ca9ccbe1f2d9865e787fabcb562a36fb3c0111d4e3e4325434849beed8222377e2b9f3ac4559
7
- data.tar.gz: 911bf475818949a1c21a4500db7a6fff42999e886a1a1c5128b84f6aa9ce90c6e7d1969237cfd341a0832cfeb3fb304ebcfd8f681377a64e48331a9280f1597e
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
- Nokogiri::HTML(Polytexnic::Pipeline.new(title).to_html).at_css('p')
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(title, copyright, author, uuid, cover_id,
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>#{escape(title)}</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(title, uuid, chapter_nav)
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>#{escape(title)}</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(title, nav_list)
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>#{title}</title>
124
+ <title>#{escaped_title}</title>
125
125
  </head>
126
126
  <body>
127
127
  <nav epub:type="toc">
128
- <h1>#{escape(title)}</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
- content_opf_template(manifest.title, manifest.copyright,
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.title, manifest.uuid, chapter_nav)
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.title, nav_list)
620
+ nav_html_template(manifest.html_title, nav_list)
619
621
  end
620
622
 
621
623
  # Returns a navigation link for the chapter.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
@@ -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(:title) { 'Foo Bar & Grill' }
259
+ let(:escaped_title) { 'Foo Bar &amp; 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(title, copyright, author, uuid,
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(title, uuid, chapter_nav)
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(title, nav_list)
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.2
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-05-25 00:00:00.000000000 Z
12
+ date: 2017-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: polytexnic