]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/epub/bin/dbtoepub
Capitalized the start of a sentence in the bucket section of cataloging.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / epub / bin / dbtoepub
1 #!/usr/bin/env ruby\r
2 # This program converts DocBook documents into .epub files.\r
3\r
4 # Usage: dbtoepub [OPTIONS] [DocBook Files]\r
5 #\r
6 # .epub is defined by the IDPF at www.idpf.org and is made up of 3 standards:\r
7 # - Open Publication Structure (OPS)\r
8 # - Open Packaging Format (OPF) \r
9 # - Open Container Format (OCF)\r
10 #\r
11 # Specific options:\r
12 #     -c, --css [FILE]                 Use FILE for CSS on generated XHTML.\r
13 #     -d, --debug                      Show debugging output.\r
14 #     -f, --font [OTF FILE]            Embed OTF FILE in .epub.\r
15 #     -h, --help                       Display usage info.\r
16 #     -s, --stylesheet [XSL FILE]      Use XSL FILE as a customization\r
17 #                                        layer (imports epub/docbook.xsl).\r
18 #     -v, --verbose                    Make output verbose.\r
19 \r
20 lib = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))\r
21 $LOAD_PATH.unshift(lib) if File.exist?(lib)\r
22 \r
23 require 'fileutils'\r
24 require 'optparse'\r
25 require 'tmpdir'\r
26 \r
27 require 'docbook'\r
28 \r
29 verbose = false\r
30 debug = false\r
31 css_file = nil\r
32 otf_files = []\r
33 customization_layer = nil\r
34 output_file = nil\r
35 \r
36 # Set up the OptionParser\r
37 opts = OptionParser.new\r
38 opts.banner = "Usage: #{File.basename($0)} [OPTIONS] [DocBook Files]\r
39 \r
40 #{File.basename($0)} converts DocBook <book> and <article>s into to .epub files.\r
41 \r
42 .epub is defined by the IDPF at www.idpf.org and is made up of 3 standards:\r
43 - Open Publication Structure (OPS)\r
44 - Open Packaging Format (OPF) \r
45 - Open Container Format (OCF)\r
46 \r
47 Specific options:"\r
48 opts.on("-c", "--css [FILE]", "Use FILE for CSS on generated XHTML.") {|f| css_file = f}\r
49 opts.on("-d", "--debug", "Show debugging output.") {debug = true; verbose = true}\r
50 opts.on("-f", "--font [OTF FILE]", "Embed OTF FILE in .epub.") {|f| otf_files << f}\r
51 opts.on("-h", "--help", "Display usage info.") {puts opts.to_s; exit 0}\r
52 opts.on("-o", "--output [OUTPUT FILE]", "Output ePub file as OUTPUT FILE.") {|f| output_file = f}\r
53 opts.on("-s", "--stylesheet [XSL FILE]", "Use XSL FILE as a customization layer (imports epub/docbook.xsl).") {|f| customization_layer = f}\r
54 opts.on("-v", "--verbose", "Make output verbose.") {verbose = true}\r
55 \r
56 db_files = opts.parse(ARGV)\r
57 if db_files.size == 0\r
58   puts opts.to_s\r
59   exit 0\r
60 end\r
61 \r
62 db_files.each {|docbook_file|\r
63   dir = File.expand_path(File.join(Dir.tmpdir, ".epubtmp#{Time.now.to_f.to_s}"))\r
64   FileUtils.mkdir_p(dir)\r
65   e = DocBook::Epub.new(docbook_file, dir, css_file, customization_layer, otf_files)\r
66 \r
67   if output_file\r
68     epub_file = output_file\r
69   else  \r
70     epub_file = File.basename(docbook_file, ".xml") + ".epub"\r
71   end  \r
72   puts "Rendering DocBook file #{docbook_file} to #{epub_file}" if verbose\r
73   e.render_to_file(epub_file)\r
74 }  \r