Changesets can be listed by changeset number.
The Git repository is here.
Changeset 141
Added new attribute "escaped", which indicates that '%xx' hex sequence
escaping has already been carried out on links in the source feed so
should not be done internally. The I2 feeds have this, so were failing
when escaped characters appeared. Fixes Ticket #88.
- Comitted by: adh
- Date: Thursday November 09 19:10:02 2006 (over 18 years ago)
Affected files:
rool/rails/radiant/trunk/app/behaviors/news_behavior.rb:
prev. | current | |
# can be used if a more flexible scheme is required at | ||
# the expense of more effort and less clean handling of | ||
# empty RSS item fields. | ||
29 | # 2006-11-09 (ADH): Added 'escaped' attribute to deal with feeds which | |
30 | # have already had "%xx" hex escape sequences applied | |
31 | # in URIs, as well as feeds that have not. | |
require 'rss' | ||
... | ... | |
fully qualified URL pointing to an XML RSS feed. The feed is | ||
parsed and the 'latest news' summary generated from it. The URL | ||
is given in the mandatory 'feed' attribute within the tag. | ||
42 | ||
45 | ||
The 'headlines' attribute is optional; it defines how many entries | ||
will be included in the news summary and defaults to '4'. | ||
45 | ||
48 | ||
The 'dates' attribute is also optional; it says whether or not | ||
article published or modified dates (if found) will be added in | ||
small text after each headline. If '0' there are no dates, else | ||
dates are shown. The default value is '1', to show dates. Dates are | ||
extracted from the feed's "pubDate", "modified" or "dc_date" fields, | ||
in that order. | ||
52 | ||
55 | ||
56 | The optional 'https' attribute defaults to '0'. If '1', HTTP URLs | |
57 | are upgraded to HTTPS if @request.ssl? is true, else they are left | |
58 | alone. Note, requires "@request" to be available to this Behavior. | |
59 | ||
60 | The optional 'escaped' attribute (not to be confused with 'escape', | |
61 | below!) states whether or not the feed URIs themselves are already | |
62 | escaped for including in links (i.e. there is use of "%xx" escape | |
63 | sequences where "xx" is a two digit hex number). Defaults to zero; | |
64 | URI.escape() will be run on the links. If set to a non-zero value, | |
65 | URI.escape() will not be called though "~" characters will still | |
66 | be substituted with '%7E'. | |
67 | ||
Finally, an optional 'escape' attribute, defaulting to '1', ensures | ||
that RSS titles or links cannot be accidentally interpreted as | ||
Textile data for Textile filtered parts. Setting the attribute to | ||
'0' disables escaping to allow headlines marked up in Textile to be | ||
passed through to the Textile parser. | ||
58 | ||
73 | ||
Note that '<' and '>' characters in RSS item titles will always be | ||
60 | | |
61 | | |
62 | | |
63 | ||
75 | escaped to HTML entities for security. | |
76 | ||
Example of use: | ||
65 | ||
78 | ||
<r:news feed="http://my.url/news.xml" headlines="4" dates="0" /> | ||
} | ||
... | ... | |
define_tags do | ||
94 | | |
107 | # Syntax: | |
# | ||
96 | | |
97 | | |
98 | | |
99 | | |
109 | # <r:news feed="feed_url" [headlines="number"] [dates="0|1"] [escaped="0|1"] [escape="0|1"] /> | |
# | ||
101 | | |
102 | | |
111 | # See 'description' towards the top of this file for more details. | |
# | ||
104 | | |
105 | | |
106 | | |
107 | | |
108 | | |
109 | | |
110 | | |
111 | | |
112 | | |
113 | | |
114 | | |
115 | | |
116 | | |
117 | | |
118 | | |
119 | | |
120 | | |
121 | | |
122 | | |
123 | | |
124 | | |
125 | | |
126 | | |
127 | | |
128 | | |
129 | | |
tag 'news' do |tag| | ||
feed = tag.attr['feed'] | ||
dates = (tag.attr['dates'] || '1').to_i | ||
to_https = (tag.attr['https'] || '0').to_i | ||
escape = (tag.attr['escape'] || '1').to_i | ||
118 | escaped = (tag.attr['escaped'] || '0').to_i | |
headlines = (tag.attr['headlines'] || '4').to_i | ||
raise TagError.new("No feed URL given in `news' tag") if (feed.nil? or feed.empty?) | ||
... | ... | |
link = uri.to_s | ||
end | ||
197 | | |
181 | link = URI.escape(link) if (escaped == 0) | |
link.gsub!(/\~/, '%7E') | ||
out << "<a href=\"#{link}\">#{title}</a>" | ||
else |