review 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +43 -1
- data/.rubocop_todo.yml +605 -0
- data/.travis.yml +9 -0
- data/ChangeLog +4 -0
- data/Dockerfile +22 -0
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/bin/review-check +8 -21
- data/bin/review-compile +9 -15
- data/bin/review-epubmaker-legacy +6 -6
- data/bin/review-index +2 -13
- data/bin/review-preproc +1 -14
- data/bin/review-validate +1 -1
- data/bin/review-vol +1 -13
- data/doc/NEWS.ja.md +22 -0
- data/doc/NEWS.md +22 -0
- data/doc/quickstart.ja.md +1 -1
- data/doc/quickstart.md +1 -1
- data/lib/epubmaker/content.rb +3 -3
- data/lib/epubmaker/epubcommon.rb +91 -108
- data/lib/epubmaker/epubv2.rb +14 -67
- data/lib/epubmaker/epubv3.rb +25 -59
- data/lib/epubmaker/producer.rb +12 -0
- data/lib/review/book/base.rb +12 -4
- data/lib/review/book/compilable.rb +1 -3
- data/lib/review/book/index.rb +4 -4
- data/lib/review/builder.rb +6 -11
- data/lib/review/compiler.rb +7 -7
- data/lib/review/configure.rb +20 -8
- data/lib/review/epubbuilder.rb +1 -1
- data/lib/review/epubmaker.rb +52 -122
- data/lib/review/ewbbuilder.rb +4 -4
- data/lib/review/exception.rb +1 -1
- data/lib/review/htmlbuilder.rb +49 -54
- data/lib/review/htmltoc.rb +45 -0
- data/lib/review/htmlutils.rb +3 -3
- data/lib/review/i18n.rb +6 -2
- data/lib/review/i18n.yml +1 -1
- data/lib/review/idgxmlbuilder.rb +4 -5
- data/lib/review/inaobuilder.rb +1 -1
- data/lib/review/latexbuilder.rb +2 -2
- data/lib/review/latexutils.rb +6 -6
- data/lib/review/markdownbuilder.rb +4 -3
- data/lib/review/pdfmaker.rb +92 -92
- data/lib/review/preprocessor.rb +14 -51
- data/lib/review/template.rb +21 -0
- data/lib/review/textbuilder.rb +1 -1
- data/lib/review/textutils.rb +0 -28
- data/lib/review/tocparser.rb +3 -3
- data/lib/review/tocprinter.rb +8 -31
- data/lib/review/topbuilder.rb +2 -3
- data/lib/review/unfold.rb +2 -2
- data/lib/review/version.rb +1 -1
- data/review.gemspec +2 -1
- data/templates/html/layout-html5.html.erb +17 -0
- data/templates/html/layout-xhtml1.html.erb +20 -0
- data/templates/ncx/epubv2.ncx.erb +11 -0
- data/templates/opf/epubv2.opf.erb +21 -0
- data/templates/opf/epubv3.opf.erb +18 -0
- data/templates/xml/container.xml.erb +6 -0
- data/test/assets/test.xml.erb +3 -0
- data/test/test.re +1 -1
- data/test/test_book.rb +4 -4
- data/test/test_book_chapter.rb +0 -76
- data/test/test_book_part.rb +1 -1
- data/test/test_builder.rb +0 -49
- data/test/test_configure.rb +50 -0
- data/test/test_htmlbuilder.rb +54 -4
- data/test/test_htmltoc.rb +32 -0
- data/test/test_i18n.rb +3 -5
- data/test/test_idgxmlbuilder.rb +0 -2
- data/test/test_inaobuilder.rb +2 -4
- data/test/test_latexbuilder.rb +2 -4
- data/test/test_lineinput.rb +0 -18
- data/test/test_markdownbuilder.rb +5 -4
- data/test/test_pdfmaker.rb +11 -10
- data/test/test_template.rb +26 -0
- data/test/test_topbuilder.rb +0 -2
- metadata +35 -4
- data/rubocop-todo.yml +0 -456
data/lib/epubmaker/epubcommon.rb
CHANGED
@@ -28,6 +28,10 @@ module EPUBMaker
|
|
28
28
|
"application/epub+zip"
|
29
29
|
end
|
30
30
|
|
31
|
+
def opf_path
|
32
|
+
"OEBPS/#{@producer.params["bookname"]}.opf"
|
33
|
+
end
|
34
|
+
|
31
35
|
def opf_coverimage
|
32
36
|
s = ""
|
33
37
|
if @producer.params["coverimage"]
|
@@ -112,66 +116,53 @@ EOT
|
|
112
116
|
|
113
117
|
# Return container content.
|
114
118
|
def container
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<rootfile full-path="OEBPS/#{@producer.params["bookname"]}.opf" media-type="application/oebps-package+xml" />
|
120
|
-
</rootfiles>
|
121
|
-
</container>
|
122
|
-
EOT
|
123
|
-
s
|
119
|
+
@opf_path = opf_path
|
120
|
+
tmplfile = File.expand_path('./xml/container.xml.erb', ReVIEW::Template::TEMPLATE_DIR)
|
121
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
122
|
+
tmpl.result(binding)
|
124
123
|
end
|
125
124
|
|
126
125
|
# Return cover content.
|
127
126
|
def cover(type=nil)
|
128
|
-
|
127
|
+
@body_ext = type.nil? ? "" : " epub:type=\"#{type}\""
|
129
128
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
<body#{bodyext}>
|
135
|
-
EOT
|
136
|
-
if @producer.params["coverimage"].nil?
|
137
|
-
s << <<EOT
|
138
|
-
<h1 class="cover-title">#{CGI.escapeHTML(@producer.params["title"])}</h1>
|
139
|
-
EOT
|
140
|
-
else
|
141
|
-
file = nil
|
142
|
-
@producer.contents.each do |item|
|
143
|
-
if item.media =~ /\Aimage/ && item.file =~ /#{@producer.params["coverimage"]}\Z/ # /
|
144
|
-
file = item.file
|
145
|
-
break
|
146
|
-
end
|
129
|
+
if @producer.params["coverimage"]
|
130
|
+
file = @producer.coverimage
|
131
|
+
if !file
|
132
|
+
raise "coverimage #{@producer.params["coverimage"]} not found. Abort."
|
147
133
|
end
|
148
|
-
|
149
|
-
s << <<EOT
|
134
|
+
@body = <<-EOT
|
150
135
|
<div id="cover-image" class="cover-image">
|
151
136
|
<img src="#{file}" alt="#{CGI.escapeHTML(@producer.params["title"])}" class="max"/>
|
152
137
|
</div>
|
153
|
-
EOT
|
138
|
+
EOT
|
139
|
+
else
|
140
|
+
@body = <<-EOT
|
141
|
+
<h1 class="cover-title">#{CGI.escapeHTML(@producer.params["title"])}</h1>
|
142
|
+
EOT
|
154
143
|
end
|
155
144
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
145
|
+
@title = @producer.params['title']
|
146
|
+
@language = @producer.params['language']
|
147
|
+
@stylesheets = @producer.params["stylesheet"]
|
148
|
+
if @producer.params["htmlversion"].to_i == 5
|
149
|
+
tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
150
|
+
else
|
151
|
+
tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
152
|
+
end
|
153
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
154
|
+
tmpl.result(binding)
|
161
155
|
end
|
162
156
|
|
163
157
|
# Return title (copying) content.
|
164
158
|
def titlepage
|
165
|
-
|
166
|
-
s << <<EOT
|
167
|
-
<title>#{CGI.escapeHTML(@producer.params["title"])}</title>
|
168
|
-
</head>
|
169
|
-
<body>
|
170
|
-
<h1 class="tp-title">#{CGI.escapeHTML(@producer.params["title"])}</h1>
|
171
|
-
EOT
|
159
|
+
@title = @producer.params["title"]
|
172
160
|
|
161
|
+
@body = <<EOT
|
162
|
+
<h1 class="tp-title">#{CGI.escapeHTML(@title)}</h1>
|
163
|
+
EOT
|
173
164
|
if @producer.params["aut"]
|
174
|
-
|
165
|
+
@body << <<EOT
|
175
166
|
<p>
|
176
167
|
<br />
|
177
168
|
<br />
|
@@ -182,7 +173,7 @@ EOT
|
|
182
173
|
|
183
174
|
publisher = @producer.params["pbl"] || @producer.params["prt"] # XXX Backward Compatiblity
|
184
175
|
if publisher
|
185
|
-
|
176
|
+
@body << <<EOT
|
186
177
|
<p>
|
187
178
|
<br />
|
188
179
|
<br />
|
@@ -193,67 +184,66 @@ EOT
|
|
193
184
|
EOT
|
194
185
|
end
|
195
186
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
187
|
+
@language = @producer.params['language']
|
188
|
+
@stylesheets = @producer.params["stylesheet"]
|
189
|
+
if @producer.params["htmlversion"].to_i == 5
|
190
|
+
tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
191
|
+
else
|
192
|
+
tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
193
|
+
end
|
194
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
195
|
+
tmpl.result(binding)
|
202
196
|
end
|
203
197
|
|
204
198
|
# Return colophon content.
|
205
199
|
def colophon
|
206
|
-
|
207
|
-
|
208
|
-
<title>#{@producer.res.v("colophontitle")}</title>
|
209
|
-
</head>
|
210
|
-
<body>
|
200
|
+
@title = @producer.res.v("colophontitle")
|
201
|
+
@body = <<EOT
|
211
202
|
<div class="colophon">
|
212
203
|
EOT
|
213
204
|
|
214
205
|
if @producer.params["subtitle"].nil?
|
215
|
-
|
206
|
+
@body << <<EOT
|
216
207
|
<p class="title">#{CGI.escapeHTML(@producer.params["title"])}</p>
|
217
208
|
EOT
|
218
209
|
else
|
219
|
-
|
210
|
+
@body << <<EOT
|
220
211
|
<p class="title">#{CGI.escapeHTML(@producer.params["title"])}<br /><span class="subtitle">#{CGI.escapeHTML(@producer.params["subtitle"])}</span></p>
|
221
212
|
EOT
|
222
213
|
end
|
223
214
|
|
224
215
|
if @producer.params["date"] || @producer.params["history"]
|
225
|
-
|
216
|
+
@body << %Q[ <div class="pubhistory">\n]
|
226
217
|
if @producer.params["history"]
|
227
218
|
@producer.params["history"].each_with_index do |items, edit|
|
228
219
|
items.each_with_index do |item, rev|
|
229
220
|
editstr = (edit == 0) ? ReVIEW::I18n.t("first_edition") : ReVIEW::I18n.t("nth_edition","#{edit+1}")
|
230
221
|
revstr = ReVIEW::I18n.t("nth_impression", "#{rev+1}")
|
231
222
|
if item =~ /\A\d+\-\d+\-\d+\Z/
|
232
|
-
|
223
|
+
@body << %Q[ <p>#{ReVIEW::I18n.t("published_by1", [date_to_s(item), editstr+revstr])}</p>\n]
|
233
224
|
else
|
234
225
|
# custom date with string
|
235
226
|
item.match(/\A(\d+\-\d+\-\d+)[\s ](.+)/) do |m|
|
236
|
-
|
227
|
+
@body << %Q[ <p>#{ReVIEW::I18n.t("published_by3", [date_to_s(m[1]), m[2]])}</p>\n]
|
237
228
|
end
|
238
229
|
end
|
239
230
|
end
|
240
231
|
end
|
241
232
|
else
|
242
|
-
|
233
|
+
@body << %Q[ <p>#{ReVIEW::I18n.t("published_by2", date_to_s(@producer.params["date"]))}</p>\n]
|
243
234
|
end
|
244
|
-
|
235
|
+
@body << %Q[ </div>\n]
|
245
236
|
end
|
246
237
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
s << %Q[ <tr><th>#{@producer.res.v("pht")}</th><td>#{CGI.escapeHTML(@producer.params["pht"].join(", "))}</td></tr>\n] unless @producer.params["pht"].nil?
|
238
|
+
@body << %Q[ <table class="colophon">\n]
|
239
|
+
@body << %w[aut csl trl dsr ill edt pbl prt pht].map{ |role|
|
240
|
+
if @producer.params[role]
|
241
|
+
%Q[ <tr><th>#{@producer.res.v(role)}</th><td>#{CGI.escapeHTML(@producer.params[role].join(", "))}</td></tr>\n]
|
242
|
+
else
|
243
|
+
""
|
244
|
+
end
|
245
|
+
}.join("")
|
246
|
+
|
257
247
|
if @producer.params["isbn"].to_s =~ /\A\d{10}\Z/ || @producer.params["isbn"].to_s =~ /\A\d{13}\Z/
|
258
248
|
isbn = nil
|
259
249
|
str = @producer.params["isbn"].to_s
|
@@ -262,21 +252,23 @@ EOT
|
|
262
252
|
else
|
263
253
|
isbn = "#{str[0..2]}-#{str[3..3]}-#{str[4..8]}-#{str[9..11]}-#{str[12..12]}"
|
264
254
|
end
|
265
|
-
|
255
|
+
@body << %Q[ <tr><th>ISBN</th><td>#{isbn}</td></tr>\n]
|
266
256
|
end
|
267
|
-
|
268
|
-
</table>
|
269
|
-
EOT
|
257
|
+
@body << %Q[ </table>\n]
|
270
258
|
if !@producer.params["rights"].nil? && @producer.params["rights"].size > 0
|
271
|
-
|
259
|
+
@body << %Q[ <p class="copyright">#{@producer.params["rights"].join("<br />")}</p>]
|
272
260
|
end
|
261
|
+
@body << %Q[ </div>\n]
|
273
262
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
263
|
+
@language = @producer.params['language']
|
264
|
+
@stylesheets = @producer.params["stylesheet"]
|
265
|
+
if @producer.params["htmlversion"].to_i == 5
|
266
|
+
tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
267
|
+
else
|
268
|
+
tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
269
|
+
end
|
270
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
271
|
+
tmpl.result(binding)
|
280
272
|
end
|
281
273
|
|
282
274
|
def date_to_s(date)
|
@@ -287,25 +279,24 @@ EOT
|
|
287
279
|
|
288
280
|
# Return own toc content.
|
289
281
|
def mytoc
|
290
|
-
|
291
|
-
s << <<EOT
|
292
|
-
<title>#{@producer.res.v("toctitle")}</title>
|
293
|
-
</head>
|
294
|
-
<body>
|
295
|
-
<h1 class="toc-title">#{@producer.res.v("toctitle")}</h1>
|
296
|
-
EOT
|
282
|
+
@title = @producer.res.v("toctitle")
|
297
283
|
|
284
|
+
@body = %Q[ <h1 class="toc-title">#{@producer.res.v("toctitle")}</h1>\n]
|
298
285
|
if @producer.params["epubmaker"]["flattoc"].nil?
|
299
|
-
|
286
|
+
@body << hierarchy_ncx("ul")
|
300
287
|
else
|
301
|
-
|
288
|
+
@body << flat_ncx("ul", @producer.params["epubmaker"]["flattocindent"])
|
302
289
|
end
|
303
290
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
291
|
+
@language = @producer.params['language']
|
292
|
+
@stylesheets = @producer.params["stylesheet"]
|
293
|
+
if @producer.params["htmlversion"].to_i == 5
|
294
|
+
tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
295
|
+
else
|
296
|
+
tmplfile = File.expand_path('./html/layout-xhtml1.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
297
|
+
end
|
298
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
299
|
+
tmpl.result(binding)
|
309
300
|
end
|
310
301
|
|
311
302
|
def hierarchy_ncx(type)
|
@@ -394,7 +385,7 @@ EOT
|
|
394
385
|
File.open("#{tmpdir}/META-INF/container.xml", "w") {|f| @producer.container(f) }
|
395
386
|
|
396
387
|
FileUtils.mkdir_p("#{tmpdir}/OEBPS")
|
397
|
-
File.open(
|
388
|
+
File.open(File.join(tmpdir, opf_path), "w") {|f| @producer.opf(f) }
|
398
389
|
|
399
390
|
if File.exist?("#{basedir}/#{@producer.params["cover"]}")
|
400
391
|
FileUtils.cp("#{basedir}/#{@producer.params["cover"]}", "#{tmpdir}/OEBPS")
|
@@ -417,21 +408,13 @@ EOT
|
|
417
408
|
end
|
418
409
|
|
419
410
|
def legacy_cover_and_title_file(loadfile, writefile)
|
420
|
-
|
421
|
-
s
|
422
|
-
<title>#{@producer.params["booktitle"]}</title>
|
423
|
-
</head>
|
424
|
-
<body>
|
425
|
-
EOT
|
411
|
+
@title = @producer.params["booktitle"]
|
412
|
+
s = ""
|
426
413
|
File.open(loadfile) do |f|
|
427
414
|
f.each_line do |l|
|
428
415
|
s << l
|
429
416
|
end
|
430
417
|
end
|
431
|
-
s << <<EOT
|
432
|
-
</body>
|
433
|
-
</html>
|
434
|
-
EOT
|
435
418
|
|
436
419
|
File.open(writefile, "w") do |f|
|
437
420
|
f.puts s
|
data/lib/epubmaker/epubv2.rb
CHANGED
@@ -23,24 +23,14 @@ module EPUBMaker
|
|
23
23
|
|
24
24
|
# Return opf file content.
|
25
25
|
def opf
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
s << %Q[ </metadata>\n]
|
36
|
-
|
37
|
-
s << opf_manifest
|
38
|
-
s << opf_tocx
|
39
|
-
s << opf_guide
|
40
|
-
|
41
|
-
s << %Q[</package>\n]
|
42
|
-
|
43
|
-
s
|
26
|
+
@opf_metainfo = opf_metainfo
|
27
|
+
@opf_coverimage = opf_coverimage
|
28
|
+
@opf_manifest = opf_manifest
|
29
|
+
@opf_toc = opf_tocx
|
30
|
+
|
31
|
+
tmplfile = File.expand_path('./opf/epubv2.opf.erb', ReVIEW::Template::TEMPLATE_DIR)
|
32
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
33
|
+
return tmpl.result(binding)
|
44
34
|
end
|
45
35
|
|
46
36
|
def opf_metainfo
|
@@ -121,39 +111,15 @@ EOT
|
|
121
111
|
s
|
122
112
|
end
|
123
113
|
|
124
|
-
def opf_guide
|
125
|
-
s = ""
|
126
|
-
s << %Q[ <guide>\n]
|
127
|
-
s << %Q[ <reference type="cover" title="#{@producer.res.v("covertitle")}" href="#{@producer.params["cover"]}"/>\n]
|
128
|
-
s << %Q[ <reference type="title-page" title="#{@producer.res.v("titlepagetitle")}" href="titlepage.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["titlepage"].nil?
|
129
|
-
s << %Q[ <reference type="toc" title="#{@producer.res.v("toctitle")}" href="#{@producer.params["bookname"]}-toc.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["mytoc"].nil?
|
130
|
-
s << %Q[ <reference type="colophon" title="#{@producer.res.v("colophontitle")}" href="colophon.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["colophon"].nil?
|
131
|
-
s << %Q[ </guide>\n]
|
132
|
-
s
|
133
|
-
end
|
134
|
-
|
135
114
|
# Return ncx content. +indentarray+ has prefix marks for each level.
|
136
115
|
def ncx(indentarray)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
<head>
|
141
|
-
<meta name="dtb:depth" content="1"/>
|
142
|
-
<meta name="dtb:totalPageCount" content="0"/>
|
143
|
-
<meta name="dtb:maxPageNumber" content="0"/>
|
144
|
-
EOT
|
145
|
-
s << ncx_isbn
|
116
|
+
@ncx_isbn = ncx_isbn
|
117
|
+
@ncx_doctitle = ncx_doctitle
|
118
|
+
@ncx_navmap = ncx_navmap(indentarray)
|
146
119
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
s << ncx_doctitle
|
151
|
-
s << ncx_navmap(indentarray)
|
152
|
-
|
153
|
-
s << <<EOT
|
154
|
-
</ncx>
|
155
|
-
EOT
|
156
|
-
s
|
120
|
+
tmplfile = File.expand_path('./ncx/epubv2.ncx.erb', ReVIEW::Template::TEMPLATE_DIR)
|
121
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
122
|
+
return tmpl.result(binding)
|
157
123
|
end
|
158
124
|
|
159
125
|
# Produce EPUB file +epubfile+.
|
@@ -169,24 +135,5 @@ EOT
|
|
169
135
|
export_zip(tmpdir, epubfile)
|
170
136
|
end
|
171
137
|
|
172
|
-
private
|
173
|
-
|
174
|
-
# Return common XHTML headder
|
175
|
-
def common_header
|
176
|
-
s =<<EOT
|
177
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
178
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
179
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{@producer.params["language"]}">
|
180
|
-
<head>
|
181
|
-
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
182
|
-
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
183
|
-
<meta name="generator" content="Re:VIEW"/>
|
184
|
-
EOT
|
185
|
-
|
186
|
-
@producer.params["stylesheet"].each do |file|
|
187
|
-
s << %Q[ <link rel="stylesheet" type="text/css" href="#{file}"/>\n]
|
188
|
-
end
|
189
|
-
s
|
190
|
-
end
|
191
138
|
end
|
192
139
|
end
|
data/lib/epubmaker/epubv3.rb
CHANGED
@@ -22,23 +22,13 @@ module EPUBMaker
|
|
22
22
|
|
23
23
|
# Return opf file content.
|
24
24
|
def opf
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
29
|
-
EOT
|
30
|
-
|
31
|
-
s << opf_metainfo
|
32
|
-
|
33
|
-
s << %Q[ </metadata>\n]
|
34
|
-
|
35
|
-
s << opf_manifest
|
36
|
-
s << opf_tocx
|
37
|
-
s << opf_guide # same as ePUB2
|
25
|
+
@opf_metainfo = opf_metainfo
|
26
|
+
@opf_manifest = opf_manifest
|
27
|
+
@opf_toc = opf_tocx
|
38
28
|
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
tmplfile = File.expand_path('./opf/epubv3.opf.erb', ReVIEW::Template::TEMPLATE_DIR)
|
30
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
31
|
+
return tmpl.result(binding)
|
42
32
|
end
|
43
33
|
|
44
34
|
def opf_metainfo
|
@@ -155,7 +145,11 @@ EOT
|
|
155
145
|
end
|
156
146
|
|
157
147
|
s = ""
|
158
|
-
|
148
|
+
if @producer.params["direction"]
|
149
|
+
s << %Q[ <spine page-progression-direction="#{@producer.params["direction"]}">\n]
|
150
|
+
else
|
151
|
+
s << %Q[ <spine>\n]
|
152
|
+
end
|
159
153
|
s << %Q[ <itemref idref="#{@producer.params["bookname"]}" linear="#{cover_linear}"/>\n]
|
160
154
|
s << %Q[ <itemref idref="#{@producer.params["bookname"]}-toc.#{@producer.params["htmlext"]}" />\n] if @producer.params["toc"]
|
161
155
|
|
@@ -168,38 +162,25 @@ EOT
|
|
168
162
|
s
|
169
163
|
end
|
170
164
|
|
171
|
-
def opf_guide
|
172
|
-
s = ""
|
173
|
-
s << %Q[ <guide>\n]
|
174
|
-
s << %Q[ <reference type="cover" title="#{@producer.res.v("covertitle")}" href="#{@producer.params["cover"]}"/>\n]
|
175
|
-
s << %Q[ <reference type="title-page" title="#{@producer.res.v("titlepagetitle")}" href="titlepage.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["titlepage"].nil?
|
176
|
-
s << %Q[ <reference type="toc" title="#{@producer.res.v("toctitle")}" href="#{@producer.params["bookname"]}-toc.#{@producer.params["htmlext"]}"/>\n]
|
177
|
-
s << %Q[ <reference type="colophon" title="#{@producer.res.v("colophontitle")}" href="colophon.#{@producer.params["htmlext"]}"/>\n] unless @producer.params["colophon"].nil?
|
178
|
-
s << %Q[ </guide>\n]
|
179
|
-
s
|
180
|
-
end
|
181
|
-
|
182
165
|
def ncx(indentarray)
|
183
|
-
s = common_header
|
184
|
-
s << <<EOT
|
185
|
-
<title>#{@producer.res.v("toctitle")}</title>
|
186
|
-
</head>
|
187
|
-
<body>
|
188
|
-
<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc">
|
189
|
-
<h1 class="toc-title">#{@producer.res.v("toctitle")}</h1>
|
190
|
-
EOT
|
191
|
-
|
192
166
|
if @producer.params["epubmaker"]["flattoc"].nil?
|
193
|
-
|
167
|
+
ncx_main = hierarchy_ncx("ol")
|
194
168
|
else
|
195
|
-
|
169
|
+
ncx_main = flat_ncx("ol", @producer.params["epubmaker"]["flattocindent"])
|
196
170
|
end
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
</
|
171
|
+
|
172
|
+
@body = <<EOT
|
173
|
+
<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc">
|
174
|
+
<h1 class="toc-title">#{@producer.res.v("toctitle")}</h1>
|
175
|
+
#{ncx_main} </nav>
|
201
176
|
EOT
|
202
|
-
|
177
|
+
|
178
|
+
@title = @producer.res.v("toctitle")
|
179
|
+
@language = @producer.params['language']
|
180
|
+
@stylesheets = @producer.params["stylesheet"]
|
181
|
+
tmplfile = File.expand_path('./html/layout-html5.html.erb', ReVIEW::Template::TEMPLATE_DIR)
|
182
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
183
|
+
return tmpl.result(binding)
|
203
184
|
end
|
204
185
|
|
205
186
|
# Produce EPUB file +epubfile+.
|
@@ -237,20 +218,5 @@ EOT
|
|
237
218
|
s
|
238
219
|
end
|
239
220
|
|
240
|
-
def common_header
|
241
|
-
s =<<EOT
|
242
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
243
|
-
<!DOCTYPE html>
|
244
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="#{@producer.params["language"]}">
|
245
|
-
<head>
|
246
|
-
<meta charset="UTF-8" />
|
247
|
-
<meta name="generator" content="Re:VIEW" />
|
248
|
-
EOT
|
249
|
-
|
250
|
-
@producer.params["stylesheet"].each do |file|
|
251
|
-
s << %Q[ <link rel="stylesheet" type="text/css" href="#{file}"/>\n]
|
252
|
-
end
|
253
|
-
s
|
254
|
-
end
|
255
221
|
end
|
256
222
|
end
|