pluto 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pluto/fetcher.rb +28 -5
- data/lib/pluto/formatter.rb +4 -0
- data/lib/pluto/version.rb +1 -1
- data/templates/blank.html.erb +75 -16
- metadata +4 -4
data/lib/pluto/fetcher.rb
CHANGED
@@ -71,34 +71,54 @@ class Fetcher
|
|
71
71
|
item_attribs = {
|
72
72
|
:title => item.title.content,
|
73
73
|
:url => item.link.href,
|
74
|
-
:published_at => item.updated.content,
|
74
|
+
:published_at => item.updated.content.utc.strftime( "%Y-%m-%d %H:%M" ),
|
75
75
|
# :content => item.content.content,
|
76
76
|
:feed_id => feed_rec.id
|
77
77
|
}
|
78
78
|
guid = item.id.content
|
79
79
|
|
80
|
+
if item.summary
|
81
|
+
item_attribs[ :content ] = item.summary.content
|
82
|
+
else
|
83
|
+
if item.content
|
84
|
+
text = item.content.content.dup
|
85
|
+
## strip all html tags
|
86
|
+
text = text.gsub( /<[^>]+>/, '' )
|
87
|
+
text = text[ 0..400 ] # get first 400 chars
|
88
|
+
## todo: check for length if > 400 add ... at the end???
|
89
|
+
item_attribs[ :content ] = text
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
80
93
|
puts "- #{item.title.content}"
|
81
94
|
puts " link >#{item.link.href}<"
|
82
95
|
puts " id (~guid) >#{item.id.content}<"
|
83
96
|
|
84
97
|
### todo: use/try published first? why? why not?
|
85
|
-
puts " updated (~pubDate) >#{item.updated.content}< : #{item.updated.content.class.name}"
|
98
|
+
puts " updated (~pubDate) >#{item.updated.content}< >#{item.updated.content.utc.strftime( "%Y-%m-%d %H:%M" )}< : #{item.updated.content.class.name}"
|
86
99
|
puts
|
87
100
|
|
88
101
|
else # assume RSS::Rss
|
102
|
+
|
89
103
|
item_attribs = {
|
90
104
|
:title => item.title,
|
91
105
|
:url => item.link,
|
92
|
-
:published_at => item.pubDate,
|
93
|
-
:content => item.content_encoded,
|
106
|
+
:published_at => item.pubDate.utc.strftime( "%Y-%m-%d %H:%M" ),
|
107
|
+
# :content => item.content_encoded,
|
94
108
|
:feed_id => feed_rec.id
|
95
109
|
}
|
110
|
+
|
111
|
+
# if item.content_encoded.nil?
|
112
|
+
# puts " using description for content"
|
113
|
+
item_attribs[ :content ] = item.description
|
114
|
+
# end
|
115
|
+
|
96
116
|
guid = item.guid.content
|
97
117
|
|
98
118
|
puts "- #{item.title}"
|
99
119
|
puts " link (#{item.link})"
|
100
120
|
puts " guid (#{item.guid.content})"
|
101
|
-
puts " pubDate
|
121
|
+
puts " pubDate >#{item.pubDate}< >#{item.pubDate.utc.strftime( "%Y-%m-%d %H:%M" )}< : #{item.pubDate.class.name}"
|
102
122
|
puts
|
103
123
|
|
104
124
|
end
|
@@ -107,6 +127,9 @@ class Fetcher
|
|
107
127
|
if rec.nil?
|
108
128
|
rec = Item.new
|
109
129
|
rec.guid = guid
|
130
|
+
puts "** NEW"
|
131
|
+
else
|
132
|
+
puts "UPDATE"
|
110
133
|
end
|
111
134
|
|
112
135
|
rec.update_attributes!( item_attribs )
|
data/lib/pluto/formatter.rb
CHANGED
data/lib/pluto/version.rb
CHANGED
data/templates/blank.html.erb
CHANGED
@@ -1,26 +1,85 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<style>
|
4
|
+
body {
|
5
|
+
font-family: sans-serif;
|
6
|
+
}
|
7
|
+
|
8
|
+
a, a:visited {
|
9
|
+
text-decoration: none;
|
10
|
+
color: black;
|
11
|
+
}
|
12
|
+
|
13
|
+
a:hover {
|
14
|
+
text-decoration: underline;
|
15
|
+
background-color: aqua;
|
16
|
+
}
|
17
|
+
|
18
|
+
</style>
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<h1><%= headers['title'] %></h1>
|
1
22
|
|
2
|
-
<
|
23
|
+
<table>
|
24
|
+
<tr>
|
25
|
+
<td style='vertical-align:top;'><!-- first column -->
|
3
26
|
|
4
|
-
|
5
|
-
|
6
|
-
<% Feed.all.each do |feed| %>
|
7
|
-
<li><%= feed.title %> (<%= feed.items.count %>)</li>
|
8
|
-
<% end %>
|
9
|
-
</ul>
|
27
|
+
<% last_published_at = Time.local( 1999, 1, 1 )
|
28
|
+
Item.latest.each do |item| %>
|
10
29
|
|
30
|
+
<% unless last_published_at.year == item.published_at.year &&
|
31
|
+
last_published_at.month == item.published_at.month &&
|
32
|
+
last_published_at.day == item.published_at.day %>
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
<h3 style='background-color: #eeeeee; padding: 2px 6px; border: 1px solid #7d7d7d;'>
|
37
|
+
<%= item.published_at.strftime('%A, %d. %B %Y') %>
|
38
|
+
</h3>
|
11
39
|
|
12
|
-
<%
|
13
|
-
|
14
|
-
<p>
|
15
|
-
|
40
|
+
<% end %><!-- if new day? -->
|
41
|
+
|
42
|
+
<p style='font-size: 80%; margin-bottom: 6px;'>
|
43
|
+
(<a href='<%= item.feed.url %>'><%= item.feed.title %></a>)
|
16
44
|
</p>
|
17
45
|
|
18
|
-
<
|
19
|
-
|
46
|
+
<h2 style='margin-top: 0;'>
|
47
|
+
<a href='<%= item.url %>'><%= item.title %></a>
|
48
|
+
</h2>
|
20
49
|
|
21
|
-
|
50
|
+
<div class='content'>
|
51
|
+
<%= item.content %>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<!--
|
55
|
+
<p>
|
56
|
+
<%= item.published_at.strftime('%H:%M') %>
|
22
57
|
</p>
|
58
|
+
-->
|
23
59
|
|
24
|
-
|
60
|
+
<% last_published_at = item.published_at
|
61
|
+
end %><!-- each item -->
|
25
62
|
|
26
|
-
|
63
|
+
</td>
|
64
|
+
<td style='vertical-align:top;'><!-- second column -->
|
65
|
+
|
66
|
+
<p>
|
67
|
+
Last Updated
|
68
|
+
</p>
|
69
|
+
<p style='font-size: 80%;'><%= Time.now.strftime('%A, %d. %B %Y %H:%M') %>
|
70
|
+
</p>
|
71
|
+
|
72
|
+
<p>Subscriptions</p>
|
73
|
+
<ul style='list-style: none; margin-left: 0; padding-left: 0; font-size: 80%;'>
|
74
|
+
<% Feed.all.each do |feed| %>
|
75
|
+
<li><a href='<%= feed.url %>'><%= feed.title %></a></li>
|
76
|
+
<% end %>
|
77
|
+
</ul>
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
</td>
|
82
|
+
</tr>
|
83
|
+
</table>
|
84
|
+
<body>
|
85
|
+
</html>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gerald Bauer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-07-
|
18
|
+
date: 2012-07-17 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rdoc
|