bin/review-pdfmaker in review-1.1.0 vs bin/review-pdfmaker in review-1.2.0

- old
+ new

@@ -1,9 +1,9 @@ #!/usr/bin/env ruby # encoding: utf-8 # -# Copyright (c) 2010 Kenshi Muto and Masayoshi Takahashi +# Copyright (c) 2010-2014 Kenshi Muto and Masayoshi Takahashi # # This program is free software. # You can distribute or modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # For details of the GNU LGPL, see the file "COPYING". @@ -17,10 +17,11 @@ require 'pathname' bindir = Pathname.new(__FILE__).realpath.dirname $LOAD_PATH.unshift((bindir + '../lib').realpath) require 'review' +require 'review/i18n' def error(msg) $stderr.puts "#{File.basename($0, '.*')}: error: #{msg}" exit 1 end @@ -30,11 +31,11 @@ exit 0 end def check_book(values) pdf_file = values["bookname"]+".pdf" - if File.exists? pdf_file + if File.exist? pdf_file error "file already exists:#{pdf_file}" end end def build_path(values) @@ -84,10 +85,14 @@ values["usepackage"] = "" if values["texstyle"] values["usepackage"] = "\\usepackage{#{values['texstyle']}}" end + %w[aut csl trl dsr ill cov edt].each do |item| + values[item] = [values[item]] if !values[item].nil? && values[item].instance_of?(String) + end + copy_images("./images", "#{@path}/images") copyStyToDir(Dir.pwd + "/sty", @path) copyStyToDir(Dir.pwd, @path, "tex") Dir.chdir(@path) { @@ -95,26 +100,29 @@ File.open("./book.tex", "wb"){|f| f.write(template)} ## do compile enc = values["params"].to_s.split(/\s+/).find{|i| i =~ /\A--outencoding=/ } kanji = enc ? enc.split(/=/).last.gsub(/-/, '').downcase : 'utf8' + texcommand = values["texcommand"] || "platex" fork { - exec("platex -kanji=#{kanji} book.tex") + exec("#{texcommand} -kanji=#{kanji} book.tex") } Process.waitall fork { - exec("platex -kanji=#{kanji} book.tex") + exec("#{texcommand} -kanji=#{kanji} book.tex") } Process.waitall fork { - exec("platex -kanji=#{kanji} book.tex") + exec("#{texcommand} -kanji=#{kanji} book.tex") } - Process.waitall - fork { - exec("dvipdfmx -d 5 book.dvi") - } - Process.waitall + if texcommand != "lualatex" + Process.waitall + fork { + exec("dvipdfmx -d 5 book.dvi") + } + Process.waitall + end } FileUtils.cp("#{@path}/book.pdf", "#{@basedir}/#{bookname}.pdf") end def output_chaps(filename, values) @@ -168,30 +176,43 @@ documentclass = dclass[0] || "jsbook" documentclassoption = dclass[1] || "oneside" okuduke = "" authors = "" - if values["aut"] - okuduke += "著 者 & #{values["aut"]} \\\\\n" - authors = values["aut"]+ "\\vspace*{1zh} 著" + if !values["aut"].nil? && !values["aut"].empty? + okuduke += "著 者 & #{values["aut"].join(ReVIEW::I18n.t("names_splitter"))} \\\\\n" + authors = values["aut"].join(ReVIEW::I18n.t("names_splitter")) + ReVIEW::I18n.t("author_postfix") end - if values["trl"] - authors += " \\\\\n"+values["trl"]+ "\\vspace*{1zh} 訳" - okuduke += "翻 訳 & #{values["trl"]} \\\\\n" + if !values["csl"].nil? && !values["csl"].empty? + okuduke += "監 修 & #{values["csl"].join(ReVIEW::I18n.t("names_splitter"))} \\\\\n" + authors += " \\\\\n"+values["csl"].join(ReVIEW::I18n.t("names_splitter")) + ReVIEW::I18n.t("supervisor_postfix") end - if values["edt"] - okuduke += "編集者 & #{values["edt"]} \\\\\n" + if !values["trl"].nil? && !values["trl"].empty? + okuduke += "翻 訳 & #{values["trl"].join(ReVIEW::I18n.t("names_splitter"))} \\\\\n" + authors += " \\\\\n"+values["trl"].join(ReVIEW::I18n.t("names_splitter")) + ReVIEW::I18n.t("translator_postfix") end + if !values["dsr"].nil? && !values["dsr"].empty? + okuduke += "デザイン & #{values["dsr"].join(ReVIEW::I18n.t("names_splitter"))} \\\\\n" + end + if !values["ill"].nil? && !values["ill"].empty? + okuduke += "イラスト & #{values["ill"].join(ReVIEW::I18n.t("names_splitter"))} \\\\\n" + end + if !values["cov"].nil? && !values["cov"].empty? + okuduke += "表 紙 & #{values["cov"].join(ReVIEW::I18n.t("names_splitter"))} \\\\\n" + end + if !values["edt"].nil? && !values["edt"].empty? + okuduke += "編集者 & #{values["edt"].join(ReVIEW::I18n.t("names_splitter"))} \\\\\n" + end okuduke += <<EOB 発行所 & #{values["prt"]} \\\\ EOB custom_titlepage = make_custom_titlepage(values["coverfile"]) template = File.expand_path(File.dirname(__FILE__) + '/../lib/review/review.tex.erb') layout_file = File.join(@basedir, "layouts", "layout.tex.erb") - if File.exists?(layout_file) + if File.exist?(layout_file) template = layout_file end erb = ERB.new(File.open(template).read) erb.result(binding)