diff --git a/lib/review/epubmaker.rb b/lib/review/epubmaker.rb
index 9010420ac..666181708 100644
--- a/lib/review/epubmaker.rb
+++ b/lib/review/epubmaker.rb
@@ -315,22 +315,25 @@ def build_part(part, basetmpdir, htmlfile)
File.open(File.join(basetmpdir, htmlfile), 'w') do |f|
@part_number = part.number
@part_title = part.name.strip
- @body = ReVIEW::Template.generate(path: 'html/_part_body.html.erb', binding: binding)
-
+ @body = ReVIEW::Template.generate(path: template_name(localfile: '_part_body.html.erb', systemfile: 'html/_part_body.html.erb'), binding: binding)
@language = @producer.config['language']
@stylesheets = @producer.config['stylesheet']
f.write ReVIEW::Template.generate(path: template_name, binding: binding)
end
end
- def template_name
+ def template_name(localfile: 'layout.html.erb', systemfile: nil)
if @basedir
- layoutfile = File.join(@basedir, 'layouts', 'layout.html.erb')
+ layoutfile = File.join(@basedir, 'layouts', localfile)
if File.exist?(layoutfile)
return layoutfile
end
end
+ if systemfile
+ return systemfile
+ end
+
if @producer.config['htmlversion'].to_i == 5
'./html/layout-html5.html.erb'
else
@@ -552,25 +555,12 @@ def copy_frontmatter(basetmpdir)
end
def build_titlepage(basetmpdir, htmlfile)
- # TODO: should be created via epubcommon
@title = h(@config.name_of('booktitle'))
File.open(File.join(basetmpdir, htmlfile), 'w') do |f|
- @body = ''
- @body << %Q(
\n)
- @body << %Q(
#{h(@config.name_of('booktitle'))}
\n)
- if @config['subtitle']
- @body << %Q(#{h(@config.name_of('subtitle'))}
\n)
- end
- if @config['aut']
- @body << %Q(#{h(@config.names_of('aut').join(ReVIEW::I18n.t('names_splitter')))}
\n)
- end
- if @config['pbl']
- @body << %Q(#{h(@config.names_of('pbl').join(ReVIEW::I18n.t('names_splitter')))}
\n)
- end
- @body << ''
-
+ @body = ReVIEW::Template.generate(path: template_name(localfile: '_titlepage.html.erb', systemfile: 'html/_titlepage.html.erb'), binding: binding)
@language = @producer.config['language']
@stylesheets = @producer.config['stylesheet']
+
f.write ReVIEW::Template.generate(path: template_name, binding: binding)
end
end
diff --git a/lib/review/epubmaker/epubcommon.rb b/lib/review/epubmaker/epubcommon.rb
index 7c98f9bc1..1940b3bfe 100644
--- a/lib/review/epubmaker/epubcommon.rb
+++ b/lib/review/epubmaker/epubcommon.rb
@@ -101,14 +101,18 @@ def coverimage
end
end
- def template_name
+ def template_name(localfile: 'layout.html.erb', systemfile: nil)
if @workdir
- layoutfile = File.join(@workdir, 'layouts', 'layout.html.erb')
+ layoutfile = File.join(@workdir, 'layouts', localfile)
if File.exist?(layoutfile)
return layoutfile
end
end
+ if systemfile
+ return systemfile
+ end
+
if config['htmlversion'].to_i == 5
'./html/layout-html5.html.erb'
else
@@ -126,7 +130,7 @@ def cover
@coverimage_src = coverimage
raise ApplicationError, "coverimage #{config['coverimage']} not found. Abort." unless @coverimage_src
end
- @body = ReVIEW::Template.generate(path: './html/_cover.html.erb', binding: binding)
+ @body = ReVIEW::Template.generate(path: template_name(localfile: '_cover.html.erb', systemfile: 'html/_cover.html.erb'), binding: binding)
@title = h(config.name_of('title'))
@language = config['language']
@@ -152,7 +156,7 @@ def titlepage
if config.names_of('pbl')
@publisher_str = join_with_separator(config.names_of('pbl'), ReVIEW::I18n.t('names_splitter'))
end
- @body = ReVIEW::Template.generate(path: './html/_titlepage.html.erb', binding: binding)
+ @body = ReVIEW::Template.generate(path: template_name(localfile: '_titlepage.html.erb', systemfile: './html/_titlepage.html.erb'), binding: binding)
@language = config['language']
@stylesheets = config['stylesheet']
@@ -164,7 +168,7 @@ def colophon
@title = h(ReVIEW::I18n.t('colophontitle'))
@isbn_hyphen = isbn_hyphen
- @body = ReVIEW::Template.generate(path: './html/_colophon.html.erb', binding: binding)
+ @body = ReVIEW::Template.generate(path: template_name(localfile: '_colophon.html.erb', systemfile: './html/_colophon.html.erb'), binding: binding)
@language = config['language']
@stylesheets = config['stylesheet']
@@ -203,7 +207,7 @@ def colophon_history
end
end
- ReVIEW::Template.generate(path: './html/_colophon_history.html.erb', binding: binding)
+ ReVIEW::Template.generate(path: template_name(localfile: '_colophon_history.html.erb', systemfile: './html/_colophon_history.html.erb'), binding: binding)
end
def date_to_s(date)
diff --git a/lib/review/webmaker.rb b/lib/review/webmaker.rb
index 08aa1b8d5..02f24a796 100644
--- a/lib/review/webmaker.rb
+++ b/lib/review/webmaker.rb
@@ -146,26 +146,27 @@ def build_body(basetmpdir, _yamlfile)
def build_part(part, basetmpdir, htmlfile)
@title = h("#{ReVIEW::I18n.t('part', part.number)} #{part.name.strip}")
File.open("#{basetmpdir}/#{htmlfile}", 'w') do |f|
- @body = ''
- @body << %Q(\n)
- @body << %Q(
#{ReVIEW::I18n.t('part', part.number)}
\n)
- @body << %Q(#{part.name.strip}
\n) if part.name.strip.present?
- @body << "\n"
-
+ @part_number = part.number
+ @part_title = part.name.strip
+ @body = ReVIEW::Template.generate(path: template_name(localfile: '_part_body.html.erb', systemfile: 'html/_part_body.html.erb'), binding: binding)
@language = @config['language']
@stylesheets = @config['stylesheet']
f.write ReVIEW::Template.generate(path: template_name, binding: binding)
end
end
- def template_name
+ def template_name(localfile: 'layout-web.html.erb', systemfile: nil)
if @basedir
- layoutfile = File.join(@basedir, 'layouts', 'layout-web.html.erb')
+ layoutfile = File.join(@basedir, 'layouts', localfile)
if File.exist?(layoutfile)
return layoutfile
end
end
+ if systemfile
+ return systemfile
+ end
+
if @config['htmlversion'].to_i == 5
'web/html/layout-html5.html.erb'
else
@@ -281,18 +282,8 @@ def build_indexpage(basetmpdir)
def build_titlepage(basetmpdir, htmlfile)
@title = h('titlepage')
- File.open("#{basetmpdir}/#{htmlfile}", 'w') do |f|
- @body = ''
- @body << %Q()
- @body << %Q(
#{h(@config.name_of('booktitle'))}
)
- if @config['aut']
- @body << %Q(#{join_with_separator(@config.names_of('aut'), ReVIEW::I18n.t('names_splitter'))}
)
- end
- if @config['pbl']
- @body << %Q(#{join_with_separator(@config.names_of('pbl'), ReVIEW::I18n.t('names_splitter'))}
)
- end
- @body << ''
-
+ File.open(File.join(basetmpdir, htmlfile), 'w') do |f|
+ @body = ReVIEW::Template.generate(path: template_name(localfile: '_titlepage.html.erb', systemfile: 'html/_titlepage.html.erb'), binding: binding)
@language = @config['language']
@stylesheets = @config['stylesheet']
f.write ReVIEW::Template.generate(path: template_name, binding: binding)
diff --git a/templates/html/_titlepage.html.erb b/templates/html/_titlepage.html.erb
index 45e508578..8c28915e6 100644
--- a/templates/html/_titlepage.html.erb
+++ b/templates/html/_titlepage.html.erb
@@ -1,20 +1,12 @@
- <%= @title_str %>
-<% if @subtitle_str %>
- <%= h(@subtitle_str) %>
+
+
<%= h(@config.name_of('booktitle')) %>
+<% if @config['subtitle'] %>
+
<%= h(@config.name_of('subtitle')) %>
<% end %>
-<% if @author_str %>
-
-
-
-
-
<%= h(@author_str) %>
+<% if @config['aut'] %>
+
<%= h(@config.names_of('aut').join(ReVIEW::I18n.t('names_splitter'))) %>
<% end %>
-<% if @publisher_str %>
-
-
-
-
-
-
-
<%= h(@publisher_str) %>
+<% if @config['pbl'] %>
+
<%= h(@config.names_of('pbl').join(ReVIEW::I18n.t('names_splitter'))) %>
<% end %>
+
diff --git a/test/test_epubmaker.rb b/test/test_epubmaker.rb
index cee77f001..0380fbb05 100644
--- a/test/test_epubmaker.rb
+++ b/test/test_epubmaker.rb
@@ -6,6 +6,7 @@ def setup
config = ReVIEW::Configure.values
config.merge!(
'bookname' => 'sample',
+ 'booktitle' => 'Sample Book',
'title' => 'Sample Book',
'epubversion' => 2,
'urnid' => 'http://example.jp/',
@@ -806,19 +807,11 @@ def test_title
Sample Book
- Sample Book
-
-
-
-
- Mr.Smith
-
-
-
-
-
-
- BLUEPRINT
+
+
Sample Book
+Mr.Smith
+BLUEPRINT
+