Permalink
Browse files

added cover to epub

  • Loading branch information...
1 parent 662d9d7 commit a80bb6bcff1daef6ffd98b9c29bbc8f6a3e21dbc Drew Bowman committed Sep 26, 2012
Showing with 15 additions and 1 deletion.
  1. +2 −0 lib/eeepub/maker.rb
  2. +2 −0 lib/eeepub/opf.rb
  3. +5 −0 spec/eeepub/maker_spec.rb
  4. +6 −1 spec/eeepub/opf_spec.rb
View
@@ -53,6 +53,7 @@ def #{name}(value)
:uid,
:files,
:nav,
+ :cover,
:ncx_file,
:opf_file
].each do |name|
@@ -130,6 +131,7 @@ def create_epub
:subject => @subjects,
:description => @descriptions,
:rights => @rightss,
+ :cover => @cover,
:relation => @relations,
:manifest => @files.map{|file|
case file
View
@@ -14,6 +14,7 @@ class OPF < ContainerItem
:manifest,
:spine,
:guide,
+ :cover,
:ncx,
:toc
@@ -83,6 +84,7 @@ def build_metadata(builder)
end
end
end
+ builder.meta(:name => 'cover', :content => self.cover) if self.cover
end
end
@@ -16,6 +16,7 @@
uid 'http://example.com/book/foo'
ncx_file 'toc.ncx'
opf_file 'content.opf'
+ cover 'cover.jpg'
files ['foo.html', 'bar.html']
nav [
{:label => '1. foo', :content => 'foo.html'},
@@ -32,6 +33,7 @@
it { @maker.instance_variable_get(:@uid).should == 'http://example.com/book/foo' }
it { @maker.instance_variable_get(:@ncx_file).should == 'toc.ncx' }
it { @maker.instance_variable_get(:@opf_file).should == 'content.opf' }
+ it { @maker.instance_variable_get(:@cover).should == 'cover.jpg' }
it { @maker.instance_variable_get(:@files).should == ['foo.html', 'bar.html'] }
it {
@maker.instance_variable_get(:@nav).should == [
@@ -61,6 +63,7 @@
:rights => ['xxx'],
:relation => ['xxx'],
:ncx => "toc.ncx",
+ :cover => 'cover.jpg',
:publisher => ["jugyo.org"],
:unique_identifier=>"http://example.com/book/foo",
:identifier => [{:value => "http://example.com/book/foo", :scheme => "URL", :id => "http://example.com/book/foo"}],
@@ -90,6 +93,7 @@
uid 'http://example.com/book/foo'
ncx_file 'toc.ncx'
opf_file 'content.opf'
+ cover 'cover.jpg'
files [{'foo.html' => 'foo/bar'}, {'bar.html' => 'foo/bar/baz'}]
nav [
{:label => '1. foo', :content => 'foo.html'},
@@ -113,6 +117,7 @@
:rights => ['xxx'],
:relation => ['xxx'],
:ncx => "toc.ncx",
+ :cover => 'cover.jpg',
:publisher => ["jugyo.org"],
:unique_identifier=>"http://example.com/book/foo",
:identifier => [{:value => "http://example.com/book/foo", :scheme => "URL", :id=>"http://example.com/book/foo"}],
View
@@ -118,7 +118,8 @@
:relation => 'relation',
:creator => 'creator',
:publisher => 'publisher',
- :rights => 'rights'
+ :rights => 'rights',
+ :cover => 'cover.jpg'
)
end
@@ -144,6 +145,10 @@
identifier.attribute('id').value.should == @opf.unique_identifier
identifier.attribute('scheme').value.should == @opf.identifier[0][:scheme]
identifier.inner_text.should == @opf.identifier[0][:value]
+
+ identifier = metadata.at('meta')
+ identifier.attribute('name').value.should == 'cover'
+ identifier.attribute('content').value.should == 'cover.jpg'
end
end

0 comments on commit a80bb6b

Please sign in to comment.