tweak RSS elements for W3C compatibility

installation needs to have contact_email set in the admin settings in
order for that installation to have truly valid feeds
This commit is contained in:
Alexander
2013-12-18 11:06:36 -05:00
parent 14d21ec865
commit 8294dced6c
3 changed files with 10 additions and 12 deletions

View File

@@ -2,22 +2,21 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<% lang = SiteSetting.find_by_name('default_locale').try(:value) %>
<% site_email = SiteSetting.find_by_name('contact_email').try(:value) %>
<title><%= @title %></title>
<link><%= @link %></link>
<description><%= @description %></description>
<% if lang %>
<language><%= lang %></language>
<% end %>
<%= "<language>#{lang}</language>" if lang %>
<lastBuildDate><%= @topic_list.topics.first.created_at.rfc2822 %></lastBuildDate>
<atom:link href="<%= @atom_link %>" rel="self" type="application/rss+xml" />
<% @topic_list.topics.each do |topic| %>
<% topic_url = Discourse.base_url + topic.relative_url -%>
<item>
<title><%= topic.title %></title>
<author><%= "@#{topic.user.username} (#{topic.user.name})" -%></author>
<author><%= "#{site_email} (@#{topic.user.username}#{" #{topic.user.name}" if topic.user.name.present?})" -%></author>
<category><%= topic.category.name %></category>
<description><![CDATA[
<p><%= t('author_wrote', author: link_to(topic.user.name, topic.user)).html_safe %></p>
<p><%= t('author_wrote', author: link_to(topic.user.name, userpage_url(topic.user))).html_safe %></p>
<blockquote>
<%= topic.posts.first.cooked.html_safe %>
</blockquote>