epuber 0.9.2 → 0.9.4
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/epuber/compiler/file_resolver.rb +4 -4
- data/lib/epuber/compiler/file_types/css_file.rb +12 -5
- data/lib/epuber/compiler/file_types/source_file.rb +9 -2
- data/lib/epuber/compiler/file_types/stylus_file.rb +5 -1
- data/lib/epuber/compiler/opf_generator.rb +9 -3
- data/lib/epuber/compiler/xhtml_processor.rb +2 -1
- data/lib/epuber/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdced1dd2ebd0dc9d67e06757560ed5acd26d93303db343b53985b3c7aeebe20
|
4
|
+
data.tar.gz: e979d0957ff1a554bc4f29cb4e2bbe6cd0a113a83a42ed46a6e80c8f049e8008
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2ea5b2448b893e8c1c6cb47d4868cdfcd8e16aefeb54733c880c686107439ba51ec50aa89f0f571b6322998d5fe1d4862d4b8a4e78df003fbe4d1d849ebcbc9
|
7
|
+
data.tar.gz: 6492a8277ff6d0179a5fd91e3758cc0edc5ff73faf584237336395a52d151654a7c451085ddde6e40532010b3e6d5f9046a3f058237c7879b6da184141b63877
|
@@ -36,19 +36,19 @@ module Epuber
|
|
36
36
|
attr_reader :destination_path
|
37
37
|
|
38
38
|
|
39
|
-
# @return [Array<FileTypes::
|
39
|
+
# @return [Array<Epuber::Compiler::FileTypes::AbstractFile>] all files that will be in spine
|
40
40
|
#
|
41
41
|
attr_reader :spine_files
|
42
42
|
|
43
|
-
# @return [Array<FileTypes::
|
43
|
+
# @return [Array<Epuber::Compiler::FileTypes::AbstractFile>] all files that has to be in manifest file (OPF)
|
44
44
|
#
|
45
45
|
attr_reader :manifest_files
|
46
46
|
|
47
|
-
# @return [Array<FileTypes::
|
47
|
+
# @return [Array<Epuber::Compiler::FileTypes::AbstractFile>] all files that will be copied to EPUB package
|
48
48
|
#
|
49
49
|
attr_reader :package_files
|
50
50
|
|
51
|
-
# @return [Array<FileTypes::
|
51
|
+
# @return [Array<Epuber::Compiler::FileTypes::AbstractFile>] totally all files
|
52
52
|
#
|
53
53
|
attr_reader :files
|
54
54
|
|
@@ -27,9 +27,12 @@ module Epuber
|
|
27
27
|
# @param [Compiler::CompilationContext] compilation_context
|
28
28
|
#
|
29
29
|
def process(compilation_context)
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if destination_file_up_to_date?
|
31
|
+
# HACK: for now, we need to process the file again, because we need to find linked files
|
32
|
+
process_css(File.read(final_destination_path), compilation_context)
|
33
|
+
else
|
34
|
+
write_processed(process_css(File.read(abs_source_path), compilation_context))
|
35
|
+
end
|
33
36
|
end
|
34
37
|
|
35
38
|
# Processes CSS file, resolves all linked files and adds them to file resolver
|
@@ -49,8 +52,10 @@ module Epuber
|
|
49
52
|
# resolve links to files, add other linked resources and compute correct path
|
50
53
|
UI.print_step_processing_time('resolving url()') do
|
51
54
|
parser.each_rule_set do |rule_set, _media_types|
|
55
|
+
# @type [CssParser::RuleSet::Declarations]
|
52
56
|
declarations = rule_set.instance_eval { @declarations }
|
53
57
|
declarations.each do |property, decl_value|
|
58
|
+
# @type [String]
|
54
59
|
value = decl_value.to_s
|
55
60
|
next unless value =~ URL_REGEXP
|
56
61
|
|
@@ -70,8 +75,10 @@ module Epuber
|
|
70
75
|
new_url = SourceFile.resolve_relative_file(destination_path,
|
71
76
|
path,
|
72
77
|
compilation_context.file_resolver,
|
73
|
-
group: resource_group
|
74
|
-
|
78
|
+
group: resource_group,
|
79
|
+
location: self)
|
80
|
+
|
81
|
+
content = content.gsub(value, "url(#{quote}#{new_url}#{quote})") if new_url
|
75
82
|
end
|
76
83
|
end
|
77
84
|
end
|
@@ -36,6 +36,12 @@ module Epuber
|
|
36
36
|
# do nothing
|
37
37
|
end
|
38
38
|
|
39
|
+
# @return [Set<Symbol>] list of properties
|
40
|
+
#
|
41
|
+
def properties
|
42
|
+
file_request&.properties || super
|
43
|
+
end
|
44
|
+
|
39
45
|
# Source file does not change from last build
|
40
46
|
# @warning Using only this method can cause not updating files that are different for targets
|
41
47
|
#
|
@@ -113,7 +119,7 @@ module Epuber
|
|
113
119
|
end
|
114
120
|
end
|
115
121
|
|
116
|
-
def self.resolve_relative_file(destination_path, pattern, file_resolver, group: nil)
|
122
|
+
def self.resolve_relative_file(destination_path, pattern, file_resolver, group: nil, location: nil)
|
117
123
|
dirname = File.dirname(destination_path)
|
118
124
|
|
119
125
|
begin
|
@@ -127,7 +133,8 @@ module Epuber
|
|
127
133
|
rescue XHTMLProcessor::UnparseableLinkError,
|
128
134
|
FileFinders::FileNotFoundError,
|
129
135
|
FileFinders::MultipleFilesFoundError => e
|
130
|
-
UI.warning(e.to_s, location:
|
136
|
+
UI.warning(e.to_s, location: location)
|
137
|
+
return nil
|
131
138
|
end
|
132
139
|
end
|
133
140
|
|
@@ -11,7 +11,11 @@ module Epuber
|
|
11
11
|
# @param [Compiler::CompilationContext] compilation_context
|
12
12
|
#
|
13
13
|
def process(compilation_context)
|
14
|
-
|
14
|
+
if destination_file_up_to_date?
|
15
|
+
# HACK: for now, we need to process the file again, because we need to find linked files
|
16
|
+
process_css(File.read(final_destination_path), compilation_context)
|
17
|
+
return
|
18
|
+
end
|
15
19
|
|
16
20
|
Stylus.define('__is_debug', !compilation_context.release_build)
|
17
21
|
Stylus.define('__is_verbose_mode', compilation_context.verbose?)
|
@@ -126,7 +126,10 @@ module Epuber
|
|
126
126
|
cover_image = @target.cover_image
|
127
127
|
unless cover_image.nil?
|
128
128
|
cover_image_result = @file_resolver.file_from_request(cover_image)
|
129
|
-
|
129
|
+
if cover_image_result
|
130
|
+
@xml.meta(name: 'cover',
|
131
|
+
content: create_id_from_path(pretty_path(cover_image_result)))
|
132
|
+
end
|
130
133
|
end
|
131
134
|
|
132
135
|
if epub_version >= 3
|
@@ -164,8 +167,11 @@ module Epuber
|
|
164
167
|
|
165
168
|
properties = file.properties
|
166
169
|
if properties.length.positive? && @target.epub_version >= 3
|
167
|
-
|
168
|
-
|
170
|
+
formatted = properties.to_a
|
171
|
+
.map { |prop| PROPERTIES_MAP[prop] }
|
172
|
+
.compact
|
173
|
+
.join(' ')
|
174
|
+
attrs['properties'] = formatted unless formatted.empty?
|
169
175
|
end
|
170
176
|
|
171
177
|
@xml.item(attrs)
|
@@ -351,7 +351,8 @@ module Epuber
|
|
351
351
|
new_path = Compiler::FileTypes::SourceFile.resolve_relative_file(file_path,
|
352
352
|
path,
|
353
353
|
file_resolver,
|
354
|
-
group: resource_group
|
354
|
+
group: resource_group,
|
355
|
+
location: img)
|
355
356
|
img[attribute_name] = new_path if new_path
|
356
357
|
end
|
357
358
|
end
|
data/lib/epuber/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epuber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Kříž
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -594,7 +594,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
594
594
|
- !ruby/object:Gem::Version
|
595
595
|
version: '0'
|
596
596
|
requirements: []
|
597
|
-
rubygems_version: 3.5.
|
597
|
+
rubygems_version: 3.5.10
|
598
598
|
signing_key:
|
599
599
|
specification_version: 4
|
600
600
|
summary: Epuber is simple tool to compile and pack source files into EPUB format.
|