class SiSU_XHTML_EPUB2::Source::Output
Public Class Methods
new(md,output='')
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 730 def initialize(md,output='') @md,@output=md,output @epub_doc="#{@md.fnb}.epub" @epub_header=SiSU_XHTML_EPUB2_Format::HeadInformation.new(@md) @make=SiSU_Env::ProcessingSettings.new(@md) @make_file=SiSU_Env::CreateFile.new(@md.fns) end
Public Instance Methods
concordance()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 809 def concordance SiSU_XHTML_EPUB2_Concordance::Source.new(@md.opt).read end
css()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 755 def css out=@make_file.epub.xhtml_css out << SiSU_XHTML_EPUB2_Format::CSS.new.css_epub_xhtml out.close end
epub_metadata_opf()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 775 def epub_metadata_opf begin out=@make_file.epub.metadata @output.each do |para| unless para =~/\A\s*\Z/ out.puts para end end out.close rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do __LINE__.to_s + ':' + __FILE__ end end end
epub_toc_ncx()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 760 def epub_toc_ncx begin out=@make_file.epub.toc_ncx @output.each do |para| unless para =~/\A\s*\Z/ out.puts para end end out.close rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do __LINE__.to_s + ':' + __FILE__ end end end
images()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 790 def images img_pth=@md.env.path.image_source_include img_src_pth=unless @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/ @md.file.output_path.epub.rel_image else pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1] pt + '/image' end @md.ec[:image].each do |x| if FileTest.directory?("#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") \ && FileTest.file?("#{img_src_pth}/#{x}") FileUtils::cp("#{img_src_pth}/#{x}","#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") elsif FileTest.directory?("#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") \ && FileTest.file?("#{img_pth}/#{x}") FileUtils::cp("#{img_pth}/#{x}","#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") else STDERR.puts %{\t*WARN* did not find image - "#{x}" in #{img_src_pth} or #{img_pth} [#{__FILE__}:#{__LINE__}]} end end end
make_cover_image()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 830 def make_cover_image begin if @md.make.cover_image? \ and @md.make.cover_image.is_a?(Hash) \ and @md.make.cover_image[:cover] =~/\S+/ filename_xhtml=@make_file.epub.xhtml_cover_image cover_image=<<WOK <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Cover</title> <meta http-equiv="Content-Type" content='text/html; charset=utf-8' /> <link rel="stylesheet" href="css/xhtml.css" type="text/css" /> <style type="text/css"> img { max-width: 100%; } </style> </head> <body xml:lang="en"> <div class="svg_outer"> <div class="svg_inner"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xl="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 #{@md.make.cover_image[:w]} #{@md.make.cover_image[:h]}" preserveAspectRatio="xMidYMid meet"> <image width="#{@md.make.cover_image[:w]}" height="#{@md.make.cover_image[:h]}" xl:href="image/#{@md.make.cover_image[:cover]}" /> </svg> </div> </div> </body> </html> WOK filename_xhtml.puts cover_image,"\n" filename_xhtml.close end rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do __LINE__.to_s + ':' + __FILE__ end end end
make_segtoc()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 867 def make_segtoc begin if @make.build.toc? filename_xhtml=@make_file.epub.xhtml_index @output.each do |para| para=para.strip unless para =~/\A\s*\Z/ filename_xhtml.puts para,"\n" end end filename_xhtml.close end rescue SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do __LINE__.to_s + ':' + __FILE__ end end end
metainf_container()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 750 def metainf_container #container.xml file in META-INF directory out=@make_file.epub.metainf_cont out<<@epub_header.metainf_container out.close end
mimetype()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 745 def mimetype out=@make_file.epub.mimetype out<<@epub_header.mimetype out.close end
output_zip()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 812 def output_zip FileUtils::mkdir_p(@md.file.output_path.epub.dir) unless FileTest.directory?(@md.file.output_path.epub.dir) if FileTest.directory?(@md.env.processing_path.epub) \ and SiSU_Env::SystemCall.new.zip pwd=Dir.pwd Dir.chdir(@md.env.processing_path.epub) system(" zip -qXr9D #{@epub_doc} * ") FileUtils::mv(@epub_doc, @md.file.place_file.epub.dir) Dir.chdir(pwd) unless @md.opt.act[:maintenance][:set]==:on FileUtils::rm_r(@md.env.processing_path.epub) end else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('*EXITED epub* zip program not found') unless SiSU_Env::SystemCall.new.zip end end
songsheet()
click to toggle source
# File lib/sisu/xhtml_epub2.rb, line 737 def songsheet mimetype metainf_container css images if @md.ec[:image] #concordance #uncomment to enable inclusion of concordance file output_zip end