From 79ec50a16c0711a23bc7f4e5890ff0baa541dbc2 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 21 Oct 2011 13:49:31 -0700 Subject: [PATCH] DG MS; added setting for displaying spotlight members in soup stream --- app/controllers/users_controller.rb | 18 +++++-- .../interim_stream_hackiness_helper.rb | 6 ++- app/models/user.rb | 3 +- app/views/aspects/_aspect_stream.haml | 7 +-- app/views/shared/_stream_element.html.haml | 3 ++ app/views/users/edit.html.haml | 18 +++++++ config/locales/diaspora/en.yml | 9 +++- ...84041_add_community_spotlight_in_stream.rb | 14 ++++++ db/schema.rb | 47 ++++++++++--------- lib/stream/soup.rb | 2 +- public/stylesheets/sass/application.sass | 6 +++ 11 files changed, 100 insertions(+), 33 deletions(-) create mode 100644 db/migrate/20111021184041_add_community_spotlight_in_stream.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4188a98b0..b3c35c92b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -41,12 +41,20 @@ class UsersController < ApplicationController else flash[:error] = I18n.t 'users.update.password_not_changed' end - elsif u[:language] - if @user.update_attributes(:language => u[:language]) - I18n.locale = @user.language - flash[:notice] = I18n.t 'users.update.language_changed' + elsif u[:show_community_spotlight_in_stream] + if @user.update_attributes(u) + flash[:notice] = I18n.t 'users.update.settings_updated' + redirect_to soup_path + return else - flash[:error] = I18n.t 'users.update.language_not_changed' + flash[:notice] = I18n.t 'users.update.settings_not_updated' + end + elsif u[:language] + if @user.update_attributes(u) + I18n.locale = @user.language + flash[:notice] = I18n.t 'users.update.language_updated' + else + flash[:error] = I18n.t 'users.update.language_not_updated' end elsif u[:email] @user.unconfirmed_email = u[:email] diff --git a/app/helpers/interim_stream_hackiness_helper.rb b/app/helpers/interim_stream_hackiness_helper.rb index bb3a247b2..0a6f2e853 100644 --- a/app/helpers/interim_stream_hackiness_helper.rb +++ b/app/helpers/interim_stream_hackiness_helper.rb @@ -5,7 +5,7 @@ module InterimStreamHackinessHelper @commenting_disabled elsif defined?(@stream) !@stream.can_comment?(post) - else + else false end end @@ -31,4 +31,8 @@ module InterimStreamHackinessHelper def what_soup_sentence(post) from_group(post).map{|x| x.to_s.gsub("_soup", '').gsub('_',' ').titleize}.to_sentence end + + def stream_settings_link(post) + link_to "", "#{edit_user_path}#stream-preferences" + end end diff --git a/app/models/user.rb b/app/models/user.rb index 327f8b0db..96cd712fb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -58,7 +58,8 @@ class User < ActiveRecord::Base :language, :disable_mail, :invitation_service, - :invitation_identifier + :invitation_identifier, + :show_community_spotlight_in_stream def self.all_sharing_with_person(person) diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml index c86ae06dc..7bc16bed8 100644 --- a/app/views/aspects/_aspect_stream.haml +++ b/app/views/aspects/_aspect_stream.haml @@ -16,11 +16,12 @@ = render 'shared/publisher', :selected_aspects => stream.aspects, :aspect_ids => stream.aspect_ids, :for_all_aspects => stream.for_all_aspects?, :aspect => stream.aspect = render 'aspects/no_posts_message' -- if current_user.contacts.size < 2 - = render 'aspects/no_contacts_message' - #main_stream.stream{:data => {:guids => stream.aspect_ids.join(','), :time_for_scroll => time_for_scroll(stream.ajax_stream?, stream)}} - if !stream.ajax_stream? && stream.posts.length > 0 = render 'shared/stream', :posts => stream.posts #pagination =link_to(t('more'), next_page_path(:ajax_stream => stream.ajax_stream?), :class => 'paginate') + +- if current_user.contacts.size < 2 + = render 'aspects/no_contacts_message' + diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index eb8ba638b..8fd23006c 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -17,7 +17,10 @@ %p = t('share_visibilites.update.see_it_on_their_profile', :name => person_link(post.author)).html_safe = link_to t('undo'), share_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true + .indicator{:title => "from #{what_soup_sentence(post)}"} + = stream_settings_link(post) + .sm_body = person_image_link(post.author, :size => :thumb_small) .content diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index f9f585dc3..3a93018f3 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -68,6 +68,24 @@ = f.select :language, available_language_options = f.submit t('.change_language') + %br + %br + %hr + + %br + + %h3#stream-preferences + = t('.stream_preferences') + = form_for current_user, :url => user_path, :html => { :method => :put } do |f| + = f.error_messages + + %p.checkbox_select + = f.label t('.show_community_spotlight') + = f.check_box :show_community_spotlight_in_stream + + %br + = f.submit t('.change'), :class => 'button' + %br %br %hr diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 410e312d0..7b041a69a 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -116,7 +116,7 @@ en: start_talking: "Nobody has said anything yet!" no_contacts_message: you_should_add_some_more_contacts: "You should add some more contacts!" - try_adding_some_more_contacts: "You can search (top) or invite (right) more contacts." + try_adding_some_more_contacts: "You can search or invite more contacts." or_spotlight: "Or you can share with %{link}" community_spotlight: "community spotlight" aspect_listings: @@ -876,6 +876,8 @@ en: reshared: "...someone reshares your post?" change: "Change" email_awaiting_confirmation: "We have sent you an activation link to %{unconfirmed_email}. Until you follow this link and activate the new address, we will continue to use your original address %{email}." + stream_preferences: "Stream Preferences" + show_community_spotlight: "Show Community Spotlight in Stream?" destroy: "Your account has been locked. It may take 20 minutes for us to finish closing your account. Thank you for trying Diaspora." getting_started: welcome: "Welcome!" @@ -924,8 +926,13 @@ en: update: password_changed: "Password changed. You can now log in with your new password." password_not_changed: "Password change failed" + language_changed: "Language changed" language_not_changed: "Language change failed" + + settings_updated: "Settings updated" + settings_not_updated: "Settings update failed" + email_notifications_changed: "Email notifications changed" unconfirmed_email_changed: "Email changed. Needs activation." unconfirmed_email_not_changed: "Email change failed" diff --git a/db/migrate/20111021184041_add_community_spotlight_in_stream.rb b/db/migrate/20111021184041_add_community_spotlight_in_stream.rb new file mode 100644 index 000000000..25143ff1f --- /dev/null +++ b/db/migrate/20111021184041_add_community_spotlight_in_stream.rb @@ -0,0 +1,14 @@ +class AddCommunitySpotlightInStream < ActiveRecord::Migration + def self.up + add_column :users, :show_community_spotlight_in_stream, :boolean, :null => false, :default => true + + ActiveRecord::Base.connection.execute < 20111018010003) do +ActiveRecord::Schema.define(:version => 20111021184041) do create_table "aspect_memberships", :force => true do |t| t.integer "aspect_id", :null => false @@ -32,8 +32,10 @@ ActiveRecord::Schema.define(:version => 20111018010003) do end add_index "aspect_visibilities", ["aspect_id"], :name => "index_aspect_visibilities_on_aspect_id" + add_index "aspect_visibilities", ["shareable_id", "aspect_id"], :name => "index_aspect_visibilities_on_post_id_and_aspect_id", :unique => true add_index "aspect_visibilities", ["shareable_id", "shareable_type", "aspect_id"], :name => "shareable_and_aspect_id" add_index "aspect_visibilities", ["shareable_id", "shareable_type"], :name => "index_aspect_visibilities_on_shareable_id_and_shareable_type" + add_index "aspect_visibilities", ["shareable_id"], :name => "index_aspect_visibilities_on_post_id" create_table "aspects", :force => true do |t| t.string "name", :null => false @@ -48,17 +50,17 @@ ActiveRecord::Schema.define(:version => 20111018010003) do add_index "aspects", ["user_id"], :name => "index_aspects_on_user_id" create_table "comments", :force => true do |t| - t.text "text", :null => false - t.integer "commentable_id", :null => false - t.integer "author_id", :null => false - t.string "guid", :null => false + t.text "text", :null => false + t.integer "commentable_id", :null => false + t.integer "author_id", :null => false + t.string "guid", :null => false t.text "author_signature" t.text "parent_author_signature" t.text "youtube_titles" t.datetime "created_at" t.datetime "updated_at" - t.integer "likes_count", :default => 0, :null => false - t.string "commentable_type", :limit => 60, :default => "Post", :null => false + t.integer "likes_count", :default => 0, :null => false + t.string "commentable_type", :default => "Post", :null => false end add_index "comments", ["author_id"], :name => "index_comments_on_person_id" @@ -364,15 +366,17 @@ ActiveRecord::Schema.define(:version => 20111018010003) do add_index "services", ["user_id"], :name => "index_services_on_user_id" create_table "share_visibilities", :force => true do |t| - t.integer "shareable_id", :null => false + t.integer "shareable_id", :null => false t.datetime "created_at" t.datetime "updated_at" - t.boolean "hidden", :default => false, :null => false - t.integer "contact_id", :null => false - t.string "shareable_type", :limit => 60, :default => "Post", :null => false + t.boolean "hidden", :default => false, :null => false + t.integer "contact_id", :null => false + t.string "shareable_type", :default => "Post", :null => false end + add_index "share_visibilities", ["contact_id", "shareable_id"], :name => "index_post_visibilities_on_contact_id_and_post_id", :unique => true add_index "share_visibilities", ["contact_id"], :name => "index_post_visibilities_on_contact_id" + add_index "share_visibilities", ["shareable_id", "hidden", "contact_id"], :name => "index_post_visibilities_on_post_id_and_hidden_and_contact_id", :unique => true add_index "share_visibilities", ["shareable_id", "shareable_type", "contact_id"], :name => "shareable_and_contact_id" add_index "share_visibilities", ["shareable_id", "shareable_type", "hidden", "contact_id"], :name => "shareable_and_hidden_and_contact_id" add_index "share_visibilities", ["shareable_id"], :name => "index_post_visibilities_on_post_id" @@ -415,32 +419,33 @@ ActiveRecord::Schema.define(:version => 20111018010003) do create_table "users", :force => true do |t| t.string "username" t.text "serialized_private_key" - t.boolean "getting_started", :default => true, :null => false - t.boolean "disable_mail", :default => false, :null => false + t.boolean "getting_started", :default => true, :null => false + t.boolean "disable_mail", :default => false, :null => false t.string "language" - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false - t.string "invitation_token", :limit => 60 + t.string "email", :default => "", :null => false + t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "invitation_token", :limit => 60 t.datetime "invitation_sent_at" t.string "reset_password_token" t.string "remember_token" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" - t.string "invitation_service", :limit => 127 - t.string "invitation_identifier", :limit => 127 + t.string "invitation_service", :limit => 127 + t.string "invitation_identifier", :limit => 127 t.integer "invitation_limit" t.integer "invited_by_id" t.string "invited_by_type" - t.string "authentication_token", :limit => 30 + t.string "authentication_token", :limit => 30 t.string "unconfirmed_email" - t.string "confirm_email_token", :limit => 30 + t.string "confirm_email_token", :limit => 30 t.datetime "locked_at" + t.boolean "show_community_spotlight_in_stream", :default => true, :null => false end add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true diff --git a/lib/stream/soup.rb b/lib/stream/soup.rb index ad81f7727..e2b301f44 100644 --- a/lib/stream/soup.rb +++ b/lib/stream/soup.rb @@ -40,7 +40,7 @@ class Stream::Soup < Stream::Base end def include_community_spotlight? - false + user.show_community_spotlight_in_stream? end def aspects_post_ids diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 7a5087297..c5cc8d060 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3500,6 +3500,12 @@ ul#getting_started :height 4px :float right + a + :display block + :height 100% + :width 100% + :padding 0 + :margin 0 .community_spotlight_soup .indicator