futurist-fieldguide/printable.rb

49 lines
1.3 KiB
Ruby
Raw Normal View History

2015-05-26 17:39:55 +00:00
#!/usr/local/bin/ruby
#
# dokuwiki -> pdf conversion for futurist fieldguide
2015-06-02 17:25:14 +00:00
require "slop"
2015-06-02 20:58:17 +00:00
opts = Slop.parse do |o|
o.string '-f','--file', 'source file basename'
o.bool '-v', '--verbose', 'enable verbose mode'
o.bool '-g', '--git', 'commit new files to git repo'
2015-06-02 17:25:14 +00:00
end
2015-05-26 17:39:55 +00:00
repo="/home/nik/pandoc/futurist-fieldguide/"
doku="/var/www/libarynth/dokuwiki/data/pages/futurist_fieldguide/"
user="www-data"
2015-06-02 17:25:14 +00:00
#file=ARGV[0] # dokuwiki pagenme as argument (no opts)
2015-05-26 17:39:55 +00:00
2015-06-02 17:25:14 +00:00
file = opts[:file]
puts file
2015-05-26 17:39:55 +00:00
# parse dokuwiki -> html
`php /var/www/libarynth/dokuwiki/bin/dokucli.php < #{doku}/#{file}.txt > /tmp/#{file}.html`
# convert html -> pdf with pandoc
# extra html step to create self-contained (local) images
`pandoc /tmp/#{file}.html --self-contained -o /tmp/#{file}.html`
2015-06-02 11:44:15 +00:00
`pandoc /tmp/#{file}.html -S --template=#{repo}/pandoc/templates/fieldguide.tex \
--include-in-header=#{repo}/pandoc/header.tex \
--metadata=title-meta:#{file} \
--latex-engine=xelatex -o #{repo}/print/#{file}.pdf`
2015-05-26 19:28:53 +00:00
2015-05-27 05:11:07 +00:00
# merge single pdfs with 'assemble.rb'
2015-05-26 19:28:53 +00:00
2015-05-29 10:15:51 +00:00
# gittery
# - assuming the script is run in #{repo} and has origin ssh://git@repo.fo.am:foam/futurist-fieldguide.git
# - otherwise perhaps https://github.com/schacon/ruby-git
2015-05-27 09:30:17 +00:00
2015-06-02 17:25:14 +00:00
if opts.git?
`git add -A`
`git commit -m "#{file}"`
`git pull --commit`
`git push`
end
2015-05-29 10:15:51 +00:00