review 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/.travis.yml +1 -2
  2. data/ChangeLog +65 -0
  3. data/Gemfile +5 -0
  4. data/README.rdoc +6 -1
  5. data/Rakefile +14 -28
  6. data/bin/review-check +9 -21
  7. data/bin/review-compile +45 -12
  8. data/bin/review-epubmaker +477 -220
  9. data/bin/review-epubmaker-ng +5 -14
  10. data/bin/review-index +4 -2
  11. data/bin/review-init +94 -0
  12. data/bin/review-pdfmaker +70 -287
  13. data/bin/review-preproc +5 -2
  14. data/bin/review-vol +4 -11
  15. data/debian/changelog +3 -3
  16. data/debian/copyright +5 -3
  17. data/debian/docs +1 -0
  18. data/doc/format.rdoc +57 -11
  19. data/doc/quickstart.rdoc +4 -4
  20. data/doc/sample.yaml +11 -7
  21. data/lib/epubmaker.rb +1 -1
  22. data/lib/epubmaker/epubv2.rb +26 -27
  23. data/lib/epubmaker/epubv3.rb +13 -13
  24. data/lib/epubmaker/producer.rb +1 -1
  25. data/lib/review.rb +3 -4
  26. data/lib/review/book.rb +17 -581
  27. data/lib/review/book/base.rb +247 -0
  28. data/lib/review/book/chapter.rb +81 -0
  29. data/lib/review/book/compilable.rb +163 -0
  30. data/lib/review/book/index.rb +339 -0
  31. data/lib/review/book/page_metric.rb +38 -0
  32. data/lib/review/book/parameters.rb +97 -0
  33. data/lib/review/book/part.rb +44 -0
  34. data/lib/review/book/volume.rb +65 -0
  35. data/lib/review/builder.rb +34 -40
  36. data/lib/review/compiler.rb +32 -13
  37. data/lib/review/configure.rb +38 -0
  38. data/lib/review/ewbbuilder.rb +23 -21
  39. data/lib/review/extentions.rb +3 -0
  40. data/lib/review/extentions/object.rb +9 -0
  41. data/lib/review/{compat.rb → extentions/string.rb} +11 -0
  42. data/lib/review/htmlbuilder.rb +162 -74
  43. data/lib/review/htmlutils.rb +28 -1
  44. data/lib/review/i18n.yaml +11 -0
  45. data/lib/review/idgxmlbuilder.rb +119 -35
  46. data/lib/review/inaobuilder.rb +355 -0
  47. data/lib/review/latexbuilder.rb +133 -59
  48. data/lib/review/latexutils.rb +15 -6
  49. data/lib/review/makerhelper.rb +59 -0
  50. data/lib/review/markdownbuilder.rb +129 -0
  51. data/lib/review/preprocessor.rb +20 -7
  52. data/lib/review/review.tex.erb +250 -0
  53. data/lib/review/textutils.rb +28 -3
  54. data/lib/review/tocparser.rb +20 -12
  55. data/lib/review/tocprinter.rb +7 -3
  56. data/lib/review/topbuilder.rb +44 -27
  57. data/lib/review/version.rb +3 -0
  58. data/review.gemspec +20 -117
  59. data/test/book_test_helper.rb +35 -0
  60. data/test/sample-book/README.md +5 -0
  61. data/test/sample-book/src/CHAPS +2 -0
  62. data/test/sample-book/src/PREDEF +1 -0
  63. data/test/sample-book/src/Rakefile +26 -0
  64. data/test/sample-book/src/_cover.html +3 -0
  65. data/test/sample-book/src/ch01.re +71 -0
  66. data/test/sample-book/src/ch02.re +3 -0
  67. data/test/sample-book/src/config.yml +55 -0
  68. data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
  69. data/test/sample-book/src/images/cover.jpg +0 -0
  70. data/test/sample-book/src/main.css +251 -0
  71. data/test/sample-book/src/preface.re +15 -0
  72. data/test/sample-book/src/sty/jumoline.sty +310 -0
  73. data/test/sample-book/src/sty/samplemacro.sty +21 -0
  74. data/test/sample-book/src/vendor/jumoline/README +29 -0
  75. data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
  76. data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
  77. data/test/test_book.rb +26 -646
  78. data/test/test_book_chapter.rb +418 -0
  79. data/test/test_book_parameter.rb +42 -0
  80. data/test/test_book_part.rb +53 -0
  81. data/test/test_builder.rb +17 -10
  82. data/test/test_compiler.rb +46 -0
  83. data/test/test_epubmaker.rb +1 -1
  84. data/test/test_epubmaker_cmd.rb +36 -0
  85. data/test/test_helper.rb +17 -0
  86. data/test/test_htmlbuilder.rb +156 -24
  87. data/test/test_htmlutils.rb +4 -0
  88. data/test/test_i18n.rb +6 -2
  89. data/test/test_idgxmlbuilder.rb +33 -11
  90. data/test/test_inaobuilder.rb +247 -0
  91. data/test/test_index.rb +31 -0
  92. data/test/test_latexbuilder.rb +115 -35
  93. data/test/test_makerhelper.rb +50 -0
  94. data/test/test_pdfmaker_cmd.rb +36 -0
  95. data/test/test_preprocessor.rb +7 -7
  96. data/test/test_topbuilder.rb +6 -7
  97. data/test/test_uuid.rb +1 -0
  98. metadata +117 -12
  99. data/lib/review/index.rb +0 -323
  100. data/lib/review/volume.rb +0 -66
@@ -12,6 +12,7 @@
12
12
  require 'pathname'
13
13
  bindir = Pathname.new(__FILE__).realpath.dirname
14
14
  $LOAD_PATH.unshift((bindir + '../lib').realpath)
15
+ require 'review'
15
16
  require 'epubmaker'
16
17
  include EPUBMaker
17
18
 
@@ -20,19 +21,9 @@ def main
20
21
  puts "Usage: #{$0} configfile"
21
22
  exit 0
22
23
  end
23
-
24
- @params = { # These parameters can be overridden by YAML file.
25
- "bookname" => "example", # Book file
26
- "title" => "example", # Book title
27
- "params" => "", # specify review2html parameters
28
- "epubversion" => 2,# EPUB version
29
- "toclevel" => 3, # level of toc
30
- "secnolevel" => 2, # level of section #
31
- "posthook" => nil, # command path of post hook
32
- "debug" => nil, # debug flag
33
- }
34
-
24
+
35
25
  yamlfile = ARGV[0]
26
+ @params = ReVIEW::Configure.values.merge(YAML.load_file(yamlfile))
36
27
  @epub = Producer.new(@params)
37
28
  @epub.load(yamlfile)
38
29
  @params = @epub.params
@@ -52,14 +43,14 @@ def main
52
43
 
53
44
  FileUtils.cp(@params["cover"], "#{basetmp}/#{@params["cover"]}") if !@params["cover"].nil? && File.exist?(@params["cover"])
54
45
 
55
- unless @params["titlepage"].nil? # FIXME
46
+ if @params["titlepage"] # FIXME
56
47
  FileUtils.cp(@params["titlepage"], "#{basetmp}/#{@params["titlepage"]}")
57
48
  @epub.contents.push(Content.new("id" => "title", "file" => @params["titlepage"], "title" => @epub.res.v("titlepagetitle")))
58
49
  end
59
50
 
60
51
  makeBody(basetmp, yamlfile)
61
52
 
62
- unless @params["colophon"].nil?
53
+ if @params["colophon"]
63
54
  if @params["colophon"].instance_of?(String)
64
55
  FileUtils.cp(@params["colophon"], "#{basetmp}/colophon.#{@params["htmlext"]}")
65
56
  else
@@ -22,7 +22,9 @@ require 'optparse'
22
22
 
23
23
  def main
24
24
  Signal.trap(:INT) { exit 1 }
25
- Signal.trap(:PIPE, 'IGNORE')
25
+ if RUBY_PLATFORM !~ /mswin(?!ce)|mingw|cygwin|bccwin/
26
+ Signal.trap(:PIPE, 'IGNORE')
27
+ end
26
28
  _main
27
29
  rescue Errno::EPIPE
28
30
  exit 0
@@ -59,7 +61,7 @@ def _main
59
61
  }
60
62
  parser.on('-c', '--chapter C', 'list only chapter C.') {|c|
61
63
  begin
62
- source = ReVIEW::Part.new(1, [ReVIEW.book.chapter(c)])
64
+ source = ReVIEW::Book::Part.new(nil, 1, [ReVIEW.book.chapter(c)])
63
65
  rescue
64
66
  error_exit "chapter #{c} does not exist in this book"
65
67
  end
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2013 Masanori Kado
4
+ #
5
+ # This program is free software.
6
+ # You can distribute or modify this program under the terms of
7
+ # the GNU LGPL, Lesser General Public License version 2.1.
8
+ # For details of the GNU LGPL, see the file "COPYING".
9
+
10
+ require 'fileutils'
11
+
12
+ def main
13
+ if ARGV.empty?
14
+ puts "Usage: #{File.basename($0)} dirname"
15
+ exit
16
+ end
17
+
18
+ dir = File.expand_path(ARGV.shift)
19
+ @review_dir = File.dirname(File.expand_path(__FILE__ + "./../"))
20
+
21
+ generate_dir(dir) do |dir|
22
+ generate_review_setting_files(dir)
23
+ generate_sample(dir)
24
+ generate_images_dir(dir)
25
+ generate_layout(dir)
26
+ generate_config(dir)
27
+ generate_rakefile(dir)
28
+ end
29
+ end
30
+
31
+ def generate_dir(dir)
32
+ if File.exist? dir
33
+ puts "#{dir} already exists."
34
+ exit
35
+ end
36
+ FileUtils.mkdir_p dir
37
+ yield dir
38
+ end
39
+
40
+ def generate_sample(dir)
41
+ File.open("#{dir}/#{File.basename(dir)}.re", "w") do |file|
42
+ file.write("= ")
43
+ end
44
+ end
45
+
46
+ def generate_layout(dir)
47
+ Dir.mkdir dir + '/layouts'
48
+ File.open("#{dir}/layouts/layout.erb", "w") do |file|
49
+ file.write <<-EOS
50
+ <?xml version="1.0" encoding="UTF-8"?>
51
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
52
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="ja">
53
+ <head>
54
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
55
+ <meta http-equiv="Content-Style-Type" content="text/css" />
56
+ <link rel="stylesheet" type="text/css" href="style.css" />
57
+ <meta name="generator" content="ReVIEW" />
58
+ <title><%= title %></title>
59
+ </head>
60
+ <body>
61
+ <%= body %>
62
+ </body>
63
+ </html>
64
+ EOS
65
+ end
66
+ end
67
+
68
+ def generate_review_setting_files(dir)
69
+ File.open(dir + "/PREDEF", "w")
70
+ File.open(dir + "/CHAPS", "w") do |file|
71
+ file.write("#{File.basename(dir)}.re")
72
+ end
73
+ File.open(dir + "/POSTDEF", "w")
74
+ end
75
+
76
+ def generate_images_dir(dir)
77
+ Dir.mkdir dir + '/images'
78
+ end
79
+
80
+ def generate_config(dir)
81
+ FileUtils.cp @review_dir + "/test/sample-book/src/config.yml", dir
82
+ end
83
+
84
+ def generate_style(dir)
85
+ File.open(dir + "/style.css", "w")
86
+ end
87
+
88
+ def generate_rakefile(dir)
89
+ FileUtils.cp @review_dir + "/test/sample-book/src/Rakefile", dir
90
+ end
91
+
92
+ if $0 == __FILE__
93
+ main()
94
+ end
@@ -12,6 +12,13 @@
12
12
  require 'tmpdir'
13
13
  require 'yaml'
14
14
  require 'fileutils'
15
+ require 'erb'
16
+
17
+ require 'pathname'
18
+ bindir = Pathname.new(__FILE__).realpath.dirname
19
+ $LOAD_PATH.unshift((bindir + '../lib').realpath)
20
+
21
+ require 'review'
15
22
 
16
23
  def error(msg)
17
24
  $stderr.puts "#{File.basename($0, '.*')}: error: #{msg}"
@@ -32,9 +39,9 @@ end
32
39
 
33
40
  def build_path(values)
34
41
  if values["debug"].nil?
35
- Dir.mktmpdir+"/#{values["bookname"]}"
42
+ Dir.mktmpdir+"/#{values["bookname"]}-pdf"
36
43
  else
37
- "./#{values["bookname"]}"
44
+ "./#{values["bookname"]}-pdf"
38
45
  end
39
46
  end
40
47
 
@@ -42,27 +49,37 @@ def main
42
49
  usage if ARGV.size != 1
43
50
 
44
51
  yamlfile = ARGV[0]
45
- values = YAML.load_file(yamlfile)
52
+ values = ReVIEW::Configure.values.merge(YAML.load_file(yamlfile))
46
53
  check_book(values)
47
- basedir = Dir.pwd
54
+ @basedir = Dir.pwd
48
55
  @path = build_path(values)
49
56
  bookname = values["bookname"]
50
57
  Dir.mkdir(@path)
51
58
 
52
- @chaps_filenames = Hash.new{|h, key| h[key] = ""}
59
+ @chaps_fnames = Hash.new{|h, key| h[key] = ""}
53
60
 
54
- if File.exists?("PREDEF")
55
- output_chaps("PREDEF", values)
56
- end
57
- if File.exists?("CHAPS")
58
- output_chaps("CHAPS", values)
59
- end
60
- if File.exists?("POSTDEF")
61
- output_chaps("POSTDEF", values)
61
+ ReVIEW::Book.load(@basedir).parts.each do |part|
62
+ if part.name.present?
63
+ if part.file?
64
+ output_parts(part.name, values)
65
+ @chaps_fnames["CHAPS"] << %Q|\\input{#{part.name}.tex}\n|
66
+ else
67
+ @chaps_fnames["CHAPS"] << %Q|\\part{#{part.name}}\n|
68
+ end
69
+ end
70
+
71
+ part.chapters.each do |chap|
72
+ filename = "#{File.basename(chap.path, ".*")}.tex"
73
+ output_chaps(filename, values)
74
+ @chaps_fnames["PREDEF"] << "\\input{#{filename}}\n" if chap.on_PREDEF?
75
+ @chaps_fnames["CHAPS"] << "\\input{#{filename}}\n" if chap.on_CHAPS?
76
+ @chaps_fnames["POSTDEF"] << "\\input{#{filename}}\n" if chap.on_POSTDEF?
77
+ end
62
78
  end
63
- values["pre_str"] = @chaps_filenames["PREDEF"]
64
- values["chap_str"] = @chaps_filenames["CHAPS"]
65
- values["post_str"] = @chaps_filenames["POSTDEF"]
79
+
80
+ values["pre_str"] = @chaps_fnames["PREDEF"]
81
+ values["chap_str"] = @chaps_fnames["CHAPS"]
82
+ values["post_str"] = @chaps_fnames["POSTDEF"]
66
83
 
67
84
  values["usepackage"] = ""
68
85
  if values["texstyle"]
@@ -76,7 +93,7 @@ def main
76
93
  Dir.chdir(@path) {
77
94
  template = get_template(values)
78
95
  File.open("./book.tex", "wb"){|f| f.write(template)}
79
-
96
+
80
97
  ## do compile
81
98
  enc = values["params"].to_s.split(/\s+/).find{|i| i =~ /\A--outencoding=/ }
82
99
  kanji = enc ? enc.split(/=/).last.gsub(/-/, '').downcase : 'utf8'
@@ -97,36 +114,39 @@ def main
97
114
  }
98
115
  Process.waitall
99
116
  }
100
- FileUtils.cp("#{@path}/book.pdf", "#{basedir}/#{bookname}.pdf")
117
+ FileUtils.cp("#{@path}/book.pdf", "#{@basedir}/#{bookname}.pdf")
101
118
  end
102
119
 
103
- def output_chaps(chapsfile, values)
104
- File.open(chapsfile) {|chaps|
105
- chaps.each_line {|l|
106
- next if l =~ /^#/
107
- file_id = File.basename(l.chomp.strip,".*")
108
- filename = "#{file_id}.tex"
109
- fork {
110
- STDOUT.reopen("#{@path}/#{filename}")
111
- $stderr.puts "compiling #{l}"
112
- exec("review-compile --target=latex --level=#{values["secnolevel"]} #{values["params"]} #{l}")
113
- }
114
- Process.waitall
115
- @chaps_filenames[chapsfile] << %Q|\\input{#{filename}}\n|
116
- }
120
+ def output_chaps(filename, values)
121
+ fork {
122
+ STDOUT.reopen("#{@path}/#{filename}")
123
+ $stderr.puts "compiling #{filename}"
124
+ exec("review-compile --target=latex --level=#{values["secnolevel"]} --toclevel=#{values["toclevel"]} #{values["params"]} #{filename}")
125
+ }
126
+ Process.waitall
127
+ end
128
+
129
+ def output_parts(filename, values)
130
+ fork {
131
+ STDOUT.reopen("#{@path}/#{filename}.tex")
132
+ $stderr.puts "compiling #{filename}.tex"
133
+ exec("review-compile --target=latex --level=#{values["secnolevel"]} --toclevel=#{values["toclevel"]} #{values["params"]} #{filename}.re | sed -e s/\\chapter{/\\part{/")
134
+
117
135
  }
136
+ Process.waitall
118
137
  end
119
138
 
139
+
120
140
  def copy_images(from, to)
121
141
  if File.exist?(from)
122
142
  Dir.mkdir(to)
123
- copyImagesToDir(from, to)
143
+ ReVIEW::MakerHelper.copy_images_to_dir(from, to)
124
144
  Dir.chdir(to) {
125
145
  fork {
126
146
  begin
127
- exec("extractbb *.png *.jpg */*.jpg */*.png;extractbb -m *.png *.jpg */*.jpg */*.png")
147
+ exec("extractbb *.png *.jpg *.pdf */*.jpg */*.png */*.pdf;extractbb -m *.png *.jpg *.pdf */*.jpg */*.png */*.pdf")
128
148
  rescue
129
- exec("ebb *.png *.jpg */*.jpg */*.png")
149
+ exec("ebb *.png *.jpg *.pdf */*.jpg */*.png */*.pdf")
130
150
  end
131
151
  }
132
152
  }
@@ -134,49 +154,13 @@ def copy_images(from, to)
134
154
  end
135
155
  end
136
156
 
137
- def make_titlepage(values, authors)
138
- coverfile = values["coverfile"]
139
- if coverfile
140
- coverfile_sty = coverfile.sub(/\.[^.]+$/, ".tex")
141
- if File.exist?(coverfile_sty)
142
- titlepage = File.read(coverfile_sty)
143
- return titlepage
144
- end
145
- end
146
-
147
- ## use default titlepage template
148
- titlepage = <<EOB
149
- \\begin{titlepage}
150
- EOB
151
- if values["coverimage"]
152
- titlepage += <<EOB
153
- \\begin{center}
154
- %%%\\mbox{}\\vskip5zw%
155
- \\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{./images/#{values["coverimage"]}}
156
- \\end{center}
157
- \\clearpage
158
- EOB
157
+ def make_custom_titlepage(coverfile)
158
+ coverfile_sty = coverfile.to_s.sub(/\.[^.]+$/, ".tex")
159
+ if File.exist?(coverfile_sty)
160
+ File.read(coverfile_sty)
161
+ else
162
+ nil
159
163
  end
160
- titlepage += <<EOB
161
- \\thispagestyle{empty}
162
- \\begin{center}%
163
- \\mbox{} \\vskip5zw
164
- \\reviewtitlefont%
165
- {\\Huge #{values["booktitle"]} \\par}%
166
- \\vskip 15em%
167
- {\\huge
168
- \\lineskip .75em
169
- \\begin{tabular}[t]{c}%
170
- #{authors}
171
- \\end{tabular}\\par}%
172
- \\vfill
173
- {\\large #{values["date"]} 版\\hspace{2zw}#{values["prt"]} 発行\\par}%
174
- \\vskip4zw\\mbox{}
175
- \\end{center}%
176
- \\end{titlepage}
177
- EOB
178
-
179
- return titlepage
180
164
  end
181
165
 
182
166
  def get_template(values)
@@ -186,7 +170,6 @@ def get_template(values)
186
170
 
187
171
  okuduke = ""
188
172
  authors = ""
189
-
190
173
  if values["aut"]
191
174
  okuduke += "著 者 & #{values["aut"]} \\\\\n"
192
175
  authors = values["aut"]+ "\\vspace*{1zh} 著"
@@ -202,216 +185,17 @@ def get_template(values)
202
185
  発行所 & #{values["prt"]} \\\\
203
186
  EOB
204
187
 
205
- titlepage = make_titlepage(values, authors)
206
-
207
- str = <<EOB
208
- \\documentclass[#{documentclassoption}]{#{documentclass}}
209
- \\usepackage[deluxe]{otf}
210
- \\usepackage[dvipdfmx]{color}
211
- \\usepackage[dvipdfmx]{graphicx}
212
- \\usepackage{framed}
213
- \\usepackage{wrapfig}
214
- \\definecolor{shadecolor}{gray}{0.9}
215
- \\definecolor{shadecolorb}{gray}{0.1}
216
-
217
- \\usepackage[utf8]{inputenc}
218
-
219
- \\usepackage{jumoline}
220
-
221
- \\usepackage{ascmac}
222
-
223
- \\usepackage{float}
224
- \\usepackage{alltt}
225
-
226
- \\newenvironment{shadedb}{%
227
- \\def\\FrameCommand{\\fboxsep=\\FrameSep \\colorbox{shadecolorb}}%
228
- \\MakeFramed {\\FrameRestore}}%
229
- {\\endMakeFramed}
230
-
231
-
232
- \\usepackage[top=10zw,bottom=12zw,left=10zw,right=10zw]{geometry}
233
- %\\usepackage[top=5zw,bottom=5zw,left=1zw,right=1zw]{geometry}
234
-
235
-
236
- \\newcommand{\\parasep}{\\vspace*{3zh}}
237
- \\setlength{\\footskip}{30pt}
238
-
239
- %% Bookmarkの文字化け対策(日本語向け)
240
- \\ifnum 46273=\\euc"B4C1 % 46273 == 0xB4C1 == 漢(EUC-JP)
241
- \\usepackage{atbegshi}%
242
- \\AtBeginShipoutFirst{\\special{pdf:tounicode EUC-UCS2}}%
243
- %%\\AtBeginDvi{\\special{pdf:tounicode EUC-UCS2}}%
244
- \\else
245
- \\usepackage{atbegshi}%
246
- \\AtBeginShipoutFirst{\\special{pdf:tounicode 90ms-RKSJ-UCS2}}%
247
- %%\\AtBeginDvi{\\special{pdf:tounicode 90ms-RKSJ-UCS2}}%
248
- \\fi
249
-
250
- \\usepackage[dvipdfm,bookmarks=true,bookmarksnumbered=true,colorlinks=true,%
251
- pdftitle={#{values["booktitle"]}},%
252
- pdfauthor={#{values["aut"]}}]{hyperref}
253
-
254
- \\newenvironment{reviewimage}{%
255
- \\begin{figure}[H]
256
- \\begin{center}}{%
257
- \\end{center}
258
- \\end{figure}}
259
-
260
- \\newenvironment{reviewdummyimage}{%
261
- \\begin{figure}[H]
262
- \\begin{center}}{%
263
- \\end{center}
264
- \\end{figure}}
265
-
266
- \\newenvironment{reviewemlist}{%
267
- \\medskip\\small\\begin{shaded}\\setlength{\\baselineskip}{1.3zw}}{%
268
- \\end{shaded}}
269
-
270
- \\newenvironment{reviewlist}{%
271
- \\begin{shaded}\\small\\setlength{\\baselineskip}{1.3zw}}{%
272
- \\end{shaded}\\par\\vspace*{0.5zw}}
273
-
274
- \\newenvironment{reviewcmd}{%
275
- \\color{white}\\medskip\\small\\begin{shadedb}\\setlength{\\baselineskip}{1.3zw}}{%
276
- \\end{shadedb}}
188
+ custom_titlepage = make_custom_titlepage(values["coverfile"])
277
189
 
278
- \\newenvironment{reviewtable}[1]{%
279
- \\begin{center}\\small\\setlength{\\baselineskip}{1.2zw}
280
- \\begin{tabular}{#1}}{%
281
- \\end{tabular}
282
- \\end{center}}
283
-
284
- \\newenvironment{reviewcolumn}{%
285
- \\begin{framed}
286
- }{%
287
- \\end{framed}
288
- \\vspace{2zw}}
289
-
290
- \\newcommand{\\reviewcolumnhead}[2]{%
291
- {\\noindent\\large ■コラム: #2}}
292
-
293
- \\newcommand{\\reviewtablecaption}[1]{%
294
- \\caption{#1}}
295
-
296
- \\newcommand{\\reviewbackslash}[0]{%
297
- \\textbackslash{}}
298
-
299
- \\newcommand{\\reviewlistcaption}[1]{%
300
- \\medskip{\\small\\noindent #1}\\vspace*{-1.3zw}}
301
-
302
- \\newcommand{\\reviewemlistcaption}[1]{%
303
- \\medskip{\\small\\noindent #1}\\vspace*{-1.3zw}}
304
-
305
- \\newcommand{\\reviewcmdcaption}[1]{%
306
- \\medskip{\\small\\noindent #1}\\vspace*{-1.3zw}}
307
-
308
- \\newcommand{\\reviewimageref}[1]{%
309
- 図 #1}
310
- \\newcommand{\\reviewtableref}[1]{%
311
- 表 #1}
312
- \\newcommand{\\reviewlistref}[1]{%
313
- リスト #1}
314
-
315
- \\newcommand{\\reviewminicolumntitle}[1]{%
316
- {\\large ■メモ:#1}\\\\}
317
-
318
- \\newenvironment{reviewminicolumn}{%
319
- \\vspace{1.5zw}\\begin{screen}}{%
320
- \\end{screen}\\vspace{2zw}}
321
-
322
- \\newcommand{\\reviewkw}[1]{%
323
- \\textbf{\\textgt{#1}}}
324
-
325
- \\newcommand{\\reviewtitlefont}[0]{%
326
- \\usefont{T1}{phv}{b}{n}\\gtfamily}
327
-
328
- \\newcommand{\\reviewmainfont}[0]{%
329
- }
330
-
331
- \\newcommand{\\reviewcolophon}[0]{%
332
- \\backmatter
333
- \\clearpage}
334
- \\newcommand{\\reviewappendix}[0]{%
335
- \\appendix}
336
-
337
- \\makeatletter
338
- \\def\\maxwidth{%
339
- \\ifdim\\Gin@nat@width>\\linewidth
340
- \\linewidth
341
- \\else
342
- \\Gin@nat@width
343
- \\fi
344
- }
345
- \\makeatother
346
-
347
- #{values["usepackage"]}
348
-
349
- \\usepackage[T1]{fontenc}
350
-
351
- \\begin{document}
352
-
353
- \\reviewmainfont
354
- EOB
355
-
356
- str += titlepage
357
- str += <<EOB
358
-
359
- \\renewcommand{\\chaptermark}[1]{{}}
360
- \\frontmatter
361
-
362
- %% preface
363
- #{values["pre_str"]}
364
-
365
- \\tableofcontents
366
-
367
- \\renewcommand{\\chaptermark}[1]{\\markboth{\\prechaptername\\thechapter\\postchaptername~#1}{}}
368
- \\mainmatter
369
-
370
- #{values["chap_str"]}
371
-
372
- \\renewcommand{\\chaptermark}[1]{\\markboth{\\appendixname\\thechapter~#1}{}}
373
- \\reviewappendix
374
-
375
- #{values["post_str"]}
376
-
377
- %% okuduke
378
- \\reviewcolophon
379
- \\thispagestyle{empty}
380
-
381
- \\vspace*{\\fill}
382
-
383
- {\\noindent\\reviewtitlefont\\Large #{values["booktitle"]}} \\\\
384
- \\rule[8pt]{14cm}{1pt} \\\\
385
- {\\noindent
386
- #{values["pubhistory"].to_s.gsub(/\n/){"\n\n\\noindent"} }
387
- }
388
-
389
- \\begin{tabular}{ll}
390
- #{okuduke}
391
- \\end{tabular}
392
-  \\\\
393
- \\rule[0pt]{14cm}{1pt} \\\\
394
- #{values["rights"]} \\\\
395
-
396
- \\end{document}
397
-
398
- EOB
399
- end
190
+ template = File.expand_path(File.dirname(__FILE__) +
191
+ '/../lib/review/review.tex.erb')
192
+ layout_file = File.join(@basedir, "layouts", "layout.tex.erb")
193
+ if File.exists?(layout_file)
194
+ template = layout_file
195
+ end
400
196
 
401
- def copyImagesToDir(dirname, copybase)
402
- Dir.open(dirname) {|dir|
403
- dir.each {|fname|
404
- next if fname =~ /^\./
405
- if FileTest.directory?("#{dirname}/#{fname}")
406
- copyImagesToDir("#{dirname}/#{fname}", "#{copybase}/#{fname}")
407
- else
408
- if fname =~ /\.(png|gif|jpg|jpeg|svg|pdf)$/i
409
- Dir.mkdir(copybase) unless File.exist?(copybase)
410
- FileUtils.cp "#{dirname}/#{fname}", copybase
411
- end
412
- end
413
- }
414
- }
197
+ erb = ERB.new(File.open(template).read)
198
+ erb.result(binding)
415
199
  end
416
200
 
417
201
  def copyStyToDir(dirname, copybase, extname = "sty")
@@ -431,5 +215,4 @@ def copyStyToDir(dirname, copybase, extname = "sty")
431
215
  }
432
216
  end
433
217
 
434
-
435
218
  main