added xml response to the post
This commit is contained in:
parent
bdc4b9f746
commit
a32ef3c1d8
4 changed files with 25 additions and 13 deletions
|
|
@ -12,6 +12,9 @@ class PublicsController < ApplicationController
|
|||
skip_before_filter :set_grammatical_gender
|
||||
before_filter :allow_cross_origin, :only => [:hcard, :host_meta, :webfinger]
|
||||
|
||||
respond_to :html
|
||||
respond_to :xml, :only => :post
|
||||
|
||||
def allow_cross_origin
|
||||
headers["Access-Control-Allow-Origin"] = "*"
|
||||
end
|
||||
|
|
@ -77,17 +80,20 @@ class PublicsController < ApplicationController
|
|||
if @post
|
||||
if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
|
||||
redirect_to post_path(@post)
|
||||
return
|
||||
end
|
||||
|
||||
@landing_page = true
|
||||
@person = @post.author
|
||||
if @person.owner_id
|
||||
I18n.locale = @person.owner.language
|
||||
render "#{@post.class.to_s.underscore}", :layout => 'application'
|
||||
else
|
||||
flash[:error] = I18n.t('posts.show.not_found')
|
||||
redirect_to root_url
|
||||
@landing_page = true
|
||||
@person = @post.author
|
||||
if @person.owner_id
|
||||
I18n.locale = @person.owner.language
|
||||
|
||||
respond_to do |format|
|
||||
format.all{ render "#{@post.class.to_s.underscore}", :layout => 'application'}
|
||||
format.xml{ render :xml => @post.to_diaspora_xml }
|
||||
end
|
||||
else
|
||||
flash[:error] = I18n.t('posts.show.not_found')
|
||||
redirect_to root_url
|
||||
end
|
||||
end
|
||||
else
|
||||
flash[:error] = I18n.t('posts.show.not_found')
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Reshare < Post
|
|||
root_author.save!
|
||||
|
||||
unless self.root = Post.where(:guid => @root_guid).first
|
||||
self.root = Diaspora::Parser.from_xml(Faraday.get(root_author.url + "/p/#{@root_guid}").body)
|
||||
self.root = Diaspora::Parser.from_xml(Faraday.get(root_author.url + "/p/#{@root_guid}.xml").body)
|
||||
self.root.save!
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@ describe PublicsController do
|
|||
response.should be_redirect
|
||||
end
|
||||
|
||||
it 'responds with diaspora xml if format is xml' do
|
||||
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
|
||||
get :post, :guid => status.guid, :format => :xml
|
||||
response.body.should == status.to_diaspora_xml
|
||||
end
|
||||
|
||||
# We want to be using guids from now on for this post route, but do not want to break
|
||||
# preexisiting permalinks. We can assume a guid is 8 characters long as we have
|
||||
# guids set to hex(8) since we started using them.
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ describe Reshare do
|
|||
it 'fetches the root post from root_guid' do
|
||||
response = mock
|
||||
response.stub(:body).and_return(@root_object.to_diaspora_xml)
|
||||
Faraday.default_connection.should_receive(:get).with(@reshare.root.author.url + public_post_path(:guid => @root_object.guid)).and_return(response)
|
||||
Faraday.default_connection.should_receive(:get).with(@reshare.root.author.url + public_post_path(:guid => @root_object.guid, :format => "xml")).and_return(response)
|
||||
|
||||
root = Reshare.from_xml(@xml).root
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ describe Reshare do
|
|||
response = mock
|
||||
response.stub(:body).and_return(@root_object.to_diaspora_xml)
|
||||
|
||||
Faraday.default_connection.should_receive(:get).with(@original_author.url + public_post_path(:guid => @root_object.guid)).and_return(response)
|
||||
Faraday.default_connection.should_receive(:get).with(@original_author.url + public_post_path(:guid => @root_object.guid, :format => "xml")).and_return(response)
|
||||
|
||||
Reshare.from_xml(@xml)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue