Skip to content

Commit

Permalink
images and code includes work
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Jan 19, 2011
1 parent 9974a49 commit 3019ac7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.asciidoc
Expand Up @@ -12,6 +12,8 @@ Sell: Kindle, iBooks, Lulu, Pledgie(?)

https://github.com/oreilly/couchdb-guide

A good cheat sheet: http://powerman.name/doc/asciidoc#_text

Start a Book
===================

Expand Down Expand Up @@ -111,16 +113,16 @@ The layout that the `git scribe init` produces looks like this:
|`--* 01_first_chapter.asciidoc
|`--* 02_second_chapter.asciidoc
|`--* 99_backmatter.asciidoc
|`--* img/
|`--* image/
| `--* 01.01-example-image.png
| `--* 01.02-another-image.png
| `--* 02.01-an-image.png
|`--* include/
| `--* 02.01-code.c
* style/
|`--* style.css
* site/
|`--* layout.html
* code/
|`--* 01_example.rb
* test/
|`--* 01_test.rb
* LICENSE.txt
Expand Down
7 changes: 7 additions & 0 deletions example/book/01_book.asciidoc
Expand Up @@ -5,6 +5,8 @@ Nec vitae mus fringilla eu vel pede sed pellentesque. Nascetur fugiat
nobis. Eu felis id mauris sollicitudin ut. Sem volutpat feugiat.
Ornare convallis urna vitae.

image::octocat_professor.png[]

Nec mauris sed aliquam nam mauris dolor lorem imperdiet.

== The second chapter
Expand All @@ -14,3 +16,8 @@ cras. Id tellus cubilia erat.

Quisque nullam et. Blandit dui tempor. Posuere in elit diam egestas
sem vivamus vel ac.

[c]
source~~~~
include::hello.c[]
source~~~~
Binary file added example/book/image/octocat_professor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions example/book/include/hello.c
@@ -0,0 +1,10 @@
#include <stdio.h>

main()
{
char hex[] = "599955586da1c3ad514f3e65f1081d2012ec862d";
git_oid oid;

git_oid_mkstr(&oid, hex);
printf("Raw 20 bytes: [%s]\n", (&oid)->id);
}
22 changes: 18 additions & 4 deletions lib/git-scribe.rb
Expand Up @@ -68,37 +68,45 @@ def gen
def prepare_output_dir
Dir.mkdir('output') rescue nil
Dir.chdir('output') do
Dir.mkdir('resources') rescue nil
Dir.mkdir('stylesheets') rescue nil
from_stdir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'stylesheets'))
FileUtils.cp_r from_stdir, '.'
end
end

def a2x(type)
"a2x -f #{type} -d book -r resources"
end
def a2x_wss(type)
a2x(type) + " --stylesheet=stylesheets/handbookish.css"
end

def do_pdf
puts "GENERATING PDF"
`a2x -f pdf -d book #{BOOK_FILE}`
`#{a2x('pdf')} #{BOOK_FILE}`
if $?.exitstatus == 0
'book.pdf'
end
end

def do_epub
puts "GENERATING EPUB"
`a2x -f epub -d book --epubcheck --stylesheet=stylesheets/handbookish.css #{BOOK_FILE}`
`#{a2x_wss('epub')} --epubcheck #{BOOK_FILE}`
puts 'exit status', $?.exitstatus
'book.epub'
end

def do_html
puts "GENERATING HTML"
`a2x -f xhtml -d book --stylesheet=stylesheets/handbookish.css #{BOOK_FILE}`
`#{a2x_wss('xhtml')} #{BOOK_FILE}`
puts 'exit status', $?.exitstatus
'book.html'
end

def do_site
puts "GENERATING SITE"
`a2x -f chunked -d book --stylesheet=stylesheets/handbookish.css #{BOOK_FILE}`
`#{a2x_wss('chunked')} #{BOOK_FILE}`
puts 'exit status', $?.exitstatus
'book.html'
end
Expand All @@ -112,6 +120,12 @@ def gather_and_process
f.puts File.read(file)
end
end
files = Dir.glob("book/image/**/*")
FileUtils.cp_r(files, 'output/resources/')

files = Dir.glob("book/include/**/*")
FileUtils.cp_r(files, 'output/')
pp files
end

# DISPLAY HELPER FUNCTIONS #
Expand Down

0 comments on commit 3019ac7

Please sign in to comment.