Make public stream accessible for logged out users
Fixes #6564. closes #7775
This commit is contained in:
parent
7d6623d069
commit
01ae004518
12 changed files with 240 additions and 171 deletions
|
|
@ -9,6 +9,7 @@
|
|||
* Show error message when creating posts with invalid aspects [#7742](https://github.com/diaspora/diaspora/pull/7742)
|
||||
|
||||
## Features
|
||||
* Make public stream accessible for logged out users [#7775](https://github.com/diaspora/diaspora/pull/7775)
|
||||
|
||||
# 0.7.4.1
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ app.views.Stream = app.views.InfScroll.extend({
|
|||
|
||||
markNavSelected : function() {
|
||||
var activeStream = Backbone.history.fragment;
|
||||
var streamSelection = $("#stream_selection");
|
||||
var streamSelection = $("#stream-selection");
|
||||
streamSelection.find("[data-stream]").removeClass("selected");
|
||||
streamSelection.find("[data-stream='" + activeStream + "']").addClass("selected");
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
.public-stream {
|
||||
float: none;
|
||||
}
|
||||
|
||||
.main-stream-publisher {
|
||||
margin-top: 20px;
|
||||
padding: 0;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class StreamsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_user!, except: :public
|
||||
before_action :save_selected_aspects, :only => :aspects
|
||||
|
||||
layout proc { request.format == :mobile ? "application" : "with_header" }
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ module ApplicationHelper
|
|||
current_user.services.size == AppConfig.configured_services.size
|
||||
end
|
||||
|
||||
def service_unconnected?(service)
|
||||
AppConfig.show_service?(service, current_user) && current_user.services.none? {|x| x.provider == service }
|
||||
end
|
||||
|
||||
def popover_with_close_html(without_close_html)
|
||||
without_close_html + link_to('×'.html_safe, "#", :class => 'close')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
.container-fluid.main-stream-publisher
|
||||
.pull-left.hidden-xs
|
||||
= owner_image_link
|
||||
= render "publisher/publisher", publisher_aspects_for(stream)
|
||||
- if user_signed_in?
|
||||
.container-fluid.main-stream-publisher
|
||||
.pull-left.hidden-xs
|
||||
= owner_image_link
|
||||
= render "publisher/publisher", publisher_aspects_for(stream)
|
||||
|
||||
- if current_user.getting_started?
|
||||
- if current_user&.getting_started?
|
||||
.stream#main-stream{:title => popover_with_close_html("3. #{t('.stay_updated')}"),
|
||||
"data-content" => t(".stay_updated_explanation")}
|
||||
- else
|
||||
|
|
@ -17,5 +18,5 @@
|
|||
.loader.hidden
|
||||
.spinner
|
||||
|
||||
- if current_user.contacts.size < 2
|
||||
- if current_user && current_user.contacts.size < 2
|
||||
= render 'aspects/no_contacts_message'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
= javascript_include_tag :jsxc, id: 'jsxc',
|
||||
data: { endpoint: get_bosh_endpoint }
|
||||
|
||||
- if current_user.getting_started?
|
||||
- if current_user&.getting_started?
|
||||
#welcome-to-diaspora
|
||||
.container-fluid
|
||||
.row
|
||||
|
|
@ -22,159 +22,161 @@
|
|||
|
||||
.container-fluid
|
||||
.row
|
||||
.col-md-3
|
||||
.sidebar.left-navbar
|
||||
%ul#stream_selection
|
||||
%li{data: {stream: "stream"}}
|
||||
= link_to t("streams.multi.title"), stream_path, rel: "backbone", class: "hoverable"
|
||||
%li.nested-list.my-activity{data: {stream: "activity"}}
|
||||
= link_to t("streams.activity.title"), activity_stream_path, rel: "backbone", class: "hoverable"
|
||||
%ul
|
||||
%li{data: {stream: "liked"}}
|
||||
= link_to t("streams.liked.title"), liked_stream_path, rel: "backbone", class: "hoverable selectable"
|
||||
%li{data: {stream: "commented"}}
|
||||
= link_to t("streams.commented.title"), commented_stream_path,
|
||||
rel: "backbone", class: "hoverable selectable"
|
||||
%li{data: {stream: "mentions"}}
|
||||
= link_to t("streams.mentions.title"), mentioned_stream_path, rel: "backbone", class: "hoverable"
|
||||
%li.nested-list.all-aspects
|
||||
= render "aspects/aspect_listings", stream: @stream
|
||||
%li.nested-list
|
||||
= render "tags/followed_tags_listings"
|
||||
%li{data: {stream: "public"}}
|
||||
= link_to t("streams.public.title"), public_stream_path, rel: "backbone", class: "hoverable"
|
||||
- if user_signed_in?
|
||||
.col-md-3
|
||||
.sidebar.left-navbar
|
||||
%ul#stream-selection
|
||||
%li{data: {stream: "stream"}}
|
||||
= link_to t("streams.multi.title"), stream_path, rel: "backbone", class: "hoverable"
|
||||
%li.nested-list.my-activity{data: {stream: "activity"}}
|
||||
= link_to t("streams.activity.title"), activity_stream_path, rel: "backbone", class: "hoverable"
|
||||
%ul
|
||||
%li{data: {stream: "liked"}}
|
||||
= link_to t("streams.liked.title"), liked_stream_path, rel: "backbone", class: "hoverable selectable"
|
||||
%li{data: {stream: "commented"}}
|
||||
= link_to t("streams.commented.title"), commented_stream_path,
|
||||
rel: "backbone", class: "hoverable selectable"
|
||||
%li{data: {stream: "mentions"}}
|
||||
= link_to t("streams.mentions.title"), mentioned_stream_path, rel: "backbone", class: "hoverable"
|
||||
%li.nested-list.all-aspects
|
||||
= render "aspects/aspect_listings", stream: @stream
|
||||
%li.nested-list
|
||||
= render "tags/followed_tags_listings"
|
||||
%li{data: {stream: "public"}}
|
||||
= link_to t("streams.public.title"), public_stream_path, rel: "backbone", class: "hoverable"
|
||||
|
||||
.sidebar.info-bar.hidden-xs
|
||||
- if AppConfig.settings.invitations.open?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("shared.invitations.invite_your_friends")
|
||||
.content
|
||||
= render "shared/invitations"
|
||||
|
||||
.sidebar.info-bar.hidden-xs
|
||||
- if AppConfig.settings.invitations.open?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("shared.invitations.invite_your_friends")
|
||||
= t("aspects.index.new_here.title")
|
||||
.content
|
||||
= render "shared/invitations"
|
||||
!= t("aspects.index.new_here.follow",
|
||||
link: link_to("#" + t("shared.publisher.new_user_prefill.newhere"),
|
||||
tag_path(name: t("shared.publisher.new_user_prefill.newhere"))))
|
||||
%br
|
||||
= link_to(t("aspects.index.new_here.learn_more"),
|
||||
"http://wiki.diasporafoundation.org/Welcoming_Committee")
|
||||
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.new_here.title")
|
||||
.content
|
||||
!= t("aspects.index.new_here.follow",
|
||||
link: link_to("#" + t("shared.publisher.new_user_prefill.newhere"),
|
||||
tag_path(name: t("shared.publisher.new_user_prefill.newhere"))))
|
||||
%br
|
||||
= link_to(t("aspects.index.new_here.learn_more"),
|
||||
"http://wiki.diasporafoundation.org/Welcoming_Committee")
|
||||
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.help.need_help")
|
||||
.content
|
||||
%p
|
||||
= t("aspects.index.help.here_to_help")
|
||||
%p
|
||||
= t("aspects.index.help.do_you")
|
||||
%ul
|
||||
%li
|
||||
!= t("aspects.index.help.have_a_question",
|
||||
link: link_to("#" + t("aspects.index.help.tag_question"),
|
||||
tag_path(name: t("aspects.index.help.tag_question"))))
|
||||
%li
|
||||
!= t("aspects.index.help.find_a_bug",
|
||||
link: link_to(t("aspects.index.help.tag_bug"),
|
||||
"https://wiki.diasporafoundation.org/How_to_report_a_bug"))
|
||||
%li
|
||||
!= t("aspects.index.help.feature_suggestion",
|
||||
link: link_to(t("aspects.index.help.tag_feature"),
|
||||
"https://discourse.diasporafoundation.org/c/features-and-ideas"))
|
||||
%p
|
||||
!= t("aspects.index.help.tutorials_and_wiki",
|
||||
faq: link_to(t("_help"), help_path),
|
||||
tutorial: link_to(t("aspects.index.help.tutorial_link_text"),
|
||||
"https://diasporafoundation.org/tutorials", target: "_blank"),
|
||||
wiki: link_to("Wiki", "http://wiki.diasporafoundation.org",
|
||||
target: "_blank"),
|
||||
target: "_blank")
|
||||
|
||||
%p
|
||||
!= t("aspects.index.help.support_forum",
|
||||
support_forum: link_to(t("aspects.index.help.support_forum_link"),
|
||||
"https://discourse.diasporafoundation.org/c/support", target: "_blank"))
|
||||
|
||||
- unless AppConfig.configured_services.blank? || all_services_connected?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.services.heading")
|
||||
= t("aspects.index.help.need_help")
|
||||
.content
|
||||
%div
|
||||
= t("aspects.index.services.content")
|
||||
%p
|
||||
= t("aspects.index.help.here_to_help")
|
||||
%p
|
||||
= t("aspects.index.help.do_you")
|
||||
%ul
|
||||
%li
|
||||
!= t("aspects.index.help.have_a_question",
|
||||
link: link_to("#" + t("aspects.index.help.tag_question"),
|
||||
tag_path(name: t("aspects.index.help.tag_question"))))
|
||||
%li
|
||||
!= t("aspects.index.help.find_a_bug",
|
||||
link: link_to(t("aspects.index.help.tag_bug"),
|
||||
"https://wiki.diasporafoundation.org/How_to_report_a_bug"))
|
||||
%li
|
||||
!= t("aspects.index.help.feature_suggestion",
|
||||
link: link_to(t("aspects.index.help.tag_feature"),
|
||||
"https://discourse.diasporafoundation.org/c/features-and-ideas"))
|
||||
%p
|
||||
!= t("aspects.index.help.tutorials_and_wiki",
|
||||
faq: link_to(t("_help"), help_path),
|
||||
tutorial: link_to(t("aspects.index.help.tutorial_link_text"),
|
||||
"https://diasporafoundation.org/tutorials", target: "_blank"),
|
||||
wiki: link_to("Wiki", "http://wiki.diasporafoundation.org",
|
||||
target: "_blank"),
|
||||
target: "_blank")
|
||||
|
||||
.right-service-icons
|
||||
- AppConfig.configured_services.each do |service|
|
||||
- if AppConfig.show_service?(service, current_user)
|
||||
- unless current_user.services.any? {|x| x.provider == service }
|
||||
%p
|
||||
!= t("aspects.index.help.support_forum",
|
||||
support_forum: link_to(t("aspects.index.help.support_forum_link"),
|
||||
"https://discourse.diasporafoundation.org/c/support", target: "_blank"))
|
||||
|
||||
- unless AppConfig.configured_services.blank? || all_services_connected?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.services.heading")
|
||||
.content
|
||||
%div
|
||||
= t("aspects.index.services.content")
|
||||
|
||||
.right-service-icons
|
||||
- AppConfig.configured_services.each do |service|
|
||||
- if service_unconnected?(service)
|
||||
= link_to(content_tag(:div, nil,
|
||||
class: "social-media-logos-#{service.to_s.downcase}-24x24",
|
||||
title: service.to_s.titleize), "/auth/#{service}")
|
||||
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("bookmarklet.heading")
|
||||
.content
|
||||
!= t("bookmarklet.explanation", link: link_to(t("bookmarklet.post_something"), bookmarklet_code))
|
||||
|
||||
- if donations_enabled?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.donate")
|
||||
= t("bookmarklet.heading")
|
||||
.content
|
||||
!= t("bookmarklet.explanation", link: link_to(t("bookmarklet.post_something"), bookmarklet_code))
|
||||
|
||||
- if donations_enabled?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.donate")
|
||||
.content
|
||||
%p
|
||||
= t("aspects.index.keep_pod_running", pod: AppConfig.pod_uri.host)
|
||||
= render "shared/donatepod"
|
||||
|
||||
- if AppConfig.admins.podmin_email.present?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.help.any_problem")
|
||||
.content
|
||||
%p
|
||||
= t("aspects.index.help.contact_podmin")
|
||||
%p
|
||||
= link_to t("aspects.index.help.mail_podmin"), "mailto:#{AppConfig.admins.podmin_email}"
|
||||
|
||||
.excellence-box
|
||||
.content
|
||||
%p
|
||||
= t("aspects.index.keep_pod_running", pod: AppConfig.pod_uri.host)
|
||||
= render "shared/donatepod"
|
||||
= link_to t("layouts.application.be_excellent"), "https://diasporafoundation.org/community_guidelines"
|
||||
|
||||
- if AppConfig.admins.podmin_email.present?
|
||||
.section.collapsed
|
||||
.title
|
||||
%h5.title-header
|
||||
.entypo-triangle-right
|
||||
.entypo-triangle-down
|
||||
= t("aspects.index.help.any_problem")
|
||||
.info-links
|
||||
.content
|
||||
%p
|
||||
= t("aspects.index.help.contact_podmin")
|
||||
%p
|
||||
= link_to t("aspects.index.help.mail_podmin"), "mailto:#{AppConfig.admins.podmin_email}"
|
||||
%ul
|
||||
= render "shared/links"
|
||||
|
||||
.excellence-box
|
||||
.content
|
||||
%p
|
||||
= link_to t("layouts.application.be_excellent"), "https://diasporafoundation.org/community_guidelines"
|
||||
.powered-box
|
||||
.content
|
||||
.powered-by-diaspora.text-center
|
||||
= link_to t("layouts.application.powered_by"), "https://diasporafoundation.org"
|
||||
|
||||
.info-links
|
||||
.content
|
||||
%ul
|
||||
= render "shared/links"
|
||||
|
||||
.powered-box
|
||||
.content
|
||||
.powered-by-diaspora.text-center
|
||||
= link_to t("layouts.application.powered_by"), "https://diasporafoundation.org"
|
||||
|
||||
.col-md-9
|
||||
.col-md-9{class: ("center-block public-stream" unless user_signed_in?)}
|
||||
.stream-container#aspect-stream-container
|
||||
- unless user_signed_in?
|
||||
%h2= @stream.title
|
||||
= render "aspects/aspect_stream", stream: @stream
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
- unless user_signed_in?
|
||||
%h1= @stream.title
|
||||
|
||||
#main-stream.stream
|
||||
= render 'shared/stream', posts: @stream.stream_posts
|
||||
= render 'shared/stream_more_button'
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ Feature: Keyboard navigation
|
|||
Scenario: navigate downwards after changing the stream
|
||||
When I go to the activity stream page
|
||||
And I click on selector "[data-stream='stream'] a"
|
||||
Then I should see "Stream" within "#stream_selection .selected"
|
||||
Then I should see "Stream" within "#stream-selection .selected"
|
||||
|
||||
When I press the "J" key somewhere
|
||||
Then post 1 should be highlighted
|
||||
|
|
|
|||
|
|
@ -12,3 +12,7 @@ Feature: The public stream
|
|||
When I sign in as "alice@alice.alice"
|
||||
And I am on the public stream page
|
||||
Then I should see "Bob’s public post"
|
||||
|
||||
Scenario: seeing public posts as a logged out user
|
||||
When I am on the public stream page
|
||||
Then I should see "Bob’s public post"
|
||||
|
|
|
|||
|
|
@ -7,54 +7,80 @@
|
|||
describe StreamsController, :type => :controller do
|
||||
include_context :gon
|
||||
|
||||
before do
|
||||
sign_in alice
|
||||
end
|
||||
|
||||
describe "#public" do
|
||||
it "succeeds" do
|
||||
get :public
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe '#multi' do
|
||||
it 'succeeds' do
|
||||
get :multi
|
||||
expect(response).to be_success
|
||||
context "with a logged in user" do
|
||||
before do
|
||||
sign_in alice
|
||||
end
|
||||
|
||||
it 'succeeds on mobile' do
|
||||
get :multi, :format => :mobile
|
||||
expect(response).to be_success
|
||||
describe "#public" do
|
||||
it "succeeds" do
|
||||
get :public
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
context "getting started" do
|
||||
it "add the inviter to gon" do
|
||||
user = FactoryGirl.create(:user, getting_started: true, invited_by: alice)
|
||||
sign_in user
|
||||
|
||||
describe "#multi" do
|
||||
it "succeeds" do
|
||||
get :multi
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
expect(gon["preloads"][:mentioned_person][:name]).to eq(alice.person.name)
|
||||
expect(gon["preloads"][:mentioned_person][:handle]).to eq(alice.person.diaspora_handle)
|
||||
it "succeeds on mobile" do
|
||||
get :multi, format: :mobile
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
context "getting started" do
|
||||
it "add the inviter to gon" do
|
||||
user = FactoryGirl.create(:user, getting_started: true, invited_by: alice)
|
||||
sign_in user
|
||||
|
||||
get :multi
|
||||
|
||||
expect(gon["preloads"][:mentioned_person][:name]).to eq(alice.person.name)
|
||||
expect(gon["preloads"][:mentioned_person][:handle]).to eq(alice.person.diaspora_handle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
streams = {
|
||||
liked: Stream::Likes,
|
||||
mentioned: Stream::Mention,
|
||||
followed_tags: Stream::FollowedTag,
|
||||
activity: Stream::Activity
|
||||
}
|
||||
|
||||
streams.each do |stream_path, stream_class|
|
||||
describe "a GET to #{stream_path}" do
|
||||
it "assigns a stream of the proper class" do
|
||||
get stream_path
|
||||
expect(response).to be_success
|
||||
expect(assigns[:stream]).to be_a stream_class
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
streams = {
|
||||
:liked => Stream::Likes,
|
||||
:mentioned => Stream::Mention,
|
||||
:followed_tags => Stream::FollowedTag,
|
||||
:activity => Stream::Activity
|
||||
}
|
||||
|
||||
streams.each do |stream_path, stream_class|
|
||||
describe "a GET to #{stream_path}" do
|
||||
it 'assigns a stream of the proper class' do
|
||||
get stream_path
|
||||
context "with no user signed in" do
|
||||
describe "#public" do
|
||||
it "succeeds" do
|
||||
get :public
|
||||
expect(response).to be_success
|
||||
expect(assigns[:stream]).to be_a stream_class
|
||||
end
|
||||
|
||||
it "succeeds on mobile" do
|
||||
get :public, format: :mobile
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe "other streams" do
|
||||
it "redirects to the login page" do
|
||||
%i[activity followed_tags liked mentioned multi].each do |stream_path|
|
||||
get stream_path
|
||||
expect(response).to be_redirect
|
||||
expect(response).to redirect_to new_user_session_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -35,6 +35,30 @@ describe ApplicationHelper, :type => :helper do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#service_unconnected?" do
|
||||
attr_reader :current_user
|
||||
|
||||
before do
|
||||
@current_user = alice
|
||||
end
|
||||
|
||||
it "returns true if the service is unconnected" do
|
||||
expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(true)
|
||||
expect(service_unconnected?("service")).to be true
|
||||
end
|
||||
|
||||
it "returns false if the service is already connected" do
|
||||
@current_user.services << FactoryGirl.build(:service, provider: "service")
|
||||
expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(true)
|
||||
expect(service_unconnected?("service")).to be false
|
||||
end
|
||||
|
||||
it "returns false if the the service shouldn't be shown" do
|
||||
expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(false)
|
||||
expect(service_unconnected?("service")).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#jquery_include_tag" do
|
||||
describe "with jquery cdn" do
|
||||
before do
|
||||
|
|
|
|||
Loading…
Reference in a new issue