Skip to content

Commit

Permalink
feat(pdf): PDFで出力できるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
kubosho committed Jul 21, 2014
1 parent 0d7a84d commit b6c117b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bin/fopub"]
path = bin/fopub
url = https://github.com/asciidoctor/asciidoctor-fopub.git
26 changes: 22 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SRC_FILE = 'index.adoc'
OUTPUT_DIRECTORY = 'build/'
OUTPUT_FILE = 'index.html'
OUTPUT_HTML_FILE = 'index.html'
OUTPUT_XML_FILE = 'steins-git.xml'

REPOSITORY = if ENV['GH_TOKEN']
'https://$GH_TOKEN@github.com/o2project/steins-git'
Expand Down Expand Up @@ -41,11 +42,18 @@ def directory_copy(src, dist)
FileUtils.copy_entry src, dist
end

def build_asciidoc(src, output)
def build_asciidoc_to_html(src, output)
sh "bundle exec asciidoctor -a bookversion=`node ./bin/bookversion` \
-a icons=font -o #{output} #{src}"
end

def build_asciidoc_to_pdf(src, output)
sh "bundle exec asciidoctor -a lang=en -a bookversion=`node ./bin/bookversion` \
-a icons=font -b docbook \
-o #{output} #{src}"
sh "./bin/build-pdf #{output}"
end

def push_to_target_branch(repo, branch)
sha1, _ = `git log -n 1 --oneline`.strip.split(' ')

Expand All @@ -68,8 +76,18 @@ namespace :generate do
directory_copy 'Ch3_HowToGit/img', "#{OUTPUT_DIRECTORY}/Ch3_HowToGit/img"
puts "Done!"
puts 'Generate HTML...'
build_asciidoc SRC_FILE, "#{OUTPUT_DIRECTORY}#{OUTPUT_FILE}"
puts "Done! => #{OUTPUT_FILE}"
build_asciidoc_to_html SRC_FILE, "#{OUTPUT_DIRECTORY}#{OUTPUT_HTML_FILE}"
puts "Done! => #{OUTPUT_HTML_FILE}"
end

task :pdf do
puts 'Each section img directory recursively copy to under build directory...'
directory_copy 'Ch1_WhatsGit/img', "#{OUTPUT_DIRECTORY}/Ch1_WhatsGit/img"
directory_copy 'Ch3_HowToGit/img', "#{OUTPUT_DIRECTORY}/Ch3_HowToGit/img"
puts "Done!"
puts 'Generate PDF...'
build_asciidoc_to_pdf SRC_FILE, "#{OUTPUT_DIRECTORY}#{OUTPUT_XML_FILE}"
puts "Done!"
end
end

Expand Down
13 changes: 13 additions & 0 deletions bin/build-pdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

declare parentDir=$(cd $(dirname $(cd $(dirname $0);pwd));pwd)
declare currentDir=$(cd $(dirname $0);pwd)
SRC_FILE=${parentDir}/$1

${currentDir}/fopub/fopub "${SRC_FILE}" \
-param body.font.family VL-Gothic-Regular \
-param dingbat.font.family VL-Gothic-Regular \
-param monospace.font.family VL-Gothic-Regular \
-param sans.font.family VL-Gothic-Regular \
-param title.font.family VL-Gothic-Regular \
-param alignment left
1 change: 1 addition & 0 deletions bin/fopub
Submodule fopub added at 03e6f0

0 comments on commit b6c117b

Please sign in to comment.