journalduhacker/app/views/home/rss.erb
joshua stein 9f5e04bbba use _path for most things instead of _url
Instead of hard-coding the scheme and host everywhere, use _path
methods to show relative URLs.

Except that our previous setting of
Rails.application.routes.default_url_options in
config.after_initialize made this moot because Rails inserts that
host into all _path helpers for some reason.  So revert that
setting.

But then anything that wants an absolute URL doesn't know the
hostname and the root_url helper throws an exception.  So make a
Rails.application.root_url shortcut to pass the per-app settings in
Rails.application to root_url.

Now we can just use _path helpers most places but still use _url
ones where we need them, such as in RSS views and e-mail templates.
2015-01-02 17:02:55 -06:00

32 lines
1.2 KiB
Plaintext

<?xml version="1.0" encoding="UTF-8" ?>
<% coder = HTMLEntities.new %>
<rss version="2.0">
<channel>
<title><%= Rails.application.name %><%= @title.present? ?
": " + h(@title) : "" %></title>
<description><%= @title %></description>
<link><%= Rails.application.root_url + (@newest ? "newest" : "") %></link>
<% @stories.each do |story| %>
<item>
<title><%= raw coder.encode(story.title, :decimal) %></title>
<link><%= story.url_or_comments_url %></link>
<guid isPermaLink="false"><%= story.short_id_url %></guid>
<author><%= story.user.username %></author>
<pubDate><%= story.created_at.rfc2822 %></pubDate>
<comments><%= story.comments_url %></comments>
<description>
<%= raw coder.encode(story.markeddown_description, :decimal) %>
<% if story.url.present? %>
<%= raw coder.encode("<p>" +
link_to("Comments", story.comments_url) + "</p>", :decimal) %>
<% end %>
</description>
<% story.taggings.each do |tagging| %>
<category><%= tagging.tag.tag %></category>
<% end %>
</item>
<% end %>
</channel>
</rss>