Use post page title for atom feeds and add entry author
Fixes #7249 closes #7420
This commit is contained in:
parent
6dc4493685
commit
23d3d9dc3f
4 changed files with 51 additions and 22 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
* Make photo upload button hover text translatable [#7429](https://github.com/diaspora/diaspora/pull/7429)
|
* 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)
|
* 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
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
12
app/helpers/activity_streams_helper.rb
Normal file
12
app/helpers/activity_streams_helper.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
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}"
|
'media:height' => '100', :href => "#{@user.image_url}"
|
||||||
feed.tag! :link, :href => "#{AppConfig.environment.pubsub_server}", :rel => 'hub'
|
feed.tag! :link, :href => "#{AppConfig.environment.pubsub_server}", :rel => 'hub'
|
||||||
|
|
||||||
feed.author do |author|
|
add_activitystreams_author(feed, @user.person)
|
||||||
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
|
|
||||||
|
|
||||||
@posts.each do |post|
|
@posts.each do |post|
|
||||||
feed.entry post, :url => "#{@user.url}p/#{post.id}",
|
feed.entry post, :url => "#{@user.url}p/#{post.id}",
|
||||||
:id => "#{@user.url}p/#{post.id}" do |entry|
|
: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'
|
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:verb', 'http://activitystrea.ms/schema/1.0/post'
|
||||||
entry.tag! 'activity:object-type', 'http://activitystrea.ms/schema/1.0/note'
|
entry.tag! 'activity:object-type', 'http://activitystrea.ms/schema/1.0/note'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
describe UsersController, :type => :controller do
|
describe UsersController, :type => :controller do
|
||||||
include_context :gon
|
include_context :gon
|
||||||
|
include PostsHelper
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = alice
|
@user = alice
|
||||||
|
|
@ -46,20 +47,40 @@ describe UsersController, :type => :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#public' do
|
describe '#public' do
|
||||||
it 'renders xml if atom is requested' do
|
context "entry xml contents" do
|
||||||
sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person)
|
before do
|
||||||
get :public, :username => @user.username, :format => :atom
|
@sm = FactoryGirl.create(
|
||||||
expect(response.body).to include(sm.text)
|
:status_message,
|
||||||
end
|
public: true,
|
||||||
|
author: @user.person,
|
||||||
it 'renders xml if atom is requested with clickalbe urls' do
|
text: "Go to http://diasporafoundation.org/ now!"
|
||||||
sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person)
|
)
|
||||||
@user.person.posts.each do |p|
|
end
|
||||||
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
|
end
|
||||||
get :public, :username => @user.username, :format => :atom
|
|
||||||
expect(response.body).to include('a href')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'includes reshares in the atom feed' do
|
it 'includes reshares in the atom feed' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue