kindler 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 826949cf9e1f125a5731ff497c3e983f8474d6a2
4
- data.tar.gz: 831f3b2539292ec43a507ef11d18fec434aba62e
3
+ metadata.gz: 801de4aa92350e7253473516cb0f6619a375562d
4
+ data.tar.gz: 7deedab8e5b97e1b116d58e33ad82db5a5487a26
5
5
  SHA512:
6
- metadata.gz: 054fca1227c38e5192e2914a09d0544d6c1e67f25e8fa0e6cd97f872f51a133e4df45eb8f18b094d1b690d69150c41c3204a6157d793ddf8f4da7b5146a4c90a
7
- data.tar.gz: b3e33b7aae17d1e9b6b3b8c27759aa83b61878a3c1f89e8e9d73530bbfc83523774fe02d11d8c338fa591a518045419b5aec93061c3d58a6704db12275dd012c
6
+ metadata.gz: c26baa4d462d1b9af0050c838cc2f680e868a8693505d5224c8f832e59ffafa1150a13d5159c4681cb737fd7de93d37fe2e89519c72b6a76a8526467156c86a1
7
+ data.tar.gz: 3cab0787bcb95aa6fd16849d604e0c139b0b71d3502c8c7e0b053dca2ff4829a5e94aaddabf5766d75bfa2b1cf612aeda4030bfb25f03485450fa6b7c82a2230
@@ -1,3 +1,3 @@
1
1
  module Kindler
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/lib/kindler.rb CHANGED
@@ -32,7 +32,7 @@ module Kindler
32
32
  @debug = options[:debug]
33
33
  @title = options[:title] || ''
34
34
  @author = options[:author] || 'unknown'
35
- @mobi_type = options[:mobi_type] || :magzine
35
+ @mobi_type = options[:mobi_type] || :simple
36
36
  @cover = options[:cover] || ""
37
37
  @silent = options[:silent]
38
38
  @pages = []
@@ -49,7 +49,7 @@ module Kindler
49
49
  page[:section] ||= DEFAULT_SECTION
50
50
  page[:count] = pages.count + 1
51
51
  page[:file_name] = "#{page[:count].to_s.rjust(3,'0')}.html"
52
- page[:author] = 'unknown' if (page[:author]==nil or page[:author]=='')
52
+ page[:author] = '' unless page[:author]
53
53
  # escape special chars
54
54
  page[:title] = CGI::escapeHTML(page[:title])
55
55
  page[:title] = title if(page[:title] == "")
@@ -208,8 +208,8 @@ module Kindler
208
208
  def prepare_conver_img
209
209
  if @local_images.length > 0
210
210
  image_file = @local_images.first
211
- @cover_image = "#{File.dirname(image_file)}/cover-image.gif"
212
- cmd = "convert #{Shellwords.escape(image_file)} -compose over -background white -flatten -resize '300x200>' -alpha off #{Shellwords.escape(@cover_image)}"
211
+ @cover_image = "#{File.dirname(image_file)}/cover-image.jpg"
212
+ cmd = "convert #{Shellwords.escape(image_file)} -compose over -background white -flatten -resize '566x738' -alpha off #{Shellwords.escape(@cover_image)}"
213
213
  `#{cmd}` rescue ''
214
214
  end
215
215
  end
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="#{title}">
2
+ <package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="<%= title %>">
3
3
  <metadata>
4
4
  <meta content="cover-image" name="cover"/>
5
5
  <dc-metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
@@ -22,7 +22,7 @@
22
22
  <% pages.each_with_index do |page,index|%>
23
23
  <item href='<%= (index+1).to_s.rjust(3,'0') %>.html' media-type='application/xhtml+xml' id='<%= (index+1).to_s.rjust(3,'0') %>'/>
24
24
  <% end %>
25
- <item href="cover-image.gif" id="cover-image" media-type="image/gif" />
25
+ <item href="cover-image.jpg" id="cover-image" media-type="image/jpeg" />
26
26
  <item href='contents.html' media-type='application/xhtml+xml' id='contents'/>
27
27
  <item href='nav-contents.ncx' media-type='application/x-dtbncx+xml' id='nav-contents'/>
28
28
  </manifest>
@@ -34,5 +34,6 @@
34
34
  </spine>
35
35
  <guide>
36
36
  <reference href='contents.html' type='toc' title='Table of Contents'/>
37
+ <reference href="cover-image.jpg" type="cover" title="Cover"/>
37
38
  </guide>
38
39
  </package>
@@ -7,7 +7,9 @@
7
7
  <h2>
8
8
  <%= page[:title] %>
9
9
  </h2>
10
- <p><em><%= page[:author] %></em><p>
10
+ <% if page[:author] != '' %>
11
+ <p><em><%= page[:author] %></em><p>
12
+ <% end%>
11
13
  <div><%= page[:content] %></div>
12
14
  </body>
13
15
  </html>
@@ -77,7 +77,7 @@ describe "Mobi book file generator" do
77
77
 
78
78
  it "should have two sections" do
79
79
  title = 'test_contents'
80
- book = Kindler::Book.new :title=>title,:author=>'mike',:debug=>true
80
+ book = Kindler::Book.new :title=>title,:author=>'mike',:debug=>true, :mobi_type => :magzine
81
81
  book.add_page :title=>'love page1',:author=>'mike1',:content=>'this is the love page1',:section => 'love'
82
82
  book.add_page :title=>'love page2',:author=>'mike1',:content=>'this is the love page2',:section => 'love'
83
83
  book.add_page :title=>'hate page1',:author=>'mike1',:content=>'this is the hate page1',:section => 'hate'
@@ -7,11 +7,11 @@ describe "Mobi book file generator" do
7
7
  end
8
8
 
9
9
  it "should generate books given title contains space" do
10
- title = 'title with space'
11
- book = Kindler::Book.new :title=>title,:author=>'mike',:debug=>true
10
+ title = 'title with space nice'
11
+ book = Kindler::Book.new :title=>title,:author=>'mike',:debug=>true, :mobi_type => 'simple'
12
12
  book.add_page :title=>'page1',:author=>'mike1',:content=>'this is the page 1',:wrap=>true
13
13
  book.add_page :title=>'page2',:author=>'mike1',:content=>'this is the page 2',:wrap=>true
14
- book.add_page :title=>'page3',:author=>'mike1',:content=>'<img src="http://images.fanpop.com/images/image_uploads/widescreen-season-4-wallpaper-lost-661159_1680_1050.jpg"/>this is the page 3',:wrap=>true
14
+ book.add_page :title=>'page3',:author=>'mike1',:content=>'<img src="http://images.fanpop.com/images/image_uploads/Anne-Hathaway-anne-hathaway-749084_1280_800.jpg"/>this is the page 3',:wrap=>true
15
15
  book.generate
16
16
  book.should be_generated
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kindler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dongbin.li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-27 00:00:00.000000000 Z
11
+ date: 2013-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri