Commit 23d3d9dc authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff

Use post page title for atom feeds and add entry author

Fixes #7249

closes #7420
parent 6dc44936
......@@ -5,6 +5,7 @@
## Bug fixes
* Make photo upload button hover text translatable [#7429](https://github.com/diaspora/diaspora/pull/7429)
* Fix first comment in mobile view with french locale [#7441](https://github.com/diaspora/diaspora/pull/7441)
* Use post page title and post author in atom feed [#7420](https://github.com/diaspora/diaspora/pull/7420)
## Features
......
module ActivityStreamsHelper
def add_activitystreams_author(target, person)
target.author do |author|
author.name person.name
author.uri local_or_remote_person_path(person, absolute: true)
author.tag! "activity:object-type", "http://activitystrea.ms/schema/1.0/person"
author.tag! "poco:preferredUsername", person.username
author.tag! "poco:displayName", person.name
end
end
end
......@@ -17,21 +17,16 @@ atom_feed("xmlns:thr" => "http://purl.org/syndication/thread/1.0",
'media:height' => '100', :href => "#{@user.image_url}"
feed.tag! :link, :href => "#{AppConfig.environment.pubsub_server}", :rel => 'hub'
feed.author do |author|
author.name @user.name
author.uri local_or_remote_person_path(@user.person, :absolute => true)
author.tag! 'activity:object-type', 'http://activitystrea.ms/schema/1.0/person'
author.tag! 'poco:preferredUsername', @user.username
author.tag! 'poco:displayName', @user.name
end
add_activitystreams_author(feed, @user.person)
@posts.each do |post|
feed.entry post, :url => "#{@user.url}p/#{post.id}",
:id => "#{@user.url}p/#{post.id}" do |entry|
entry.title post.message.title
entry.title post_page_title(post)
entry.content post.message.markdownified(disable_hovercards: true), :type => 'html'
add_activitystreams_author(entry, post.author)
entry.tag! 'activity:verb', 'http://activitystrea.ms/schema/1.0/post'
entry.tag! 'activity:object-type', 'http://activitystrea.ms/schema/1.0/note'
end
......
......@@ -4,6 +4,7 @@
describe UsersController, :type => :controller do
include_context :gon
include PostsHelper
before do
@user = alice
......@@ -46,20 +47,40 @@ describe UsersController, :type => :controller do
end
describe '#public' do
it 'renders xml if atom is requested' do
sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person)
get :public, :username => @user.username, :format => :atom
expect(response.body).to include(sm.text)
end
context "entry xml contents" do
before do
@sm = FactoryGirl.create(
:status_message,
public: true,
author: @user.person,
text: "Go to http://diasporafoundation.org/ now!"
)
end
it 'renders xml if atom is requested with clickalbe urls' do
sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person)
@user.person.posts.each do |p|
p.text = "Goto http://diasporaproject.org/ now!"
p.save
it "contains the text" do
get :public, username: @user.username, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry content")[0].content).to eq(@sm.message.markdownified(disable_hovercards: true))
end
it "contains the title" do
get :public, username: @user.username, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry title")[0].content).to eq(post_page_title(@sm))
end
it "contains the author" do
get :public, username: @user.username, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry author name")[0].content).to eq(@sm.author_name)
end
it "contains the original author for reshares" do
FactoryGirl.create(:reshare, root: @sm, author: bob.person)
get :public, username: bob.username, format: :atom
doc = Nokogiri::XML(response.body)
expect(doc.css("entry author name")[0].content).to eq(@sm.author_name)
end
get :public, :username => @user.username, :format => :atom
expect(response.body).to include('a href')
end
it 'includes reshares in the atom feed' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment