Monday, August 1, 2011

Arrgh! Why is Scott Chacon Still on the Cover of SPDY Book, Kindle Edition?

‹prev | My Chain | next›

Somehow Scott Chacon's picture is on the front of the Kindle (mobi) edition of SPDY Book. I am using his very nice git-scribe toolchain to maintain and generate SPDY Book, so that is at least a partial explanation. Still, I swear that I have deleted his picture from every possible place in my source directory, but it keeps popping back up. He tasks me. He tasks me. And I shall have him. Gone. Dammit.

I start by searching for cover images:
➜  spdybook git:(master) find -ls| grep cover
2280514 384 -rw-r--r-- 1 cstrom cstrom 389941 Jul 31 23:56 ./output/images/cover.png
2279528 60 -rw-r--r-- 1 cstrom cstrom 59454 Jul 21 21:17 ./output/image/cover.jpg
2280317 384 -rw-r--r-- 1 cstrom cstrom 389941 Jul 25 01:07 ./book/images/cover.png
Dang it! I had deleted that cover.jpg from the source directory. I neglected to get rid of it from the generated output directory. It's been happily finding its way into the mobi formatted book since July 21. Ah well, a quick rm ./output/image/cover.jpg and he is once and forever gone:

Of course, it would be nice to get my real cover in the mobi version. I have the cover in PNG format, but it is easy enough to convert it to the JPEG required by git-scribe:
➜  image git:(master) ✗ convert -format jpg ../images/cover.png cover.jpg
➜ image git:(master) ✗ ls -l
total 120
-rw-r--r-- 1 cstrom cstrom 119604 2011-08-01 22:22 cover.jpg
With that, I have my sweet SPDY cover back:

I would prefer the image directory to be plural. For SPDY Book, I put all of my images in the chapter directories. Even so, a book can have multiple cover images (front, back, inside, etc). The default cover location is specified in the lib/git-scribe/generate.rb:'book.opf', 'w+') do |f|
lang = @config['language'] || 'en'
author = @config['author'] || 'Author'
cover = @config['cover'] || 'image/cover.jpg'
data = {'title' => book_title,
'language' => lang,
'author' => author,
'pubdate' =>"%Y-%m-%d"),
'cover_image' => cover}
f.puts opf_template.render( data )
So I change the location:
        cover  = @config['cover'] || 'images/cover.jpg'
I also modify my local changes to the docbook XSL-FO so that the PDF will include cover.jpg instead of the PNG version. I re-install my local gem:
➜  git-scribe git:(master) gem build git-scribe.gemspec; gem install git-scribe-0.0.9.gem
Successfully built RubyGem
Name: git-scribe
Version: 0.0.9
File: git-scribe-0.0.9.gem
Successfully installed git-scribe-0.0.9
1 gem installed
Then I remove the PNG cover image and the image directory (from both book and output). With that, I re-generate my mobi and PDF copies of SPDY Book. Now they both have the right cover. And no trace of Scott Chacon!

Day #100

1 comment: