review 1.2.0 → 1.3.0

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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +36 -0
  3. data/.rubocop.yml +1 -0
  4. data/ChangeLog +102 -0
  5. data/README.rdoc +2 -2
  6. data/bin/review-check +18 -16
  7. data/bin/review-compile +49 -42
  8. data/bin/review-epubmaker +23 -993
  9. data/bin/review-epubmaker-legacy +1024 -0
  10. data/bin/review-index +17 -15
  11. data/bin/review-init +39 -9
  12. data/bin/review-pdfmaker +124 -89
  13. data/bin/review-preproc +16 -14
  14. data/bin/review-vol +17 -15
  15. data/debian/docs +1 -1
  16. data/doc/catalog.rdoc +34 -0
  17. data/doc/format.rdoc +16 -2
  18. data/doc/libepubmaker/{config.yaml → config.yml} +63 -19
  19. data/doc/quickstart.rdoc +1 -1
  20. data/doc/{sample.yaml → sample.yml} +0 -0
  21. data/lib/epubmaker.rb +1 -1
  22. data/lib/epubmaker/content.rb +9 -1
  23. data/lib/epubmaker/epubv2.rb +59 -7
  24. data/lib/epubmaker/epubv3.rb +14 -9
  25. data/lib/epubmaker/producer.rb +68 -27
  26. data/lib/epubmaker/resource.rb +3 -1
  27. data/lib/lineinput.rb +2 -2
  28. data/lib/review/book/base.rb +125 -24
  29. data/lib/review/book/chapter.rb +42 -0
  30. data/lib/review/book/compilable.rb +23 -4
  31. data/lib/review/book/image_finder.rb +64 -0
  32. data/lib/review/book/index.rb +64 -50
  33. data/lib/review/book/page_metric.rb +1 -1
  34. data/lib/review/builder.rb +19 -12
  35. data/lib/review/catalog.rb +47 -0
  36. data/lib/review/compiler.rb +3 -2
  37. data/lib/review/configure.rb +5 -3
  38. data/lib/review/epubmaker.rb +130 -46
  39. data/lib/review/ewbbuilder.rb +27 -31
  40. data/lib/review/extentions/string.rb +4 -4
  41. data/lib/review/htmlbuilder.rb +140 -79
  42. data/lib/review/htmllayout.rb +26 -4
  43. data/lib/review/htmlutils.rb +20 -1
  44. data/lib/review/i18n.rb +5 -2
  45. data/lib/review/{i18n.yaml → i18n.yml} +4 -2
  46. data/lib/review/idgxmlbuilder.rb +65 -39
  47. data/lib/review/latexbuilder.rb +72 -24
  48. data/lib/review/latexutils.rb +3 -1
  49. data/lib/review/makerhelper.rb +8 -2
  50. data/lib/review/preprocessor.rb +20 -20
  51. data/lib/review/review.tex.erb +4 -0
  52. data/lib/review/sec_counter.rb +9 -11
  53. data/lib/review/tocparser.rb +2 -2
  54. data/lib/review/tocprinter.rb +12 -12
  55. data/lib/review/topbuilder.rb +15 -15
  56. data/lib/review/version.rb +1 -1
  57. data/lib/uuid.rb +7 -7
  58. data/review.gemspec +2 -2
  59. data/rubocop-todo.yml +443 -0
  60. data/test/sample-book/src/config.yml +2 -2
  61. data/test/sample-book/src/{main.css → style.css} +0 -0
  62. data/test/test_book.rb +46 -48
  63. data/test/test_book_chapter.rb +25 -13
  64. data/test/test_builder.rb +3 -3
  65. data/test/test_catalog.rb +107 -0
  66. data/test/test_epubmaker.rb +6 -6
  67. data/test/test_htmlbuilder.rb +160 -39
  68. data/test/test_htmlutils.rb +22 -0
  69. data/test/test_i18n.rb +2 -2
  70. data/test/test_idgxmlbuilder.rb +33 -47
  71. data/test/test_image_finder.rb +82 -0
  72. data/test/test_inaobuilder.rb +1 -1
  73. data/test/test_latexbuilder.rb +35 -39
  74. data/test/test_lineinput.rb +2 -2
  75. data/test/test_markdownbuilder.rb +2 -2
  76. data/test/test_topbuilder.rb +39 -23
  77. metadata +23 -14
  78. data/bin/review-epubmaker-ng +0 -23
@@ -0,0 +1,47 @@
1
+ require 'yaml'
2
+
3
+ module ReVIEW
4
+ class Catalog
5
+ def initialize(file)
6
+ @yaml = YAML.load(file.read)
7
+ @yaml ||= {}
8
+ end
9
+
10
+ def predef
11
+ return "" unless @yaml["PREDEF"]
12
+ @yaml["PREDEF"].join("\n")
13
+ end
14
+
15
+ def chaps
16
+ return "" unless @yaml["CHAPS"]
17
+
18
+ @yaml["CHAPS"].map {|entry|
19
+ if entry.is_a? String
20
+ entry
21
+ elsif entry.is_a? Hash
22
+ entry.values # chaps in a part
23
+ end
24
+ }.flatten.join("\n")
25
+ end
26
+
27
+ def parts
28
+ return "" unless @yaml["CHAPS"]
29
+
30
+ @yaml["CHAPS"].map {|entry|
31
+ if entry.is_a? Hash
32
+ entry.keys
33
+ end
34
+ }.flatten.reject{|entry| entry.nil?}.join("\n")
35
+ end
36
+
37
+ def parts_with_chaps
38
+ return "" unless @yaml["CHAPS"]
39
+ @yaml["CHAPS"].flatten.reject{|entry| entry.nil?}
40
+ end
41
+
42
+ def postdef
43
+ return "" unless @yaml["POSTDEF"]
44
+ @yaml["POSTDEF"].join("\n")
45
+ end
46
+ end
47
+ end
@@ -35,7 +35,7 @@ module ReVIEW
35
35
  end
36
36
  end
37
37
 
38
- alias to_s string
38
+ alias_method :to_s, :string
39
39
  end
40
40
 
41
41
 
@@ -187,6 +187,7 @@ module ReVIEW
187
187
  definline :hd
188
188
  definline :href
189
189
  definline :recipe
190
+ definline :column
190
191
 
191
192
  definline :abbr
192
193
  definline :acronym
@@ -293,7 +294,7 @@ module ReVIEW
293
294
  @headline_indexs[index] = 0 if @headline_indexs[index].nil?
294
295
  @headline_indexs[index] += 1
295
296
  close_current_tagged_section(level)
296
- if ReVIEW.book.param["hdnumberingmode"]
297
+ if ReVIEW.book.config["hdnumberingmode"]
297
298
  caption = @chapter.on_CHAPS? ? "#{@headline_indexs.join('.')} #{caption}" : caption
298
299
  warn "--hdnumberingmode is deprecated. use --level option."
299
300
  end
@@ -1,8 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module ReVIEW
3
- class Configure
3
+ class Configure < Hash
4
4
  def self.values
5
- { # These parameters can be overridden by YAML file.
5
+ Configure[
6
+ # These parameters can be overridden by YAML file.
6
7
  "bookname"=> "example", # it defines epub file name also
7
8
  "booktitle" => "Re:VIEW EPUBサンプル",
8
9
  "title" => nil,
@@ -32,7 +33,8 @@ module ReVIEW
32
33
  "toc" => true, # Use table of contents
33
34
  "colophon" => nil, # Use colophon
34
35
  "debug" => nil, # debug flag
35
- }
36
+ "catalogfile" => 'catalog.yml',
37
+ ]
36
38
  end
37
39
  end
38
40
  end
@@ -20,6 +20,7 @@ module ReVIEW
20
20
  def initialize
21
21
  @epub = nil
22
22
  @tochtmltxt = "toc-html.txt"
23
+ @buildlogtxt = "build-log.txt"
23
24
  end
24
25
 
25
26
  def log(s)
@@ -36,11 +37,13 @@ module ReVIEW
36
37
  def produce(yamlfile, bookname=nil)
37
38
  load_yaml(yamlfile)
38
39
  bookname = @params["bookname"] if bookname.nil?
40
+ booktmpname = "#{bookname}-epub"
41
+
39
42
  log("Loaded yaml file (#{yamlfile}). I will produce #{bookname}.epub.")
40
43
 
41
44
  File.unlink("#{bookname}.epub") if File.exist?("#{bookname}.epub")
42
- FileUtils.rm_rf(bookname) if @params["debug"] && File.exist?(bookname)
43
-
45
+ FileUtils.rm_rf(booktmpname) if @params["debug"] && File.exist?(booktmpname)
46
+
44
47
  Dir.mktmpdir(bookname, Dir.pwd) do |basetmpdir|
45
48
  log("Created first temporary directory as #{basetmpdir}.")
46
49
 
@@ -63,18 +66,25 @@ module ReVIEW
63
66
 
64
67
  push_contents(basetmpdir)
65
68
 
66
- copy_images(@params["imagedir"], "#{basetmpdir}/images")
67
- copy_images("covers", "#{basetmpdir}/images")
68
- copy_images("adv", "#{basetmpdir}/images")
69
- copy_images(@params["fontdir"], "#{basetmpdir}/fonts", @params["font_ext"])
69
+ if !@params["verify_target_images"].nil?
70
+ verify_target_images(basetmpdir)
71
+ copy_images(@params["imagedir"], basetmpdir)
72
+ else
73
+ copy_images(@params["imagedir"], "#{basetmpdir}/images")
74
+ end
75
+
76
+ copy_resources("covers", "#{basetmpdir}/images")
77
+ copy_resources("adv", "#{basetmpdir}/images")
78
+ copy_resources(@params["fontdir"], "#{basetmpdir}/fonts", @params["font_ext"])
79
+
70
80
  log("Call hook_aftercopyimage. (#{@params["hook_aftercopyimage"]})")
71
81
  call_hook(@params["hook_aftercopyimage"], basetmpdir)
72
82
 
73
83
  @epub.import_imageinfo("#{basetmpdir}/images", basetmpdir)
74
84
  @epub.import_imageinfo("#{basetmpdir}/fonts", basetmpdir, @params["font_ext"])
75
85
 
76
- epubtmpdir = @params["debug"].nil? ? nil : "#{Dir.pwd}/#{bookname}"
77
- Dir.mkdir(bookname) unless @params["debug"].nil?
86
+ epubtmpdir = @params["debug"].nil? ? nil : "#{Dir.pwd}/#{booktmpname}"
87
+ Dir.mkdir(booktmpname) unless @params["debug"].nil?
78
88
  log("Call ePUB producer.")
79
89
  @epub.produce("#{bookname}.epub", basetmpdir, epubtmpdir)
80
90
  log("Finished.")
@@ -84,28 +94,77 @@ module ReVIEW
84
94
 
85
95
  def call_hook(filename, *params)
86
96
  if !filename.nil? && File.exist?(filename) && FileTest.executable?(filename)
87
- system(filename, *params)
97
+ if ENV["REVIEW_SAFE_MODE"].to_i & 1 > 0
98
+ warn "hook is prohibited in safe mode. ignored."
99
+ else
100
+ system(filename, *params)
101
+ end
102
+ end
103
+ end
104
+
105
+ def verify_target_images(basetmpdir)
106
+ @epub.contents.each do |content|
107
+ if content.media == "application/xhtml+xml"
108
+
109
+ File.open("#{basetmpdir}/#{content.file}") do |f|
110
+ Document.new(File.new(f)).each_element("//img") do |e|
111
+ @params["force_include_images"].push(e.attributes["src"])
112
+ if e.attributes["src"] =~ /svg\Z/i
113
+ content.properties.push("svg")
114
+ end
115
+ end
116
+ end
117
+ elsif content.media == "text/css"
118
+ File.open("#{basetmpdir}/#{content.file}") do |f|
119
+ f.each_line do |l|
120
+ l.scan(/url\((.+?)\)/) do |m|
121
+ @params["force_include_images"].push($1.strip)
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ @params["force_include_images"] = @params["force_include_images"].sort.uniq
128
+ end
129
+
130
+ def copy_images(resdir, destdir, allow_exts=nil)
131
+ return nil unless File.exist?(resdir)
132
+ allow_exts = @params["image_ext"] if allow_exts.nil?
133
+ FileUtils.mkdir_p(destdir) unless FileTest.directory?(destdir)
134
+ if !@params["verify_target_images"].nil?
135
+ @params["force_include_images"].each do |file|
136
+ unless File.exist?(file)
137
+ warn "#{file} is not found, skip." if file !~ /\Ahttp[s]?:/
138
+ next
139
+ end
140
+ basedir = File.dirname(file)
141
+ FileUtils.mkdir_p("#{destdir}/#{basedir}") unless FileTest.directory?("#{destdir}/#{basedir}")
142
+ log("Copy #{file} to the temporary directory.")
143
+ FileUtils.cp(file, "#{destdir}/#{basedir}")
144
+ end
145
+ else
146
+ recursive_copy_files(resdir, destdir, allow_exts)
88
147
  end
89
148
  end
90
149
 
91
- def copy_images(imagedir, destdir, allow_exts=nil)
92
- return nil unless File.exist?(imagedir)
150
+ def copy_resources(resdir, destdir, allow_exts=nil)
151
+ return nil unless File.exist?(resdir)
93
152
  allow_exts = @params["image_ext"] if allow_exts.nil?
94
153
  FileUtils.mkdir_p(destdir) unless FileTest.directory?(destdir)
95
- recursive_copy_images(imagedir, destdir, allow_exts)
154
+ recursive_copy_files(resdir, destdir, allow_exts)
96
155
  end
97
156
 
98
- def recursive_copy_images(imagedir, destdir, allow_exts)
99
- Dir.open(imagedir) do |dir|
157
+ def recursive_copy_files(resdir, destdir, allow_exts)
158
+ Dir.open(resdir) do |dir|
100
159
  dir.each do |fname|
101
160
  next if fname =~ /\A\./
102
- if FileTest.directory?("#{imagedir}/#{fname}")
103
- recursive_copy_images("#{imagedir}/#{fname}", "#{destdir}/#{fname}", allow_exts)
161
+ if FileTest.directory?("#{resdir}/#{fname}")
162
+ recursive_copy_files("#{resdir}/#{fname}", "#{destdir}/#{fname}", allow_exts)
104
163
  else
105
164
  if fname =~ /\.(#{allow_exts.join("|")})\Z/i
106
165
  Dir.mkdir(destdir) unless File.exist?(destdir)
107
- log("Copy #{imagedir}/#{fname} to the temporary directory.")
108
- FileUtils.cp("#{imagedir}/#{fname}", destdir)
166
+ log("Copy #{resdir}/#{fname} to the temporary directory.")
167
+ FileUtils.cp("#{resdir}/#{fname}", destdir)
109
168
  end
110
169
  end
111
170
  end
@@ -134,14 +193,15 @@ module ReVIEW
134
193
  build_part(part, basetmpdir, htmlfile)
135
194
  title = ReVIEW::I18n.t("part", part.number)
136
195
  title += ReVIEW::I18n.t("chapter_postfix") + part.name.strip if part.name.strip.present?
137
- write_tochtmltxt(basetmpdir, "0\t#{htmlfile}\t#{title}")
196
+ write_tochtmltxt(basetmpdir, "0\t#{htmlfile}\t#{title}\tchaptype=part")
197
+ write_buildlogtxt(basetmpdir, htmlfile, "")
138
198
  end
139
199
  end
140
200
 
141
201
  part.chapters.each do |chap|
142
202
  build_chap(chap, base_path, basetmpdir, yamlfile, nil)
143
203
  end
144
-
204
+
145
205
  end
146
206
  end
147
207
 
@@ -158,7 +218,7 @@ EOT
158
218
  <h2 class="part-title">#{part.name.strip}</h2>
159
219
  EOT
160
220
  end
161
-
221
+
162
222
  f.puts <<EOT
163
223
  </div>
164
224
  EOT
@@ -168,6 +228,12 @@ EOT
168
228
 
169
229
  def build_chap(chap, base_path, basetmpdir, yamlfile, ispart=nil)
170
230
  filename = ""
231
+
232
+ chaptype = "body"
233
+ chaptype = "part" unless ispart.nil?
234
+ chaptype = "pre" if chap.on_PREDEF?
235
+ chaptype = "post" if chap.on_POSTDEF?
236
+
171
237
  if !ispart.nil?
172
238
  filename = chap.path
173
239
  else
@@ -189,28 +255,32 @@ EOT
189
255
  end
190
256
 
191
257
  htmlfile = "#{id}.#{@params["htmlext"]}"
258
+ write_buildlogtxt(basetmpdir, htmlfile, filename)
192
259
  log("Create #{htmlfile} from #{filename}.")
193
260
 
194
261
  level = @params["secnolevel"]
195
-
196
- if !ispart.nil?
197
- level = @params["part_secnolevel"]
198
- else
199
- level = @params["pre_secnolevel"] if chap.on_PREDEF?
200
- level = @params["post_secnolevel"] if chap.on_POSTDEF?
201
- end
262
+
263
+ # TODO: It would be nice if we can modify level in PART, PREDEF, or POSTDEF.
264
+ # But we have to care about section number reference (@<hd>) also.
265
+ #
266
+ # if !ispart.nil?
267
+ # level = @params["part_secnolevel"]
268
+ # else
269
+ # level = @params["pre_secnolevel"] if chap.on_PREDEF?
270
+ # level = @params["post_secnolevel"] if chap.on_POSTDEF?
271
+ # end
202
272
 
203
273
  stylesheet = ""
204
274
  if @params["stylesheet"].size > 0
205
275
  stylesheet = "--stylesheet=#{@params["stylesheet"].join(",")}"
206
276
  end
207
277
 
208
- system("review-compile --yaml=#{yamlfile} --target=html --level=#{level} --htmlversion=#{@params["htmlversion"]} --epubversion=#{@params["epubversion"]} #{stylesheet} #{@params["params"]} #{filename} > \"#{basetmpdir}/#{htmlfile}\"")
278
+ system("#{ReVIEW::MakerHelper.bindir}/review-compile --yaml=#{yamlfile} --target=html --level=#{level} --htmlversion=#{@params["htmlversion"]} --epubversion=#{@params["epubversion"]} #{stylesheet} #{@params["params"]} #{filename} > \"#{basetmpdir}/#{htmlfile}\"")
209
279
 
210
- write_info_body(basetmpdir, id, htmlfile, ispart)
280
+ write_info_body(basetmpdir, id, htmlfile, ispart, chaptype)
211
281
  end
212
282
 
213
- def write_info_body(basetmpdir, id, filename, ispart=nil)
283
+ def write_info_body(basetmpdir, id, filename, ispart=nil, chaptype=nil)
214
284
  headlines = []
215
285
  # FIXME:nonumを修正する必要あり
216
286
  Document.parse_stream(File.new("#{basetmpdir}/#{filename}"), ReVIEWHeaderListener.new(headlines))
@@ -218,9 +288,9 @@ EOT
218
288
  headlines.each do |headline|
219
289
  headline["level"] = 0 if !ispart.nil? && headline["level"] == 1
220
290
  if first.nil?
221
- write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}##{headline["id"]}\t#{headline["title"]}")
291
+ write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}##{headline["id"]}\t#{headline["title"]}\tchaptype=#{chaptype}")
222
292
  else
223
- write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}\t#{headline["title"]}\tforce_include=true")
293
+ write_tochtmltxt(basetmpdir, "#{headline["level"]}\t#{filename}\t#{headline["title"]}\tforce_include=true,chaptype=#{chaptype}")
224
294
  first = nil
225
295
  end
226
296
  end
@@ -231,6 +301,7 @@ EOT
231
301
  f.each_line do |l|
232
302
  force_include = nil
233
303
  customid = nil
304
+ chaptype = nil
234
305
  level, file, title, custom = l.chomp.split("\t")
235
306
  unless custom.nil?
236
307
  # custom setting
@@ -242,6 +313,8 @@ EOT
242
313
  customid = v
243
314
  when "force_include"
244
315
  force_include = true
316
+ when "chaptype"
317
+ chaptype = v
245
318
  end
246
319
  end
247
320
  end
@@ -249,9 +322,9 @@ EOT
249
322
  log("Push #{file} to ePUB contents.")
250
323
 
251
324
  if customid.nil?
252
- @epub.contents.push(Content.new("file" => file, "level" => level.to_i, "title" => title))
325
+ @epub.contents.push(Content.new("file" => file, "level" => level.to_i, "title" => title, "chaptype" => chaptype))
253
326
  else
254
- @epub.contents.push(Content.new("id" => customid, "file" => file, "level" => level.to_i, "title" => title))
327
+ @epub.contents.push(Content.new("id" => customid, "file" => file, "level" => level.to_i, "title" => title, "chaptype" => chaptype))
255
328
  end
256
329
  end
257
330
  end
@@ -270,22 +343,22 @@ EOT
270
343
  FileUtils.cp(@params["cover"], "#{basetmpdir}/#{File.basename(@params["cover"])}") if !@params["cover"].nil? && File.exist?(@params["cover"])
271
344
 
272
345
  if @params["titlepage"]
273
- if @params["titlepagefile"].nil?
346
+ if @params["titlefile"].nil?
274
347
  build_titlepage(basetmpdir, "titlepage.#{@params["htmlext"]}")
275
348
  else
276
- FileUtils.cp(@params["titlepagefile"], "titlepage.#{@params["htmlext"]}")
349
+ FileUtils.cp(@params["titlefile"], "#{basetmpdir}/titlepage.#{@params["htmlext"]}")
277
350
  end
278
- write_tochtmltxt(basetmpdir, "1\ttitlepage.#{@params["htmlext"]}\t#{@epub.res.v("titlepagetitle")}")
351
+ write_tochtmltxt(basetmpdir, "1\ttitlepage.#{@params["htmlext"]}\t#{@epub.res.v("titlepagetitle")}\tchaptype=pre")
279
352
  end
280
353
 
281
354
  if !@params["originaltitlefile"].nil? && File.exist?(@params["originaltitlefile"])
282
355
  FileUtils.cp(@params["originaltitlefile"], "#{basetmpdir}/#{File.basename(@params["originaltitlefile"])}")
283
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["originaltitlefile"])}\t#{@epub.res.v("originaltitle")}")
356
+ write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["originaltitlefile"])}\t#{@epub.res.v("originaltitle")}\tchaptype=pre")
284
357
  end
285
358
 
286
359
  if !@params["creditfile"].nil? && File.exist?(@params["creditfile"])
287
360
  FileUtils.cp(@params["creditfile"], "#{basetmpdir}/#{File.basename(@params["creditfile"])}")
288
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["creditfile"])}\t#{@epub.res.v("credittitle")}")
361
+ write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["creditfile"])}\t#{@epub.res.v("credittitle")}\tchaptype=pre")
289
362
  end
290
363
  end
291
364
 
@@ -318,12 +391,12 @@ EOT
318
391
  def copy_backmatter(basetmpdir)
319
392
  if @params["profile"]
320
393
  FileUtils.cp(@params["profile"], "#{basetmpdir}/#{File.basename(@params["profile"])}")
321
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["profile"])}\t#{@epub.res.v("profiletitle")}")
394
+ write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["profile"])}\t#{@epub.res.v("profiletitle")}\tchaptype=post")
322
395
  end
323
396
 
324
397
  if @params["advfile"]
325
398
  FileUtils.cp(@params["advfile"], "#{basetmpdir}/#{File.basename(@params["advfile"])}")
326
- write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["advfile"])}\t#{@epub.res.v("advtitle")}")
399
+ write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["advfile"])}\t#{@epub.res.v("advtitle")}\tchaptype=post")
327
400
  end
328
401
 
329
402
  if @params["colophon"]
@@ -332,7 +405,12 @@ EOT
332
405
  else
333
406
  File.open("#{basetmpdir}/colophon.#{@params["htmlext"]}", "w") {|f| @epub.colophon(f) }
334
407
  end
335
- write_tochtmltxt(basetmpdir, "1\tcolophon.#{@params["htmlext"]}\t#{@epub.res.v("colophontitle")}")
408
+ write_tochtmltxt(basetmpdir, "1\tcolophon.#{@params["htmlext"]}\t#{@epub.res.v("colophontitle")}\tchaptype=post")
409
+ end
410
+
411
+ if @params["backcover"]
412
+ FileUtils.cp(@params["backcover"], "#{basetmpdir}/#{File.basename(@params["backcover"])}")
413
+ write_tochtmltxt(basetmpdir, "1\t#{File.basename(@params["backcover"])}\t#{@epub.res.v("backcovertitle")}\tchaptype=post")
336
414
  end
337
415
  end
338
416
 
@@ -342,6 +420,12 @@ EOT
342
420
  end
343
421
  end
344
422
 
423
+ def write_buildlogtxt(basetmpdir, htmlfile, reviewfile)
424
+ File.open("#{basetmpdir}/#{@buildlogtxt}", "a") do |f|
425
+ f.puts "#{htmlfile},#{reviewfile}"
426
+ end
427
+ end
428
+
345
429
  def header(title)
346
430
  # titleはすでにエスケープ済みと想定
347
431
  s = <<EOT
@@ -392,7 +476,7 @@ EOT
392
476
  @content = ""
393
477
  @headlines = headlines
394
478
  end
395
-
479
+
396
480
  def tag_start(name, attrs)
397
481
  if name =~ /\Ah(\d+)/
398
482
  unless @level.nil?
@@ -408,7 +492,7 @@ EOT
408
492
  end
409
493
  end
410
494
  end
411
-
495
+
412
496
  def tag_end(name)
413
497
  if name =~ /\Ah\d+/
414
498
  @headlines.push({"level" => @level, "id" => @id, "title" => @content}) unless @id.nil?
@@ -417,7 +501,7 @@ EOT
417
501
  @id = nil
418
502
  end
419
503
  end
420
-
504
+
421
505
  def text(text)
422
506
  unless @level.nil?
423
507
  @content << text.gsub("\t", " ") # FIXME:区切り文字