Skip to content

Instantly share code, notes, and snippets.

@takahashim
Created March 18, 2014 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takahashim/9615577 to your computer and use it in GitHub Desktop.
Save takahashim/9615577 to your computer and use it in GitHub Desktop.
diff --git a/bin/review-epubmaker b/bin/review-epubmaker
index 8b7a06d..99f782d 100755
--- a/bin/review-epubmaker
+++ b/bin/review-epubmaker
@@ -98,15 +98,17 @@ def main
end
if File.exist?("images")
+ allow_exts = %w(png gif jpg jpeg svg ttf woff otf)
Dir.mkdir("#{@bookdir}/OEBPS/images")
- image_files = ReVIEW::MakerHelper.copy_images_to_dir("images", "#{@bookdir}/OEBPS/images", :exts=>%w(png gif jpg jpeg svg))
+ image_files = ReVIEW::MakerHelper.copy_images_to_dir("images", "#{@bookdir}/OEBPS/images", :exts=>allow_exts)
image_files.each do |image_file|
dirname = File.dirname(image_file)
fname = File.basename(image_file)
figid = getFigId(dirname.gsub(%r|/|,'-')+"-"+fname)
mime = nil
- next unless fname =~ /\.(png|gif|jpg|jpeg|svg)$/i
- case fname.downcase.match(/\.(png|gif|jpg|jpeg|svg)$/)[1]
+ fname_pattern = /\.(#{allow_exts.join("|")})$/i
+ next unless fname =~ fname_pattern
+ case fname.downcase.match(fname_pattern)[1]
when "png"
mime = "image/png"
when "gif"
@@ -115,6 +117,10 @@ def main
mime = "image/jpeg"
when "svg"
mime = "image/svg+xml"
+ when "ttf", "otf"
+ mime = "application/vnd.ms-opentype"
+ when "woff"
+ mime = "application/font-woff"
else
raise "unsupported type #{fname}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment