rfeedreader 0.9.11 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.9.13 2007-09-14
2
+
3
+ * Add new Youtube entry with thumbnail displayed
4
+
5
+ == 0.9.12 2007-09-08
6
+
7
+ * Add method to request page with knowing it's a feed
8
+ * change timeout delays
9
+
1
10
  == 0.9.11 2007-09-08
2
11
 
3
12
  * Add timeout on http request
data/lib/rfeedreader.rb CHANGED
@@ -131,6 +131,8 @@ module Rfeedreader
131
131
  @entries<<Entry_Jumpcut.new(item, self.charset)
132
132
  when "source_picasa"
133
133
  @entries<<Entry_Picasa.new(item, self.charset)
134
+ when "source_youtube"
135
+ @entries<<Entry_Youtube.new(item, self.charset)
134
136
  else
135
137
  @entries<<Entry.new(item, self.charset)
136
138
  end
@@ -182,6 +184,7 @@ module Rfeedreader
182
184
  return "source_google_video" if @feed_url =~ /http:\/\/video\.google\.com/
183
185
  return "source_jumpcut" if @feed_url =~ /http:\/\/rss\.jumpcut\.com/
184
186
  return "source_picasa" if @feed_url =~ /http:\/\/picasaweb\.google\.com/
187
+ return "source_youtube" if @feed_url =~ /http:\/\/www\.youtube\.com\/rss\//
185
188
  return ""
186
189
  end
187
190
  end
@@ -217,7 +220,6 @@ module Rfeedreader
217
220
  @description = (@hpricot_item/"description|summary|[@type='text']").text if @description.empty?
218
221
 
219
222
  unless @description.empty?
220
-
221
223
  @description = TextyHelper.clean(@description, 200)
222
224
 
223
225
  @description = HTMLEntities.encode_entities(@description, :named, :decimal)
@@ -275,14 +277,24 @@ module Rfeedreader
275
277
  end
276
278
  end
277
279
 
280
+ class Entry_Youtube<Entry
281
+ def read_description
282
+ image = @hpricot_item.search("media:thumbnail").to_s.scan(/url=['"]?([^'"]*)['" ]/).to_s
283
+ @description = "<a href='#{@link}' class='image_link'><img src='#{image}' class='youtube_image'/></a>"
284
+ end
285
+ end
286
+
278
287
  def read(uri, nb_posts=10, parse_entries=true)
279
- uri = HTMLEntities.decode_entities(uri)
280
- link = Rfeedfinder::feed(uri)
281
- unless link.nil?
282
- doc = open_doc(link)
283
-
288
+ link = Rfeedfinder::feed(HTMLEntities.decode_entities(uri))
289
+ read_feed(link, nb_posts, parse_entries)
290
+ end
291
+
292
+ def read_feed(uri, nb_posts=10, parse_entries=true)
293
+ unless uri.nil?
294
+ doc = open_doc(uri)
295
+
284
296
  unless doc.nil?
285
- feed = Feed.new(link, doc)
297
+ feed = Feed.new(uri, doc)
286
298
  feed.parse_entries(doc, nb_posts) if parse_entries == true
287
299
  end
288
300
  end
@@ -293,14 +305,23 @@ module Rfeedreader
293
305
  return read(uri, nb_post=1)
294
306
  end
295
307
 
308
+ def read_feed_first(uri)
309
+ return read(uri, nb_post=1, is_feed=true)
310
+ end
311
+
296
312
  def read_header(uri)
297
313
  return read(uri, parse_entries=false)
298
314
  end
315
+
316
+ def read_feed_header(uri)
317
+ return read_feed(uri, parse_entries=false)
318
+ end
299
319
 
300
320
  def open_doc(link)
301
321
  data = nil
322
+ delay = 30
302
323
  begin
303
- Timeout::timeout(20) {
324
+ Timeout::timeout(delay) {
304
325
  data = Hpricot(open(link,
305
326
  "User-Agent" => "Ruby/#{RUBY_VERSION} - Rfeedfinder",
306
327
  "From" => "rfeedfinder@googlegroups.com",
@@ -308,7 +329,7 @@ module Rfeedreader
308
329
  }
309
330
  rescue OpenURI::HTTPError
310
331
  begin
311
- Timeout::timeout(20) {
332
+ Timeout::timeout(delay) {
312
333
  html = Net::HTTP.get(URI.parse(link))
313
334
  data = Hpricot(html, :xml => true) if html.to_s !~ /404 Not Found/
314
335
  }
@@ -2,7 +2,7 @@ module Rfeedreader #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 11
5
+ TINY = 13
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -56,7 +56,6 @@ class TestRfeedreader < Test::Unit::TestCase
56
56
  read_first "http://rss.slashdot.org/Slashdot/slashdot"
57
57
  read_first "http://planeta.lamatriz.org/feed/"
58
58
  read_first "http://edubloggers.blogspot.com/"
59
- read_first "http://www.deugarte.com/feed/"
60
59
  read_first "http://www.twitter.com/alx/"
61
60
  read_first "http://alemama.blogspot.com"
62
61
  read_first "http://seedmagazine.com/news/atom-focus.xml"
@@ -129,4 +128,21 @@ class TestRfeedreader < Test::Unit::TestCase
129
128
  def test_read_picasa
130
129
  read_first "http://picasaweb.google.com/data/feed/base/user/christine.klassen?category=album&alt=rss&hl=en_GB&access=public"
131
130
  end
131
+
132
+ def test_read_youtube
133
+ read_first "http://www.youtube.com/rss/user/bideoakinfo/videos.rss"
134
+ end
135
+
136
+ def test_read_deugarte
137
+ read_first "http://www.deugarte.com/feed"
138
+ end
139
+
140
+ def test_read_feed
141
+ feed_url = "http://www.ambidextrousmag.org/blog/?feed=rss2"
142
+ puts "Read first from #{feed_url}"
143
+ feed = Rfeedreader.read_feed_first feed_url
144
+ assert_not_nil feed
145
+ assert_equal 1, feed.entries.size
146
+ feed.display_entries
147
+ end
132
148
  end
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>rfeedreader</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rfeedreader"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/rfeedreader" class="numbers">0.9.11</a>
36
+ <a href="http://rubyforge.org/projects/rfeedreader" class="numbers">0.9.13</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rfeedreader
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.11
7
- date: 2007-09-08 00:00:00 +02:00
6
+ version: 0.9.13
7
+ date: 2007-09-14 00:00:00 +02:00
8
8
  summary: Feed parser to read feed and return first posts of this feed. Special parsing from sources like Flickr, Jumcut, Google video, ...
9
9
  require_paths:
10
10
  - lib