diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 0f59a2b9f..97036688e 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -4,7 +4,7 @@ class CommentsController < ApplicationController
skip_before_filter :api_check
def index
- if params[:group_by] == "comment"
+ if params[:group_by] == "comment" || request.format == Mime::ATOM
index_by_comment
elsif request.format == Mime::JS
index_for_post
@@ -92,6 +92,10 @@ private
@comments = Comment.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
respond_with(@comments) do |format|
format.html {render :action => "index_by_comment"}
+ format.atom do
+ @comments = @comments.includes(:post, :creator).load
+ render :action => "index"
+ end
format.xml do
render :xml => @comments.to_xml(:root => "comments")
end
diff --git a/app/views/comments/index.atom.builder b/app/views/comments/index.atom.builder
new file mode 100644
index 000000000..0c0396626
--- /dev/null
+++ b/app/views/comments/index.atom.builder
@@ -0,0 +1,24 @@
+atom_feed do |feed|
+ title = "Comments"
+ title += " by #{params[:search][:creator_name]}" if params.dig(:search, :creator_name).present?
+ title += " on #{params[:search][:post_tags_match]}" if params.dig(:search, :post_tags_match).present?
+
+ feed.title(title)
+ feed.updated(@comments.first.try(:updated_at))
+
+ @comments.each do |comment|
+ feed.entry(comment, published: comment.created_at, updated: comment.updated_at) do |entry|
+ entry.title("@#{comment.creator_name} on post ##{comment.post_id} (#{comment.post.humanized_essential_tag_string})")
+ entry.content(<<-EOS.strip_heredoc, type: "html")
+
+
+ #{format_text(comment.body)}
+ EOS
+
+ entry.author do |author|
+ author.name(comment.creator_name)
+ author.uri(user_url(comment.creator))
+ end
+ end
+ end
+end
diff --git a/app/views/comments/index_by_comment.html.erb b/app/views/comments/index_by_comment.html.erb
index fbe15cf40..99844b99f 100644
--- a/app/views/comments/index_by_comment.html.erb
+++ b/app/views/comments/index_by_comment.html.erb
@@ -29,3 +29,5 @@
<% content_for(:page_title) do %>
Comments - <%= Danbooru.config.app_name %>
<% end %>
+
+<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: params[:search]), title: "Comments")) %>
diff --git a/app/views/comments/index_by_post.html.erb b/app/views/comments/index_by_post.html.erb
index d49f4c54f..3a496249b 100644
--- a/app/views/comments/index_by_post.html.erb
+++ b/app/views/comments/index_by_post.html.erb
@@ -37,3 +37,5 @@
<% content_for(:page_title) do %>
Comments - <%= Danbooru.config.app_name %>
<% end %>
+
+<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: { do_not_bump_post: true }), title: "Comments")) %>
diff --git a/app/views/static/site_map.html.erb b/app/views/static/site_map.html.erb
index a67fd8ee1..0d176526f 100644
--- a/app/views/static/site_map.html.erb
+++ b/app/views/static/site_map.html.erb
@@ -73,6 +73,7 @@