gepub 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gepub/book.rb +7 -5
- data/lib/gepub/book_add_item.rb +4 -4
- data/lib/gepub/item.rb +1 -3
- data/lib/gepub/metadata.rb +1 -1
- data/lib/gepub/version.rb +1 -1
- data/tools/generate_function.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 294cefe070bfd2c4a87e0fd46c45f10f08f75857045ad62ed02b83694ca9e9ae
|
4
|
+
data.tar.gz: 1df169f042577cd0ae74db3565e92f7f70b0b87fd9bafd7de5e3802574ab1578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403d05c6d0a0d0121526d5ce92c8e95dfcb11aae052c84af6bec3303f8039b56852cc64fd4e1d171c715ad2b728a6eee2cee6043cedca2576999c7ccf1f35ae8
|
7
|
+
data.tar.gz: 89e1b455c6d1653fc4ec60ada97da3da50d508260ce5309ca3ec3aceabecd528b1941723ac5a4e594ec0bb34ea99d7ef64a5c4c573f22d5dc7627ea9e8d4b3f0
|
data/lib/gepub/book.rb
CHANGED
@@ -266,7 +266,7 @@ EOF
|
|
266
266
|
|
267
267
|
def nav_doc(title = 'Table of Contents')
|
268
268
|
# handle cascaded toc
|
269
|
-
start_level = @toc && @toc[0][:level] || 1
|
269
|
+
start_level = @toc && !@toc.empty? && @toc[0][:level] || 1
|
270
270
|
stacked_toc = {level: start_level, tocs: [] }
|
271
271
|
@toc.inject(stacked_toc) do |current_stack, toc_entry|
|
272
272
|
toc_entry_level = toc_entry[:level] || 1
|
@@ -428,7 +428,7 @@ EOF
|
|
428
428
|
|_x,item|
|
429
429
|
item.media_type == 'application/x-dtbncx+xml'
|
430
430
|
}.size == 0
|
431
|
-
if (@toc.size == 0)
|
431
|
+
if (@toc.size == 0 && !@package.spine.itemref_list.empty?)
|
432
432
|
@toc << { :item => @package.manifest.item_list[@package.spine.itemref_list[0].idref] }
|
433
433
|
end
|
434
434
|
add_item('toc.ncx', id: 'ncx', content: StringIO.new(ncx_xml))
|
@@ -467,10 +467,12 @@ EOF
|
|
467
467
|
item_attributes.each do |attr, val|
|
468
468
|
next if val.nil?
|
469
469
|
method_name = if attr == :toc_text
|
470
|
-
|
470
|
+
""
|
471
|
+
elsif attr == :property
|
472
|
+
"add_"
|
471
473
|
else
|
472
|
-
"
|
473
|
-
end
|
474
|
+
"set_"
|
475
|
+
end + attr.to_s
|
474
476
|
item.send(method_name, val)
|
475
477
|
end
|
476
478
|
item
|
data/lib/gepub/book_add_item.rb
CHANGED
@@ -3,18 +3,18 @@ module GEPUB
|
|
3
3
|
# add an item(i.e. html, images, audios, etc) to Book.
|
4
4
|
# the added item will be referenced by the first argument in the EPUB container.
|
5
5
|
def add_item(href, deprecated_content = nil, deprecated_id = nil, deprecated_attributes = nil, content: nil,
|
6
|
-
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,
|
6
|
+
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
|
7
7
|
attributes: {})
|
8
8
|
content, id, attributes = handle_deprecated_add_item_arguments(deprecated_content, deprecated_id, deprecated_attributes, content, id, attributes)
|
9
|
-
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text }, attributes: attributes, ordered: false)
|
9
|
+
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text,property: property }, attributes: attributes, ordered: false)
|
10
10
|
end
|
11
11
|
|
12
12
|
# same as add_item, but the item will be added to spine of the EPUB.
|
13
13
|
def add_ordered_item(href, deprecated_content = nil, deprecated_id = nil, deprecated_attributes = nil, content:nil,
|
14
|
-
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,
|
14
|
+
id: nil,media_type: nil,fallback: nil,properties: nil,media_overlay: nil,toc_text: nil,property: nil,
|
15
15
|
attributes: {})
|
16
16
|
content, id, attributes = handle_deprecated_add_item_arguments(deprecated_content, deprecated_id, deprecated_attributes, content, id, attributes)
|
17
|
-
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text }, attributes: attributes, ordered: true)
|
17
|
+
add_item_internal(href, content: content, item_attributes: { id: id,media_type: media_type,fallback: fallback,properties: properties,media_overlay: media_overlay,toc_text: toc_text,property: property }, attributes: attributes, ordered: true)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/gepub/item.rb
CHANGED
@@ -97,9 +97,7 @@ module GEPUB
|
|
97
97
|
# guess and set content property from contents.
|
98
98
|
def guess_content_property
|
99
99
|
if File.extname(self.href) =~ /.x?html/ && @attributes['media-type'] === 'application/xhtml+xml'
|
100
|
-
@attributes['properties']
|
101
|
-
|x| x == 'svg' || x == 'mathml' || x == 'switch' || x == 'remote-resources'
|
102
|
-
}
|
100
|
+
@attributes['properties'] ||= []
|
103
101
|
parsed = Nokogiri::XML::Document.parse(@content)
|
104
102
|
return unless parsed.root.node_name === "html"
|
105
103
|
ns_prefix = parsed.namespaces.invert['http://www.w3.org/1999/xhtml']
|
data/lib/gepub/metadata.rb
CHANGED
data/lib/gepub/version.rb
CHANGED
data/tools/generate_function.rb
CHANGED
@@ -4,7 +4,8 @@ attrs = GEPUB::Item::ATTRIBUTES.select do |attr|
|
|
4
4
|
end.map do |attr|
|
5
5
|
attr.sub('-', '_')
|
6
6
|
end
|
7
|
-
attrs << "toc_text"
|
7
|
+
attrs << "toc_text"
|
8
|
+
attrs << "property"
|
8
9
|
attrs_arguments_string = attrs.map { |attr| "#{attr}: nil" }.join(',')
|
9
10
|
attrs_internal_string = "{ " + attrs.map { |attr| "#{attr}: #{attr}"}.join(',') + " }"
|
10
11
|
File.write(File.join(File.dirname(__FILE__), "../lib/gepub/book_add_item.rb"), <<EOF)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gepub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KOJIMA Satoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|