pluto 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{History.markdown → History.md} +0 -0
- data/Manifest.txt +7 -18
- data/README.md +172 -0
- data/Rakefile +11 -6
- data/config/pluto.index.yml +19 -0
- data/lib/pluto.rb +14 -12
- data/lib/pluto/cli/main.rb +213 -0
- data/lib/pluto/cli/opts.rb +38 -2
- data/lib/pluto/formatter.rb +17 -39
- data/lib/pluto/installer.rb +58 -0
- data/lib/pluto/lister.rb +42 -0
- data/lib/pluto/manifest_helpers.rb +50 -0
- data/lib/pluto/models.rb +60 -5
- data/lib/pluto/schema.rb +38 -6
- data/lib/pluto/updater.rb +90 -114
- data/lib/pluto/version.rb +1 -1
- metadata +65 -33
- data/README.markdown +0 -107
- data/lib/pluto/cli/runner.rb +0 -96
- data/lib/pluto/server.rb +0 -108
- data/lib/pluto/server/public/feed-icon-10x10.png +0 -0
- data/lib/pluto/server/public/style.css +0 -79
- data/lib/pluto/server/views/_debug.erb +0 -16
- data/lib/pluto/server/views/_version.erb +0 -5
- data/lib/pluto/server/views/debug.erb +0 -14
- data/lib/pluto/server/views/feeds.erb +0 -13
- data/lib/pluto/server/views/index.erb +0 -3
- data/lib/pluto/server/views/items.erb +0 -12
- data/lib/pluto/server/views/layout.erb +0 -22
- data/lib/pluto/server/views/sites.erb +0 -21
- data/templates/blank.html.erb +0 -133
- data/templates/blank.top.html.erb +0 -10
- data/templates/blank.txt +0 -5
- data/templates/feed-icon-10x10.png +0 -0
data/lib/pluto/updater.rb
CHANGED
@@ -22,6 +22,9 @@ class Updater
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def fetch_feed( url )
|
25
|
+
|
26
|
+
### fix: use worker.get( url ) # check http response code etc.
|
27
|
+
|
25
28
|
xml = worker.read( url )
|
26
29
|
|
27
30
|
###
|
@@ -42,60 +45,77 @@ class Updater
|
|
42
45
|
end
|
43
46
|
|
44
47
|
|
45
|
-
def parse_feed( xml )
|
46
|
-
parser = RSS::Parser.new( xml )
|
47
|
-
parser.do_validate = false
|
48
|
-
parser.ignore_unknown_element = true
|
49
|
-
|
50
|
-
puts "Parsing feed..."
|
51
|
-
feed = parser.parse
|
52
|
-
|
53
|
-
puts " feed.class=#{feed.class.name}"
|
54
|
-
feed
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
48
|
def update_subscriptions( config, opts={} )
|
59
49
|
|
60
50
|
## for now - use single site w/ key planet -- fix!! allow multiple sites (planets)
|
61
51
|
|
52
|
+
site_attribs = {
|
53
|
+
title: config[ 'title' ]
|
54
|
+
}
|
55
|
+
|
62
56
|
site_key = 'planet'
|
63
57
|
site_rec = Site.find_by_key( site_key )
|
64
58
|
if site_rec.nil?
|
65
|
-
site_rec
|
66
|
-
|
59
|
+
site_rec = Site.new
|
60
|
+
site_attribs[ :key ] = site_key
|
61
|
+
|
62
|
+
## use object_id: site.id and object_type: Site
|
63
|
+
## change - model/table/schema!!!
|
64
|
+
Action.create!( title: 'new site', object: site_attribs[ :title ] )
|
67
65
|
end
|
68
|
-
site_rec.
|
69
|
-
|
66
|
+
site_rec.update_attributes!( site_attribs )
|
67
|
+
|
68
|
+
# -- log update action
|
69
|
+
Action.create!( title: 'update subscriptions' )
|
70
70
|
|
71
71
|
|
72
72
|
config[ 'feeds' ].each do |feed_key|
|
73
73
|
|
74
74
|
feed_hash = config[ feed_key ]
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
|
76
|
+
feed_attribs = {
|
77
|
+
feed_url: feed_hash[ 'feed_url' ],
|
78
|
+
url: feed_hash[ 'url' ],
|
79
|
+
title: feed_hash[ 'title' ] # todo: use title from feed?
|
80
|
+
}
|
81
|
+
|
82
|
+
puts "Updating feed subscription >#{feed_key}< - >#{feed_attribs[:feed_url]}<..."
|
78
83
|
|
79
84
|
feed_rec = Feed.find_by_key( feed_key )
|
80
85
|
if feed_rec.nil?
|
81
|
-
feed_rec
|
82
|
-
|
86
|
+
feed_rec = Feed.new
|
87
|
+
feed_attribs[ :key ] = feed_key
|
88
|
+
|
89
|
+
## use object_id: feed.id and object_type: Feed
|
90
|
+
## change - model/table/schema!!!
|
91
|
+
## todo: add parent_action_id - why? why not?
|
92
|
+
Action.create!( title: 'new feed', object: feed_attribs[ :title ] )
|
83
93
|
end
|
84
|
-
|
85
|
-
feed_rec.
|
86
|
-
feed_rec.title = feed_hash[ 'title' ] # todo: use title from feed?
|
87
|
-
feed_rec.save!
|
94
|
+
|
95
|
+
feed_rec.update_attributes!( feed_attribs )
|
88
96
|
|
89
97
|
## todo:
|
90
98
|
# add subscription records (feed,site) - how?
|
91
99
|
end
|
92
100
|
|
93
101
|
end # method update_subscriptions
|
94
|
-
|
95
|
-
|
102
|
+
|
103
|
+
|
96
104
|
def update_feeds( opts={} )
|
97
105
|
|
98
|
-
|
106
|
+
### move to feedutils
|
107
|
+
### logger.debug "using stdlib RSS::VERSION #{RSS::VERSION}"
|
108
|
+
|
109
|
+
# -- log update action
|
110
|
+
Action.create!( title: 'update feeds' )
|
111
|
+
|
112
|
+
#####
|
113
|
+
# -- update fetched_at timestamps for all sites
|
114
|
+
feeds_fetched_at = Time.now
|
115
|
+
Site.all.each do |site|
|
116
|
+
site.fetched_at = feeds_fetched_at
|
117
|
+
site.save!
|
118
|
+
end
|
99
119
|
|
100
120
|
Feed.all.each do |feed_rec|
|
101
121
|
|
@@ -117,108 +137,64 @@ class Updater
|
|
117
137
|
|
118
138
|
puts "Before parsing feed >#{feed_key}<..."
|
119
139
|
|
120
|
-
|
140
|
+
## fix/todo: check for feed.nil? -> error parsing!!!
|
141
|
+
# or throw exception
|
142
|
+
feed = FeedUtils::Parser.parse( feed_xml )
|
121
143
|
|
122
|
-
|
123
|
-
puts "== #{feed.title.content} =="
|
124
|
-
else ## assume RSS::Rss::Feed
|
125
|
-
puts "== #{feed.channel.title} =="
|
126
|
-
end
|
144
|
+
feed_fetched_at = Time.now
|
127
145
|
|
128
|
-
|
129
|
-
if feed.class == RSS::Atom::Feed
|
130
|
-
item_attribs = handle_feed_item_atom( item )
|
131
|
-
else ## assume RSS::Rss::Feed
|
132
|
-
item_attribs = handle_feed_item_rss( item )
|
133
|
-
end
|
146
|
+
## todo/check: move feed_rec update to the end (after item updates??)
|
134
147
|
|
135
|
-
|
136
|
-
|
148
|
+
# update feed attribs e.g.
|
149
|
+
# generator
|
150
|
+
# published_at,built_at,touched_at,fetched_at
|
151
|
+
# summary,title2
|
152
|
+
feed_attribs = {
|
153
|
+
fetched_at: feed_fetched_at,
|
154
|
+
format: feed.format,
|
155
|
+
published_at: feed.published? ? feed.published : nil,
|
156
|
+
touched_at: feed.updated? ? feed.updated : nil,
|
157
|
+
built_at: feed.built? ? feed.built : nil,
|
158
|
+
summary: feed.summary? ? feed.summary : nil,
|
159
|
+
title2: feed.title2? ? feed.title2 : nil,
|
160
|
+
generator: feed.generator
|
161
|
+
}
|
137
162
|
|
138
|
-
|
139
|
-
if rec.nil?
|
140
|
-
rec = Item.new
|
141
|
-
puts "** NEW"
|
142
|
-
else
|
143
|
-
puts "UPDATE"
|
144
|
-
end
|
145
|
-
|
146
|
-
rec.update_attributes!( item_attribs )
|
147
|
-
end # each item
|
163
|
+
feed_rec.update_attributes!( feed_attribs )
|
148
164
|
|
149
|
-
end # each feed
|
150
|
-
|
151
|
-
end # method run
|
152
165
|
|
166
|
+
feed.items.each do |item|
|
153
167
|
|
154
|
-
def handle_feed_item_atom( item )
|
155
|
-
|
156
|
-
## todo: if content.content empty use summary for example
|
157
168
|
item_attribs = {
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
169
|
+
fetched_at: feed_fetched_at,
|
170
|
+
title: item.title,
|
171
|
+
url: item.url,
|
172
|
+
summary: item.summary? ? item.summary : nil,
|
173
|
+
content: item.content? ? item.content : nil,
|
174
|
+
published_at: item.published? ? item.published : nil,
|
175
|
+
touched_at: item.updated? ? item.updated : nil,
|
176
|
+
feed_id: feed_rec.id # add feed_id fk_ref
|
162
177
|
}
|
163
178
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
item_attribs[ :
|
179
|
+
rec = Item.find_by_guid( item.guid )
|
180
|
+
if rec.nil?
|
181
|
+
rec = Item.new
|
182
|
+
item_attribs[ :guid ] = item.guid
|
183
|
+
puts "** NEW | #{item.title}"
|
168
184
|
else
|
169
|
-
if
|
170
|
-
|
171
|
-
## strip all html tags
|
172
|
-
text = text.gsub( /<[^>]+>/, '' )
|
173
|
-
text = text[ 0..400 ] # get first 400 chars
|
174
|
-
## todo: check for length if > 400 add ... at the end???
|
175
|
-
item_attribs[ :content ] = text
|
176
|
-
end
|
185
|
+
## todo: check if any attribs changed
|
186
|
+
puts "UPDATE | #{item.title}"
|
177
187
|
end
|
178
188
|
|
179
|
-
|
180
|
-
|
181
|
-
puts " id (~guid) >#{item.id.content}<"
|
182
|
-
|
183
|
-
### todo: use/try published first? why? why not?
|
184
|
-
puts " updated (~pubDate) >#{item.updated.content}< >#{item.updated.content.utc.strftime( "%Y-%m-%d %H:%M" )}< : #{item.updated.content.class.name}"
|
185
|
-
puts
|
186
|
-
|
187
|
-
# puts "*** dump item:"
|
188
|
-
# pp item
|
189
|
-
|
190
|
-
item_attribs
|
191
|
-
end
|
189
|
+
rec.update_attributes!( item_attribs )
|
190
|
+
end # each item
|
192
191
|
|
193
|
-
|
192
|
+
end # each feed
|
194
193
|
|
195
|
-
|
196
|
-
title: item.title,
|
197
|
-
url: item.link,
|
198
|
-
published_at: item.pubDate.utc.strftime( "%Y-%m-%d %H:%M" ),
|
199
|
-
# content: item.content_encoded,
|
200
|
-
}
|
201
|
-
|
202
|
-
# if item.content_encoded.nil?
|
203
|
-
# puts " using description for content"
|
204
|
-
item_attribs[ :content ] = item.description
|
205
|
-
# end
|
206
|
-
|
207
|
-
item_attribs[ :guid ] = item.guid.content
|
208
|
-
|
209
|
-
puts "- #{item.title}"
|
210
|
-
puts " link (#{item.link})"
|
211
|
-
puts " guid (#{item.guid.content})"
|
212
|
-
puts " pubDate >#{item.pubDate}< >#{item.pubDate.utc.strftime( "%Y-%m-%d %H:%M" )}< : #{item.pubDate.class.name}"
|
213
|
-
puts
|
214
|
-
|
215
|
-
# puts "*** dump item:"
|
216
|
-
# pp item
|
217
|
-
|
218
|
-
item_attribs
|
219
|
-
end
|
194
|
+
end # method run
|
220
195
|
|
221
196
|
|
197
|
+
|
222
198
|
end # class Fetcher
|
223
199
|
|
224
200
|
end # module Pluto
|
data/lib/pluto/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pakman
|
16
|
-
requirement: &
|
16
|
+
requirement: &82365260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *82365260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: fetcher
|
27
|
-
requirement: &
|
27
|
+
requirement: &82364940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.3'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *82364940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: logutils
|
38
|
-
requirement: &
|
38
|
+
requirement: &82364710 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,54 @@ dependencies:
|
|
43
43
|
version: '0.6'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *82364710
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: feedutils
|
49
|
+
requirement: &82364390 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.3'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *82364390
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: props
|
60
|
+
requirement: &82364120 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.0.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *82364120
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: textutils
|
71
|
+
requirement: &82363830 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.6.8
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *82363830
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: gli
|
82
|
+
requirement: &82363570 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 2.5.6
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *82363570
|
47
91
|
- !ruby/object:Gem::Dependency
|
48
92
|
name: rdoc
|
49
|
-
requirement: &
|
93
|
+
requirement: &82363260 !ruby/object:Gem::Requirement
|
50
94
|
none: false
|
51
95
|
requirements:
|
52
96
|
- - ~>
|
@@ -54,10 +98,10 @@ dependencies:
|
|
54
98
|
version: '3.10'
|
55
99
|
type: :development
|
56
100
|
prerelease: false
|
57
|
-
version_requirements: *
|
101
|
+
version_requirements: *82363260
|
58
102
|
- !ruby/object:Gem::Dependency
|
59
103
|
name: hoe
|
60
|
-
requirement: &
|
104
|
+
requirement: &82362910 !ruby/object:Gem::Requirement
|
61
105
|
none: false
|
62
106
|
requirements:
|
63
107
|
- - ~>
|
@@ -65,7 +109,7 @@ dependencies:
|
|
65
109
|
version: '3.3'
|
66
110
|
type: :development
|
67
111
|
prerelease: false
|
68
|
-
version_requirements: *
|
112
|
+
version_requirements: *82362910
|
69
113
|
description: pluto - Another Planet Generator (Lets You Build Web Pages from Published
|
70
114
|
Web Feeds)
|
71
115
|
email: webslideshow@googlegroups.com
|
@@ -74,45 +118,33 @@ executables:
|
|
74
118
|
extensions: []
|
75
119
|
extra_rdoc_files:
|
76
120
|
- Manifest.txt
|
77
|
-
- templates/blank.txt
|
78
121
|
files:
|
79
|
-
- History.
|
122
|
+
- History.md
|
80
123
|
- Manifest.txt
|
81
|
-
- README.
|
124
|
+
- README.md
|
82
125
|
- Rakefile
|
83
126
|
- bin/pluto
|
127
|
+
- config/pluto.index.yml
|
84
128
|
- lib/pluto.rb
|
129
|
+
- lib/pluto/cli/main.rb
|
85
130
|
- lib/pluto/cli/opts.rb
|
86
|
-
- lib/pluto/cli/runner.rb
|
87
131
|
- lib/pluto/connecter.rb
|
88
132
|
- lib/pluto/fetcher.rb
|
89
133
|
- lib/pluto/formatter.rb
|
134
|
+
- lib/pluto/installer.rb
|
135
|
+
- lib/pluto/lister.rb
|
136
|
+
- lib/pluto/manifest_helpers.rb
|
90
137
|
- lib/pluto/models.rb
|
91
138
|
- lib/pluto/schema.rb
|
92
|
-
- lib/pluto/server.rb
|
93
|
-
- lib/pluto/server/public/feed-icon-10x10.png
|
94
|
-
- lib/pluto/server/public/style.css
|
95
|
-
- lib/pluto/server/views/_debug.erb
|
96
|
-
- lib/pluto/server/views/_version.erb
|
97
|
-
- lib/pluto/server/views/debug.erb
|
98
|
-
- lib/pluto/server/views/feeds.erb
|
99
|
-
- lib/pluto/server/views/index.erb
|
100
|
-
- lib/pluto/server/views/items.erb
|
101
|
-
- lib/pluto/server/views/layout.erb
|
102
|
-
- lib/pluto/server/views/sites.erb
|
103
139
|
- lib/pluto/updater.rb
|
104
140
|
- lib/pluto/version.rb
|
105
|
-
|
106
|
-
- templates/blank.top.html.erb
|
107
|
-
- templates/blank.txt
|
108
|
-
- templates/feed-icon-10x10.png
|
109
|
-
homepage: https://github.com/geraldb/pluto
|
141
|
+
homepage: https://github.com/feedreader/pluto
|
110
142
|
licenses:
|
111
143
|
- Public Domain
|
112
144
|
post_install_message:
|
113
145
|
rdoc_options:
|
114
146
|
- --main
|
115
|
-
- README.
|
147
|
+
- README.md
|
116
148
|
require_paths:
|
117
149
|
- lib
|
118
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|