22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/twitterize.rb', line 22
def Item.(feed, , shorturl)
item = Item.find(:first, :conditions => ["guid = ? and feed_id = ?", .guid, feed.id])
if item.nil? then
tinyurl = WWW::ShortURL.shorten(.link, shorturl)
html_decoder = HTMLEntities.new
max_title_len = MAX_TWITTER_CHARS - (tinyurl.size + 4)
title = html_decoder.decode .title
= title[0, max_title_len]
+= "..." if .size == max_title_len
+= " " + tinyurl
item = Item.new
item.link = .link
item.guid = .guid
item.title = title
item.published_at = .published
item. =
item.posted = 0
feed.items << item
item.save
item
else
nil
end
end
|