kindler 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kindler/version.rb +1 -1
- data/lib/kindler.rb +4 -4
- data/lib/templates/book.opf.erb +3 -2
- data/lib/templates/page.html.erb +3 -1
- data/spec/cases/generator_spec.rb +1 -1
- data/spec/cases/title_space_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 801de4aa92350e7253473516cb0f6619a375562d
|
4
|
+
data.tar.gz: 7deedab8e5b97e1b116d58e33ad82db5a5487a26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c26baa4d462d1b9af0050c838cc2f680e868a8693505d5224c8f832e59ffafa1150a13d5159c4681cb737fd7de93d37fe2e89519c72b6a76a8526467156c86a1
|
7
|
+
data.tar.gz: 3cab0787bcb95aa6fd16849d604e0c139b0b71d3502c8c7e0b053dca2ff4829a5e94aaddabf5766d75bfa2b1cf612aeda4030bfb25f03485450fa6b7c82a2230
|
data/lib/kindler/version.rb
CHANGED
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] || :
|
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] = '
|
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.
|
212
|
-
cmd = "convert #{Shellwords.escape(image_file)} -compose over -background white -flatten -resize '
|
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
|
data/lib/templates/book.opf.erb
CHANGED
@@ -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="
|
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.
|
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>
|
data/lib/templates/page.html.erb
CHANGED
@@ -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/
|
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.
|
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-
|
11
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|