diff --git a/.gitignore b/.gitignore
index aa71241..ad9af3a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
_site
-rgh-*.epub
+ebooks
*#
*~
diff --git a/script/publish b/script/publish
index cdd16ff..3a41993 100755
--- a/script/publish
+++ b/script/publish
@@ -2,7 +2,9 @@
# Simple script to generate EPUB book (which could be also converted
# to MOBI then) from site sources
#
-# It depends on on 'eeepub' ruby gem
+# It depends on on 'eeepub' ruby gem and also you should have
+# ebook-convert executable somewhere in path (or use --path argument
+# for that)
#
# Usage is simple:
#
@@ -12,6 +14,30 @@
require 'eeepub'
require 'date'
require 'fileutils'
+require 'optparse'
+
+calibre_path = '/Applications/calibre.app/Contents/MacOS'
+OptionParser.new do |opts|
+ opts.banner = "Usage: #{ARGV[0]} [options]"
+ opts.on("-p", "--calibre-path PATH", "The path to ebook-convert binary, it also look in PATH env (default: #{calibre_path})") do |v|
+ calibre_path = v
+ end
+ opts.on_tail("-?", "--help", "Show this message") do
+ puts opts
+ exit
+ end
+end.parse!
+
+ENV["PATH"] = "#{ENV["PATH"]}:#{calibre_path}"
+def executable?(bin)
+ ENV["PATH"].split(":").any? do |path|
+ File.executable?(File.join(path, bin))
+ end
+end
+
+unless executable?("ebook-convert")
+ abort("ebook-convert not found in PATH. Use --calibre-path option to specify custom path")
+end
today = Date.today
system("jekyll build")
@@ -37,9 +63,6 @@ end
Dir["#{ORIGINAL_DIR}/*.html"].each do |f|
old = File.read(f)
new = old.gsub(%r("/css/styles.css"), %q("css/styles.css"))
- .gsub(%r(
), %q(
))
- .gsub(%r(