Changesets can be listed by changeset number.
The Git repository is here.
Changeset 66
Updated version of the News behavior that removes the simple-rss
dependency by using core RSS instead and now handles SlashDot on
Textile filtered pages by escaping "~" characters in URLs.
- Comitted by: adh
- Date: Monday August 07 14:34:54 2006 (over 18 years ago)
Affected files:
rool/rails/radiant/trunk/app/behaviors/news_behavior.rb:
prev. | current | |
# ------- | ||
# | ||
# 2006-08-06 (ADH): Created. | ||
11 | # 2006-08-07 (ADH): It seems the core RSS features are easily sufficient | |
12 | # so fun though Simple-RSS was, it makes sense to use | |
13 | # something that doesn't add extra dependencies. Moved | |
14 | # over to the Ruby RSS parser. Since tags get expanded | |
15 | # before filters run, but there is no way to escape | |
16 | # text filtered by (say) Textile, instead get rid of | |
17 | # characters known to be a problem. | |
12 | ||
13 | ||
19 | require 'rss' | |
class TagError < StandardError; end | ||
... | ... | |
defaults to '4'. The 'dates' attribute is optional; it says whether | ||
or not article dates (if found) will be added in small text after | ||
each headline. If '0' there are no dates, else dates are shown. The | ||
29 | | |
30 | | |
31 | | |
35 | default value is '1', to show dates. Dates are extracted from the | |
36 | feed's "pubDate", "modified" or "dc_date" fields, in that order. | |
Example: <r:news feed="http://my.url/news.xml" headlines="4" dates="0" /> | ||
} | ||
... | ... | |
# Fetch the feed and parse it. | ||
65 | | |
70 | rss = RSS::Parser.parse(feed) | |
done = 0 | ||
out = "<ul>\n" | ||
... | ... | |
out << ' <li>' | ||
unless (item.link.nil? or item.link.empty?) | ||
88 | | |
93 | link = item.link.dup | |
94 | link.gsub!(/\~/, '%7E') | |
95 | out << "<a href=\"#{link}\">#{item.title}</a>" | |
else | ||
out << "#{item.title}" | ||
end | ||
93 | | |
100 | time = nil | |
101 | ||
102 | if item.respond_to?(:pubDate) | |
103 | # Typo blogs, The Register | |
time = item.pubDate | ||
95 | | |
105 | elsif item.respond_to?(:modified) | |
106 | # RForum installations, generic | |
time = item.modified | ||
108 | elsif item.respond_to?(:dc_date) | |
109 | # SlashDot | |
110 | time = item.dc_date | |
end | ||
99 | | |
113 | out << time.strftime(' <small>(%d-%b-%Y)</small>') if (time.class == Time and dates != 0) | |
out << "</li>\n" | ||
end | ||