+++ /dev/null
-#!/usr/bin/env ruby\r
-# This program converts DocBook documents into .epub files.\r
-# \r
-# Usage: dbtoepub [OPTIONS] [DocBook Files]\r
-#\r
-# .epub is defined by the IDPF at www.idpf.org and is made up of 3 standards:\r
-# - Open Publication Structure (OPS)\r
-# - Open Packaging Format (OPF) \r
-# - Open Container Format (OCF)\r
-#\r
-# Specific options:\r
-# -c, --css [FILE] Use FILE for CSS on generated XHTML.\r
-# -d, --debug Show debugging output.\r
-# -f, --font [OTF FILE] Embed OTF FILE in .epub.\r
-# -h, --help Display usage info.\r
-# -s, --stylesheet [XSL FILE] Use XSL FILE as a customization\r
-# layer (imports epub/docbook.xsl).\r
-# -v, --verbose Make output verbose.\r
-\r
-lib = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))\r
-$LOAD_PATH.unshift(lib) if File.exist?(lib)\r
-\r
-require 'fileutils'\r
-require 'optparse'\r
-require 'tmpdir'\r
-\r
-require 'docbook'\r
-\r
-verbose = false\r
-debug = false\r
-css_file = nil\r
-otf_files = []\r
-customization_layer = nil\r
-output_file = nil\r
-\r
-# Set up the OptionParser\r
-opts = OptionParser.new\r
-opts.banner = "Usage: #{File.basename($0)} [OPTIONS] [DocBook Files]\r
-\r
-#{File.basename($0)} converts DocBook <book> and <article>s into to .epub files.\r
-\r
-.epub is defined by the IDPF at www.idpf.org and is made up of 3 standards:\r
-- Open Publication Structure (OPS)\r
-- Open Packaging Format (OPF) \r
-- Open Container Format (OCF)\r
-\r
-Specific options:"\r
-opts.on("-c", "--css [FILE]", "Use FILE for CSS on generated XHTML.") {|f| css_file = f}\r
-opts.on("-d", "--debug", "Show debugging output.") {debug = true; verbose = true}\r
-opts.on("-f", "--font [OTF FILE]", "Embed OTF FILE in .epub.") {|f| otf_files << f}\r
-opts.on("-h", "--help", "Display usage info.") {puts opts.to_s; exit 0}\r
-opts.on("-o", "--output [OUTPUT FILE]", "Output ePub file as OUTPUT FILE.") {|f| output_file = f}\r
-opts.on("-s", "--stylesheet [XSL FILE]", "Use XSL FILE as a customization layer (imports epub/docbook.xsl).") {|f| customization_layer = f}\r
-opts.on("-v", "--verbose", "Make output verbose.") {verbose = true}\r
-\r
-db_files = opts.parse(ARGV)\r
-if db_files.size == 0\r
- puts opts.to_s\r
- exit 0\r
-end\r
-\r
-db_files.each {|docbook_file|\r
- dir = File.expand_path(File.join(Dir.tmpdir, ".epubtmp#{Time.now.to_f.to_s}"))\r
- FileUtils.mkdir_p(dir)\r
- e = DocBook::Epub.new(docbook_file, dir, css_file, customization_layer, otf_files)\r
-\r
- if output_file\r
- epub_file = output_file\r
- else \r
- epub_file = File.basename(docbook_file, ".xml") + ".epub"\r
- end \r
- puts "Rendering DocBook file #{docbook_file} to #{epub_file}" if verbose\r
- e.render_to_file(epub_file)\r
-} \r