summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2014-04-13 17:06:01 -0600
committerDan Allen <dan.j.allen@gmail.com>2014-04-16 02:22:24 -0600
commit876185b42a6995cda542e737a52641da921fcd53 (patch)
tree89855d1deca940a4deccea89e358846cf3466d01 /bin
make it so
Diffstat (limited to 'bin')
-rwxr-xr-xbin/adb-push-ebook18
-rwxr-xr-xbin/asciidoctor-epub351
2 files changed, 69 insertions, 0 deletions
diff --git a/bin/adb-push-ebook b/bin/adb-push-ebook
new file mode 100755
index 0000000..d45442d
--- /dev/null
+++ b/bin/adb-push-ebook
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if [ -z $ADB ]; then
+ ADB=~/opt/android-sdk/platform-tools/adb
+fi
+
+if [ -z $1 ]; then
+ DOCNAME=_output/sample-book
+else
+ DOCNAME=$1
+fi
+
+if [ -f $DOCNAME.epub ]; then
+ $ADB push $DOCNAME.epub /sdcard/
+fi
+if [ -f $DOCNAME.mobi ]; then
+ $ADB push $DOCNAME.mobi /sdcard/Android/data/com.amazon.kindle/files/
+fi
diff --git a/bin/asciidoctor-epub3 b/bin/asciidoctor-epub3
new file mode 100755
index 0000000..c340f06
--- /dev/null
+++ b/bin/asciidoctor-epub3
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+
+to_file = true
+to_dir = nil
+format = nil
+validate = false
+extract = false
+args = ARGV.dup
+while (args.first || '').start_with? '-'
+ case (opt = args.shift)
+ #when '-o'
+ # to_file = args.shift
+ when '-D', '--destination-dir'
+ to_dir = args.shift
+ when '-f', '--format'
+ format = args.shift
+ when '--validate'
+ validate = true
+ when '-x', '--extract'
+ extract = true
+ when '-h', '--help'
+ puts %(Usage: #{File.basename __FILE__} [OPTION]... SOURCE_FILE
+
+Convert an AsciiDoc document to EPUB3 or MOBI/KF8.)
+ exit 0
+ when '-v', '--version'
+ require_relative '../lib/asciidoctor-epub3/version'
+ puts %(Asciidoctor EPUB3 #{Asciidoctor::Epub3::VERSION})
+ exit 0
+ else
+ warn %(Ignoring unknown option #{opt})
+ end
+end
+
+unless (source_file = args.shift)
+ warn 'Please specify a source document to convert.'
+ exit 1
+end
+
+unless File.file? source_file
+ warn %(Source file does not exist, is a directory or is not readable: #{source_file})
+ exit 1
+end
+
+require_relative '../lib/asciidoctor-epub3'
+
+pygments_attributes = (Gem::try_activate 'pygments.rb') ? ' source-highlighter=pygments pygments-css=style pygments-style=bw' : nil
+
+Asciidoctor::Epub3::Converter.convert_file source_file,
+ ebook_format: format, safe: :safe, to_dir: to_dir, to_file: to_file, validate: validate, extract: extract,
+ attributes: %(listing-caption=Listing#{pygments_attributes})