From 8294dced6c51472390c13786ab4cace4bcf8c7d4 Mon Sep 17 00:00:00 2001
From: Alexander
Date: Wed, 18 Dec 2013 11:06:36 -0500
Subject: [PATCH] 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
---
app/views/list/list.rss.erb | 9 ++++-----
app/views/topics/show.rss.erb | 11 +++++------
config/routes.rb | 2 +-
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/app/views/list/list.rss.erb b/app/views/list/list.rss.erb
index a9c949c1498..eaf7c608bbb 100644
--- a/app/views/list/list.rss.erb
+++ b/app/views/list/list.rss.erb
@@ -2,22 +2,21 @@
<% lang = SiteSetting.find_by_name('default_locale').try(:value) %>
+ <% site_email = SiteSetting.find_by_name('contact_email').try(:value) %>
<%= @title %>
<%= @link %>
<%= @description %>
- <% if lang %>
- <%= lang %>
- <% end %>
+ <%= "#{lang}" if lang %>
<%= @topic_list.topics.first.created_at.rfc2822 %>
<% @topic_list.topics.each do |topic| %>
<% topic_url = Discourse.base_url + topic.relative_url -%>
-
<%= topic.title %>
- <%= "@#{topic.user.username} (#{topic.user.name})" -%>
+ <%= "#{site_email} (@#{topic.user.username}#{" #{topic.user.name}" if topic.user.name.present?})" -%>
<%= topic.category.name %>
<%= t('author_wrote', author: link_to(topic.user.name, topic.user)).html_safe %>
+ <%= t('author_wrote', author: link_to(topic.user.name, userpage_url(topic.user))).html_safe %>
<%= topic.posts.first.cooked.html_safe %>
diff --git a/app/views/topics/show.rss.erb b/app/views/topics/show.rss.erb
index 85d1e2e5750..61be3b86ada 100644
--- a/app/views/topics/show.rss.erb
+++ b/app/views/topics/show.rss.erb
@@ -3,23 +3,22 @@
<% topic_url = Discourse.base_url + @topic_view.relative_url %>
<% lang = SiteSetting.find_by_name('default_locale').try(:value) %>
+ <% site_email = SiteSetting.find_by_name('contact_email').try(:value) %>
<%= @topic_view.title %>
<%= topic_url %>
<%= @topic_view.posts.first.raw %>
- <% if lang %>
- <%= lang %>
- <% end %>
+ <%= "#{lang}" if lang %>
<%= @topic_view.topic.created_at.rfc2822 %>
<%= @topic_view.topic.category.name %>
<% @topic_view.recent_posts.each do |post| %>
<% next unless post.user %>
-
- <%= @topic_view.title %> at <%= post.created_at %>
- <%= "@#{post.user.username} (#{post.user.name})" -%>
+ <%= @topic_view.title %>
+ <%= "#{site_email} (@#{post.user.username}#{" #{post.user.name}" if post.user.name.present?})" -%>
-
<%= t('author_wrote', author: link_to(post.user.name, post.user)).html_safe %>
+ <%= t('author_wrote', author: link_to(post.user.name, userpage_url(post.user))).html_safe %>
<%= post.cooked.html_safe %>
diff --git a/config/routes.rb b/config/routes.rb
index d91aa179362..36fb3dbcf24 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -140,7 +140,7 @@ Discourse::Application.routes.draw do
get 'user_preferences' => 'users#user_preferences_redirect'
get 'users/:username/private-messages' => 'user_actions#private_messages', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/private-messages/:filter' => 'user_actions#private_messages', constraints: {username: USERNAME_ROUTE_FORMAT}
- get 'users/:username' => 'users#show', constraints: {username: USERNAME_ROUTE_FORMAT}
+ get 'users/:username' => 'users#show', as: 'userpage', constraints: {username: USERNAME_ROUTE_FORMAT}
put 'users/:username' => 'users#update', constraints: {username: USERNAME_ROUTE_FORMAT}
get 'users/:username/preferences' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}, as: :email_preferences
get 'users/:username/preferences/email' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}