Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make public stream accessible for logged out users #7775

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/app/views/stream_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/stream.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
}
}

.public-stream {
float: none;
}

.main-stream-publisher {
margin-top: 20px;
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/streams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def all_services_connected?
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('&times;'.html_safe, "#", :class => 'close')
end
Expand Down
13 changes: 7 additions & 6 deletions app/views/aspects/_aspect_stream.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,5 +18,5 @@
.loader.hidden
.spinner

- if current_user.contacts.size < 2
- if current_user && current_user.contacts.size < 2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use safe navigation (&.) instead of checking if an object exists before calling the method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While one could write this as current_user&.contacts&.size&.< 2, I think it's much more readable the way it is now, so I think we can ignore this one.

= render 'aspects/no_contacts_message'
256 changes: 129 additions & 127 deletions app/views/streams/main_stream.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

.sidebar.info-bar.hidden-xs
- if AppConfig.settings.invitations.open?
- 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"

.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"

.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?
!= 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.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
%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")
!= 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.help.contact_podmin")
%p
= link_to t("aspects.index.help.mail_podmin"), "mailto:#{AppConfig.admins.podmin_email}"

.excellence-box
.content
%p
= link_to t("layouts.application.be_excellent"), "https://diasporafoundation.org/community_guidelines"
= link_to t("layouts.application.be_excellent"), "https://diasporafoundation.org/community_guidelines"

.info-links
.content
%ul
= render "shared/links"
.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"
.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
3 changes: 3 additions & 0 deletions app/views/streams/main_stream.mobile.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion features/desktop/keyboard_navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions features/desktop/public_stream.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading