Skip to content

Commit 1686e32

Browse files
author
Steven Heidel
committed
Added RSS feed to tutorials site.
1 parent d8647f9 commit 1686e32

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
xml.instruct! :xml, :version => "1.0"
2+
xml.rss :version => "2.0", "xmlns:atom" => "http://www.w3.org/2005/Atom" do
3+
xml.channel do
4+
# Required to pass W3C validation.
5+
xml.atom :link, nil, {
6+
:href => tutorials_url(:format => 'rss'),
7+
:rel => 'self', :type => 'application/rss+xml'
8+
}
9+
10+
# Feed basics.
11+
xml.title page_title
12+
xml.description @page[:body].to_s.gsub(/<\/?[^>]*>/, "") # .to_s protects from nil errors
13+
xml.link tutorials_url(:format => 'rss')
14+
15+
# News items.
16+
@tutorials.each do |tutorial|
17+
xml.item do
18+
xml.title tutorial.title
19+
xml.link tutorial_url(tutorial)
20+
xml.description truncate(tutorial.content, :length => 200, :preserve_html_tags => true)
21+
xml.pubDate tutorial.updated_at.to_s(:rfc822)
22+
xml.guid tutorial_url(tutorial)
23+
end
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)