siuying-rssbook 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/rssbook.rb +37 -39
- data/rssbook.gemspec +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
@@ -50,6 +50,7 @@ task SPEC_FILE => FileList['lib/**','bin/**','Rakefile','LICENSE','README'] do |
|
|
50
50
|
sort.
|
51
51
|
reject{ |file| file =~ /^\./ }.
|
52
52
|
reject { |file| file =~ /^doc/ }.
|
53
|
+
reject { |file| file =~ /\.gem$/ }.
|
53
54
|
map{ |file| " #{file}" }.
|
54
55
|
join("\n")
|
55
56
|
# piece file back together and write...
|
data/lib/rssbook.rb
CHANGED
@@ -12,7 +12,7 @@ require "prawn/measurement_extensions"
|
|
12
12
|
require 'prawn/format'
|
13
13
|
|
14
14
|
module RSSBook
|
15
|
-
VERSION = '0.2.
|
15
|
+
VERSION = '0.2.1'
|
16
16
|
|
17
17
|
class Renderer
|
18
18
|
def initialize(input, output, font = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf",
|
@@ -43,6 +43,7 @@ module RSSBook
|
|
43
43
|
desc = item.content
|
44
44
|
link_id = "link_#{count}"
|
45
45
|
render_item(doc, title, desc, link_id)
|
46
|
+
doc.start_new_page unless item == @items.last
|
46
47
|
count += 1
|
47
48
|
end
|
48
49
|
end
|
@@ -52,53 +53,50 @@ module RSSBook
|
|
52
53
|
private
|
53
54
|
def render_toc(doc)
|
54
55
|
|
55
|
-
# TITLE
|
56
|
-
doc.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
:title => {:font_size => "3em"}, :details => {:kerning => true}
|
61
|
-
|
62
|
-
doc.pad_bottom(10) do
|
63
|
-
doc.text "<a name='title' class='toc title'></a>"
|
64
|
-
doc.text @feed.title
|
65
|
-
end
|
56
|
+
# TITLE
|
57
|
+
doc.text_options.update(:wrap => :character, :size => 32, :spacing => 4)
|
58
|
+
doc.tags :p => {:font_size => "1em", :color => "black"}
|
59
|
+
doc.styles :toc => {:font_size => "1.5em", :color => "black", :text_decoration => :underline},
|
60
|
+
:title => {:font_size => "3em"}, :details => {:kerning => true}
|
66
61
|
|
67
|
-
|
68
|
-
doc.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
62
|
+
doc.pad_bottom(10) do
|
63
|
+
doc.text "<a name='title' class='toc title'></a>"
|
64
|
+
doc.text @feed.title
|
65
|
+
end
|
66
|
+
|
67
|
+
# TOC
|
68
|
+
doc.text_options.update(:wrap => :character, :size => 26, :spacing => 4)
|
69
|
+
count = 1
|
70
|
+
@items.each do |item|
|
71
|
+
title = item.title
|
72
|
+
doc.pad_bottom(5) do
|
73
|
+
doc.text "<p>#{count}</p><a href='#link_#{count}' class='toc'>#{title}</a>"
|
77
74
|
end
|
78
|
-
|
75
|
+
|
76
|
+
count += 1
|
79
77
|
end
|
78
|
+
|
79
|
+
doc.start_new_page
|
80
80
|
end
|
81
81
|
|
82
82
|
def render_item(doc, title, description, link_id)
|
83
83
|
puts "render: #{title}"
|
84
|
-
doc.bounding_box([doc.bounds.left, doc.bounds.top], :width => doc.bounds.width) do
|
85
|
-
doc.pad_bottom(30) do
|
86
|
-
doc.text_options.update(:wrap => :character, :size => 26, :spacing => 4)
|
87
|
-
doc.text "<a name='#{link_id}'/>"
|
88
|
-
doc.text title
|
89
|
-
end
|
90
|
-
|
91
|
-
doc.text_options.update(:wrap => :character, :size => 20, :spacing => 4)
|
92
|
-
description = Hpricot(description).inner_text
|
93
|
-
description.split(/[\n\r][\n\r]?/).each do |d|
|
94
|
-
doc.pad_bottom(15) do
|
95
|
-
doc.text d
|
96
|
-
end
|
97
|
-
end
|
98
84
|
|
99
|
-
|
100
|
-
doc.
|
85
|
+
doc.pad_bottom(30) do
|
86
|
+
doc.text_options.update(:wrap => :character, :size => 26, :spacing => 4)
|
87
|
+
doc.text "<a name='#{link_id}'/>"
|
88
|
+
doc.text title
|
101
89
|
end
|
90
|
+
|
91
|
+
doc.text_options.update(:wrap => :character, :size => 20, :spacing => 4)
|
92
|
+
description = Hpricot(description).inner_text
|
93
|
+
description.split(/[\n\r][\n\r]?/).each do |d|
|
94
|
+
doc.pad_bottom(15) do
|
95
|
+
doc.text d
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
doc.text "<a href='#title' class='toc'><<</a>"
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
data/rssbook.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
s.name = 'rssbook'
|
5
|
-
s.version = '0.2.
|
5
|
+
s.version = '0.2.1'
|
6
6
|
s.date = '2009-06-14'
|
7
7
|
|
8
8
|
s.summary = s.description = "Convert RSS Feed to PDF format."
|