diff --git a/app/controllers/legacy_controller.rb b/app/controllers/legacy_controller.rb index 385080220..8a17ff46a 100644 --- a/app/controllers/legacy_controller.rb +++ b/app/controllers/legacy_controller.rb @@ -1,9 +1,21 @@ class LegacyController < ApplicationController before_filter :member_only, :only => [:create_post] + respond_to :json, :xml def posts @post_set = PostSets::Post.new(tag_query, params[:page], params[:limit], format: "json") - @posts = @post_set.posts + @posts = @post_set.posts.map(&:legacy_attributes) + + respond_with(@posts) do |format| + format.xml do + xml = Builder::XmlMarkup.new(indent: 2) + xml.instruct! + xml.posts do + @posts.each { |attrs| xml.post(attrs) } + end + render xml: xml.target! + end + end end def create_post diff --git a/app/models/post.rb b/app/models/post.rb index 34c769f39..0259afec8 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1548,7 +1548,7 @@ class Post < ApplicationRecord super(options) end - def to_legacy_json + def legacy_attributes hash = { "has_comments" => last_commented_at.present?, "parent_id" => parent_id, @@ -1574,7 +1574,7 @@ class Post < ApplicationRecord hash["md5"] = md5 end - hash.to_json + hash end def status diff --git a/app/views/legacy/posts.json.erb b/app/views/legacy/posts.json.erb deleted file mode 100644 index 182aacf3d..000000000 --- a/app/views/legacy/posts.json.erb +++ /dev/null @@ -1 +0,0 @@ -[<%= @posts.map {|x| x.to_legacy_json}.join(", ").html_safe %>] diff --git a/app/views/legacy/posts.xml.erb b/app/views/legacy/posts.xml.erb deleted file mode 100644 index 2a5d2a223..000000000 --- a/app/views/legacy/posts.xml.erb +++ /dev/null @@ -1,6 +0,0 @@ - - - <% @posts.each do |post| %> - - <% end %> -