Commit 992e5256
Changed files (3)
app
controllers
views
sitemap
config
app/controllers/sitemap_controller.rb
@@ -10,4 +10,12 @@ class SitemapController < ApplicationController
format.xml
end
end
+
+ def comments
+ headers['Content-Type'] = 'application/xml'
+ @comments = Comment.all
+ respond_to do |format|
+ format.xml
+ end
+ end
end
app/views/sitemap/comments.xml.erb
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dsq="http://www.disqus.com/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.0/">
+ <channel>
+ <% @comments.each do |comment| %>
+ <item>
+ <!-- title of article -->
+ <title><%= comment.commentable.name %></title>
+ <!-- absolute URI to article -->
+ <link>http://cakeside.com/creations/<%= comment.commentable.to_param %></link>
+ <!-- body of the page or post; use cdata; html allowed (though will be formatted to DISQUS specs) -->
+ <content:encoded><![CDATA[<%= comment.commentable.story %>]]></content:encoded>
+ <!-- value used within disqus_identifier; usually internal identifier of article -->
+ <dsq:thread_identifier>c-<%= comment.commentable.id %></dsq:thread_identifier>
+ <!-- creation date of thread (article), in GMT. Must be YYYY-MM-DD HH:MM:SS 24-hour format. -->
+ <wp:post_date_gmt><%= comment.commentable.created_at %></wp:post_date_gmt>
+ <!-- open/closed values are acceptable -->
+ <wp:comment_status>open</wp:comment_status>
+ <wp:comment>
+ <!-- sso only; see docs -->
+ <dsq:remote>
+ <!-- unique internal identifier; username, user id, etc. -->
+ <dsq:id><%= comment.user.id %></dsq:id>
+ <!-- avatar -->
+ <dsq:avatar><%= "https://secure.gravatar.com/avatar/#{Digest::MD5::hexdigest(comment.user.email.downcase)}?s=260&d=mm" %></dsq:avatar>
+ </dsq:remote>
+ <!-- internal id of comment -->
+ <wp:comment_id><%= comment.id %></wp:comment_id>
+ <!-- author display name -->
+ <wp:comment_author><%= comment.user.name %></wp:comment_author>
+ <!-- author email address -->
+ <wp:comment_author_email><%= comment.user.email %></wp:comment_author_email>
+ <!-- author url, optional -->
+ <wp:comment_author_url>http://www.cakeside.com/profiles/<%= comment.user.to_param %></wp:comment_author_url>
+ <!-- author ip address -->
+ <wp:comment_author_IP><%= comment.user.last_sign_in_ip %></wp:comment_author_IP>
+ <!-- comment datetime, in GMT. Must be YYYY-MM-DD HH:MM:SS 24-hour format. -->
+ <wp:comment_date_gmt><%= comment.created_at %></wp:comment_date_gmt>
+ <!-- comment body; use cdata; html allowed (though will be formatted to DISQUS specs) -->
+ <wp:comment_content><![CDATA[<%= comment.body %>]]></wp:comment_content>
+ <!-- is this comment approved? 0/1 -->
+ <wp:comment_approved>1</wp:comment_approved>
+ <!-- parent id (match up with wp:comment_id) -->
+ <wp:comment_parent>0</wp:comment_parent>
+ </wp:comment>
+ </item>
+ <% end %>
+ </channel>
+</rss>
config/routes.rb
@@ -44,6 +44,7 @@ Cake::Application.routes.draw do
# sitemap
match "/sitemap.xml", :to => "sitemap#index", :defaults => {:format => :xml}
+ match "/comments.xml", :to => "sitemap#comments", :defaults => {:format => :xml}
resources :settings, :only => [:index, :update]
resources :passwords, :only => [:index, :update]