diff --git a/Changelog.md b/Changelog.md index 4fd01ec8e502c3d58eb95f1155279d78b387d380..dceede4e59e2723d03be06f227a57add879ab1d8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -24,6 +24,8 @@ ## 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 diff --git a/app/assets/javascripts/mobile/mobile_comments.js b/app/assets/javascripts/mobile/mobile_comments.js index 0861ec0f26ac0840fdebb612ba8f66a3c52efbeb..49858bc1c08a590547b141f534e94129f8798265 100644 --- a/app/assets/javascripts/mobile/mobile_comments.js +++ b/app/assets/javascripts/mobile/mobile_comments.js @@ -201,7 +201,7 @@ increaseReactionCount: function(bottomBar) { var toggleReactionsLink = bottomBar.find(".show-comments").first(); var count = toggleReactionsLink.text().match(/.*(\d+).*/); - count = parseInt(count, 10); + count = parseInt(count, 10) || 0; var text = Diaspora.I18n.t("stream.comments", {count: count + 1}); // No previous comment diff --git a/app/helpers/activity_streams_helper.rb b/app/helpers/activity_streams_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..b08514404eb3c4b6c191d99e9a9c326713d1555d --- /dev/null +++ b/app/helpers/activity_streams_helper.rb @@ -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 diff --git a/app/views/users/public.atom.builder b/app/views/users/public.atom.builder index e5bfb6da8c280b8f8d1c88857979f7a8ab9cba02..790f6f21a9c942ea2c504be429932ca032b64990 100644 --- a/app/views/users/public.atom.builder +++ b/app/views/users/public.atom.builder @@ -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 diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 0ab83e120ba293b741cb54d99a23a8e30207bb83..3060c9d4d296be426d1e79693cdb09f47d1b8c07 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -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 diff --git a/spec/helpers/posts_helper_spec.rb b/spec/helpers/posts_helper_spec.rb index d10e529e462a8b6508118099bf5569d0131fc7f2..1b5f1f1824660740c1492799aa6ae78a65e6cec6 100644 --- a/spec/helpers/posts_helper_spec.rb +++ b/spec/helpers/posts_helper_spec.rb @@ -17,6 +17,13 @@ describe PostsHelper, :type => :helper do post_page_title(post) end end + + context "with a reshare" do + it "returns 'Reshare by...'" do + reshare = FactoryGirl.create(:reshare, author: alice.person) + expect(post_page_title(reshare)).to eq I18n.t("posts.show.reshare_by", author: reshare.author_name) + end + end end diff --git a/spec/javascripts/mobile/mobile_comments_spec.js b/spec/javascripts/mobile/mobile_comments_spec.js index 7a751443f741b8f325b9dc0502c406e8b64e3aae..e87a81adcb1b7080e86f1457023eafaaf5b49822 100644 --- a/spec/javascripts/mobile/mobile_comments_spec.js +++ b/spec/javascripts/mobile/mobile_comments_spec.js @@ -144,7 +144,7 @@ describe("Diaspora.Mobile.Comments", function(){ expect(this.toggleReactionsLink.text().trim()).toBe("6 comments"); }); - it("Creates the reaction link when no reactions", function(){ + it("Creates the reaction link when there are no reactions", function() { var parent = this.toggleReactionsLink.parent(); var postGuid = this.bottomBar.parents(".stream-element").data("guid"); this.toggleReactionsLink.remove(); @@ -155,6 +155,18 @@ describe("Diaspora.Mobile.Comments", function(){ expect(this.toggleReactionsLink.text().trim()).toBe("1 comment"); expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile"); }); + + it("Creates the reaction link when there are no reactions (french locale)", function() { + var parent = this.toggleReactionsLink.parent(); + var postGuid = this.bottomBar.parents(".stream-element").data("guid"); + this.toggleReactionsLink.remove(); + parent.prepend($("<span/>", {"class": "show-comments"}).text("Aucun commentaire")); + + Diaspora.Mobile.Comments.increaseReactionCount(this.bottomBar); + this.toggleReactionsLink = this.bottomBar.find(".show-comments").first(); + expect(this.toggleReactionsLink.text().trim()).toBe("1 comment"); + expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile"); + }); }); describe("bottomBarLazy", function(){