Skip to content

Commit

Permalink
EPUBMaker: support to load static files from subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Jul 30, 2024
1 parent 2f993b3 commit 176be96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/review/epubmaker.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2023 Kenshi Muto and Masayoshi Takahashi
# Copyright (c) 2010-2024 Kenshi Muto and Masayoshi Takahashi
#
# This program is free software.
# You can distribute or modify this program under the terms of
Expand Down Expand Up @@ -523,7 +523,7 @@ def copy_stylesheet(basetmpdir)
end

def copy_static_file(configname, destdir, destfilename: nil)
destfilename ||= @config[configname]
destfilename ||= File.basename(@config[configname])
unless File.exist?(@config[configname])
error! "#{configname}: #{@config[configname]} is not found."
end
Expand Down
22 changes: 11 additions & 11 deletions lib/review/epubmaker/epubcommon.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# = epubcommon.rb -- super class for EPUBv2 and EPUBv3
#
# Copyright (c) 2010-2023 Kenshi Muto and Masayoshi Takahashi
# Copyright (c) 2010-2024 Kenshi Muto and Masayoshi Takahashi
#
# This program is free software.
# You can distribute or modify this program under the terms of
Expand Down Expand Up @@ -320,19 +320,19 @@ def flat_ncx(type, indent = nil)
end

def produce_write_common(basedir, tmpdir)
File.write("#{tmpdir}/mimetype", mimetype)
File.write(File.join(tmpdir, 'mimetype'), mimetype)

FileUtils.mkdir_p("#{tmpdir}/META-INF")
File.write("#{tmpdir}/META-INF/container.xml", container)
FileUtils.mkdir_p(File.join(tmpdir, 'META-INF'))
File.write(File.join(tmpdir, 'META-INF', 'container.xml'), container)

FileUtils.mkdir_p("#{tmpdir}/OEBPS")
FileUtils.mkdir_p(File.join(tmpdir, 'OEBPS'))
File.write(File.join(tmpdir, opf_path), opf)

if config['cover']
if File.exist?("#{basedir}/#{config['cover']}")
FileUtils.cp("#{basedir}/#{config['cover']}", "#{tmpdir}/OEBPS")
if File.exist?(File.join(basedir, File.basename(config['cover'])))
FileUtils.cp(File.join(basedir, File.basename(config['cover'])), File.join(tmpdir, 'OEBPS'))
else
File.write("#{tmpdir}/OEBPS/#{config['cover']}", cover)
File.write(File.join(tmpdir, 'OEBPS', File.basename(config['cover'])), cover)
end
end

Expand All @@ -344,13 +344,13 @@ def produce_write_common(basedir, tmpdir)
contents.each do |item|
next if /#/.match?(item.file) # skip subgroup

fname = "#{basedir}/#{item.file}"
fname = File.join(basedir, item.file)
unless File.exist?(fname)
raise ApplicationError, "#{fname} is not found."
end

FileUtils.mkdir_p(File.dirname("#{tmpdir}/OEBPS/#{item.file}"))
FileUtils.cp(fname, "#{tmpdir}/OEBPS/#{item.file}")
FileUtils.mkdir_p(File.dirname(File.join(tmpdir, 'OEBPS', item.file)))
FileUtils.cp(fname, File.join(tmpdir, 'OEBPS', item.file))
end
end

Expand Down

0 comments on commit 176be96

Please sign in to comment.