From 087e11897137dc1f2811c21c3ccc6cec3ccdedb3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 17 Dec 2018 03:14:28 +0100 Subject: Remove "most popular" tab from profile directory, add responsive design (#9539) * Remove "most popular" tab from profile directory, add responsive design * Remove unused translations --- app/views/directories/index.html.haml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'app/views/directories') diff --git a/app/views/directories/index.html.haml b/app/views/directories/index.html.haml index f70eb964a..88706def7 100644 --- a/app/views/directories/index.html.haml +++ b/app/views/directories/index.html.haml @@ -16,10 +16,6 @@ .grid .column-0 - .account__section-headline - = active_link_to t('directories.most_recently_active'), @tag ? explore_hashtag_path(@tag) : explore_path - = active_link_to t('directories.most_popular'), @tag ? explore_hashtag_popular_path(@tag) : explore_popular_path - - if @accounts.empty? = nothing_here - else @@ -29,10 +25,10 @@ - @accounts.each do |account| %tr %td= account_link_to account - %td.accounts-table__count + %td.accounts-table__count.optional = number_to_human account.statuses_count, strip_insignificant_zeros: true %small= t('accounts.posts', count: account.statuses_count).downcase - %td.accounts-table__count + %td.accounts-table__count.optional = number_to_human account.followers_count, strip_insignificant_zeros: true %small= t('accounts.followers', count: account.followers_count).downcase %td.accounts-table__count -- cgit From a1c56fcef124b08fc2676d38fd79ed72d660d865 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 17 Dec 2018 20:36:30 +0100 Subject: Add admin setting to disable followers count --- app/controllers/admin/settings_controller.rb | 2 ++ app/controllers/follower_accounts_controller.rb | 2 +- app/helpers/stream_entries_helper.rb | 12 +++++++----- app/models/form/admin_settings.rb | 2 ++ app/serializers/rest/account_serializer.rb | 4 ++++ app/views/accounts/_header.html.haml | 4 ++-- app/views/admin/settings/edit.html.haml | 3 +++ app/views/directories/index.html.haml | 7 ++++--- config/locales/en.yml | 3 +++ config/settings.yml | 1 + 10 files changed, 29 insertions(+), 11 deletions(-) (limited to 'app/views/directories') diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 76b3c3a2b..9624df96b 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -29,6 +29,7 @@ module Admin preview_sensitive_media custom_css profile_directory + hide_followers_count ).freeze BOOLEAN_SETTINGS = %w( @@ -41,6 +42,7 @@ module Admin show_known_fediverse_at_about_page preview_sensitive_media profile_directory + hide_followers_count ).freeze UPLOAD_SETTINGS = %w( diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index 461e6d70e..13043b1b9 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -37,7 +37,7 @@ class FollowerAccountsController < ApplicationController def collection_presenter options = { type: :ordered } - options[:size] = @account.followers_count + options[:size] = @account.followers_count unless Setting.hide_followers_count if params[:page].present? ActivityPub::CollectionPresenter.new( id: account_followers_url(@account, page: params.fetch(:page, 1)), diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb index 033d435c4..e37cfbda4 100644 --- a/app/helpers/stream_entries_helper.rb +++ b/app/helpers/stream_entries_helper.rb @@ -61,7 +61,7 @@ module StreamEntriesHelper end def account_description(account) - prepend_str = [ + prepend_stats = [ [ number_to_human(account.statuses_count, strip_insignificant_zeros: true), I18n.t('accounts.posts', count: account.statuses_count), @@ -71,14 +71,16 @@ module StreamEntriesHelper number_to_human(account.following_count, strip_insignificant_zeros: true), I18n.t('accounts.following', count: account.following_count), ].join(' '), + ] - [ + unless Setting.hide_followers_count + prepend_stats << [ number_to_human(account.followers_count, strip_insignificant_zeros: true), I18n.t('accounts.followers', count: account.followers_count), - ].join(' '), - ].join(', ') + ].join(' ') + end - [prepend_str, account.note].join(' · ') + [prepend_stats.join(', '), account.note].join(' · ') end def media_summary(status) diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 34c75e3bf..d568200ed 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -30,6 +30,8 @@ class Form::AdminSettings :show_staff_badge=, :bootstrap_timeline_accounts, :bootstrap_timeline_accounts=, + :hide_followers_count, + :hide_followers_count=, :flavour, :flavour=, :skin, diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 12adc971c..a3f2ad036 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -51,4 +51,8 @@ class REST::AccountSerializer < ActiveModel::Serializer def moved_and_not_nested? object.moved? && object.moved_to_account.moved_to_account_id.nil? end + + def followers_count + Setting.hide_followers_count ? -1 : object.followers_count + end end diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 370e7e470..458c86ce5 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -24,8 +24,8 @@ %span.counter-label= t('accounts.following', count: account.following_count) .counter{ class: active_nav_class(account_followers_url(account)) } - = link_to account_followers_url(account), title: number_with_delimiter(account.followers_count) do - %span.counter-number= number_to_human account.followers_count, strip_insignificant_zeros: true + = link_to account_followers_url(account), title: Setting.hide_followers_count ? nil : number_with_delimiter(account.followers_count) do + %span.counter-number= Setting.hide_followers_count ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) %span.counter-label= t('accounts.followers', count: account.followers_count) .spacer .public-account-header__tabs__tabs__buttons diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index bcf57aac0..e3ceb4344 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -65,6 +65,9 @@ .fields-group = f.input :profile_directory, as: :boolean, wrapper: :with_label, label: t('admin.settings.profile_directory.title'), hint: t('admin.settings.profile_directory.desc_html') + .fields-group + = f.input :hide_followers_count, as: :boolean, wrapper: :with_label, label: t('admin.settings.hide_followers_count.title'), hint: t('admin.settings.hide_followers_count.desc_html') + %hr.spacer/ .fields-group diff --git a/app/views/directories/index.html.haml b/app/views/directories/index.html.haml index 88706def7..7f6ad13e6 100644 --- a/app/views/directories/index.html.haml +++ b/app/views/directories/index.html.haml @@ -28,9 +28,10 @@ %td.accounts-table__count.optional = number_to_human account.statuses_count, strip_insignificant_zeros: true %small= t('accounts.posts', count: account.statuses_count).downcase - %td.accounts-table__count.optional - = number_to_human account.followers_count, strip_insignificant_zeros: true - %small= t('accounts.followers', count: account.followers_count).downcase + - unless Setting.hide_followers_count + %td.accounts-table__count.optional + = number_to_human account.followers_count, strip_insignificant_zeros: true + %small= t('accounts.followers', count: account.followers_count).downcase %td.accounts-table__count - if account.last_status_at.present? %time.time-ago{ datetime: account.last_status_at.iso8601, title: l(account.last_status_at) }= l account.last_status_at diff --git a/config/locales/en.yml b/config/locales/en.yml index 735a88efd..e722788fe 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -370,6 +370,9 @@ en: hero: desc_html: Displayed on the frontpage. At least 600x100px recommended. When not set, falls back to instance thumbnail title: Hero image + hide_followers_count: + desc_html: Do not show followers count on user profiles + title: Hide followers count mascot: desc_html: Displayed on multiple pages. At least 293×205px recommended. When not set, falls back to default mascot title: Mascot image diff --git a/config/settings.yml b/config/settings.yml index 2cac28b63..bd6578bd4 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -34,6 +34,7 @@ defaults: &defaults reduce_motion: false system_font_ui: false noindex: false + hide_followers_count: false flavour: 'glitch' skin: 'default' aggregate_reblogs: true -- cgit From 9e04b2e8a4fa6cb45f59000faf2902a727973add Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 18 Dec 2018 12:02:54 +0100 Subject: Per-user followers count display in profile directory --- app/views/directories/index.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'app/views/directories') diff --git a/app/views/directories/index.html.haml b/app/views/directories/index.html.haml index 7f6ad13e6..8d136a31f 100644 --- a/app/views/directories/index.html.haml +++ b/app/views/directories/index.html.haml @@ -28,10 +28,9 @@ %td.accounts-table__count.optional = number_to_human account.statuses_count, strip_insignificant_zeros: true %small= t('accounts.posts', count: account.statuses_count).downcase - - unless Setting.hide_followers_count - %td.accounts-table__count.optional - = number_to_human account.followers_count, strip_insignificant_zeros: true - %small= t('accounts.followers', count: account.followers_count).downcase + %td.accounts-table__count.optional + = Setting.hide_followers_count ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) + %small= t('accounts.followers', count: account.followers_count).downcase %td.accounts-table__count - if account.last_status_at.present? %time.time-ago{ datetime: account.last_status_at.iso8601, title: l(account.last_status_at) }= l account.last_status_at -- cgit From bd23288a527bbbe0f8dcdf2a6ad3a585e4aed740 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 18 Dec 2018 11:24:44 +0100 Subject: Add a per-user setting to hide followers count This is only available if the instance-wide setting isn't set and allows people to hide their own followers count. This does not hide others' to them. --- app/controllers/follower_accounts_controller.rb | 2 +- app/controllers/settings/preferences_controller.rb | 1 + app/helpers/stream_entries_helper.rb | 2 +- app/lib/user_settings_decorator.rb | 5 +++++ app/models/user.rb | 2 +- app/serializers/rest/account_serializer.rb | 2 +- app/views/accounts/_header.html.haml | 4 ++-- app/views/directories/index.html.haml | 2 +- app/views/settings/preferences/show.html.haml | 4 ++++ config/locales/simple_form.en.yml | 1 + 10 files changed, 18 insertions(+), 7 deletions(-) (limited to 'app/views/directories') diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index 13043b1b9..f985f0eff 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -37,7 +37,7 @@ class FollowerAccountsController < ApplicationController def collection_presenter options = { type: :ordered } - options[:size] = @account.followers_count unless Setting.hide_followers_count + options[:size] = @account.followers_count unless Setting.hide_followers_count || @account.user&.setting_hide_followers_count if params[:page].present? ActivityPub::CollectionPresenter.new( id: account_followers_url(@account, page: params.fetch(:page, 1)), diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index b70844b65..d4932afd6 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -43,6 +43,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_system_font_ui, :setting_noindex, :setting_hide_network, + :setting_hide_followers_count, :setting_aggregate_reblogs, notification_emails: %i(follow follow_request reblog favourite mention digest report), interactions: %i(must_be_follower must_be_following) diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb index e37cfbda4..fce03d03e 100644 --- a/app/helpers/stream_entries_helper.rb +++ b/app/helpers/stream_entries_helper.rb @@ -73,7 +73,7 @@ module StreamEntriesHelper ].join(' '), ] - unless Setting.hide_followers_count + unless Setting.hide_followers_count || account.user&.setting_hide_followers_count prepend_stats << [ number_to_human(account.followers_count, strip_insignificant_zeros: true), I18n.t('accounts.followers', count: account.followers_count), diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 559e00d20..569255f6e 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -30,6 +30,7 @@ class UserSettingsDecorator user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion') user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui') user.settings['noindex'] = noindex_preference if change?('setting_noindex') + user.settings['hide_followers_count']= hide_followers_count_preference if change?('setting_hide_followers_count') user.settings['flavour'] = flavour_preference if change?('setting_flavour') user.settings['skin'] = skin_preference if change?('setting_skin') user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network') @@ -92,6 +93,10 @@ class UserSettingsDecorator boolean_cast_setting 'setting_noindex' end + def hide_followers_count_preference + boolean_cast_setting 'setting_hide_followers_count' + end + def flavour_preference settings['setting_flavour'] end diff --git a/app/models/user.rb b/app/models/user.rb index 66896257a..a6c25342a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -94,7 +94,7 @@ class User < ApplicationRecord has_many :session_activations, dependent: :destroy delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal, - :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, + :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count, :expand_spoilers, :default_language, :aggregate_reblogs, to: :settings, prefix: :setting, allow_nil: false attr_reader :invite_code diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index a3f2ad036..c34d23452 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -53,6 +53,6 @@ class REST::AccountSerializer < ActiveModel::Serializer end def followers_count - Setting.hide_followers_count ? -1 : object.followers_count + (Setting.hide_followers_count || object.user&.setting_hide_followers_count) ? -1 : object.followers_count end end diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 458c86ce5..87cb0a91f 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -24,8 +24,8 @@ %span.counter-label= t('accounts.following', count: account.following_count) .counter{ class: active_nav_class(account_followers_url(account)) } - = link_to account_followers_url(account), title: Setting.hide_followers_count ? nil : number_with_delimiter(account.followers_count) do - %span.counter-number= Setting.hide_followers_count ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) + = link_to account_followers_url(account), title: (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? nil : number_with_delimiter(account.followers_count) do + %span.counter-number= (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) %span.counter-label= t('accounts.followers', count: account.followers_count) .spacer .public-account-header__tabs__tabs__buttons diff --git a/app/views/directories/index.html.haml b/app/views/directories/index.html.haml index 8d136a31f..0dc5e7d76 100644 --- a/app/views/directories/index.html.haml +++ b/app/views/directories/index.html.haml @@ -29,7 +29,7 @@ = number_to_human account.statuses_count, strip_insignificant_zeros: true %small= t('accounts.posts', count: account.statuses_count).downcase %td.accounts-table__count.optional - = Setting.hide_followers_count ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) + = (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) %small= t('accounts.followers', count: account.followers_count).downcase %td.accounts-table__count - if account.last_status_at.present? diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 53390b6d1..6510e0560 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -34,6 +34,10 @@ .fields-group = f.input :setting_hide_network, as: :boolean, wrapper: :with_label + - unless Setting.hide_followers_count + .fields-group + = f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label + %hr#settings_web/ .fields-group diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index ed6e6faa0..2976eee6e 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -79,6 +79,7 @@ en: setting_display_media_show_all: Show all setting_expand_spoilers: Always expand toots marked with content warnings setting_favourite_modal: Show confirmation dialog before favouriting (applies to Glitch flavour only) + setting_hide_followers_count: Hide your followers count setting_hide_network: Hide your network setting_noindex: Opt-out of search engine indexing setting_reduce_motion: Reduce motion in animations -- cgit From bc113927d6abc0e629acd0450ea187538155d2a1 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 18 Dec 2018 14:26:21 +0100 Subject: Move hide_followers_count logic to an helper --- app/helpers/stream_entries_helper.rb | 6 +++++- app/views/accounts/_header.html.haml | 4 ++-- app/views/directories/index.html.haml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'app/views/directories') diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb index fce03d03e..46ef04343 100644 --- a/app/helpers/stream_entries_helper.rb +++ b/app/helpers/stream_entries_helper.rb @@ -60,6 +60,10 @@ module StreamEntriesHelper end end + def hide_followers_count(account) + Setting.hide_followers_count || account.user&.setting_hide_followers_count + end + def account_description(account) prepend_stats = [ [ @@ -73,7 +77,7 @@ module StreamEntriesHelper ].join(' '), ] - unless Setting.hide_followers_count || account.user&.setting_hide_followers_count + unless hide_followers_count(account) prepend_stats << [ number_to_human(account.followers_count, strip_insignificant_zeros: true), I18n.t('accounts.followers', count: account.followers_count), diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 87cb0a91f..a40ecb0d4 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -24,8 +24,8 @@ %span.counter-label= t('accounts.following', count: account.following_count) .counter{ class: active_nav_class(account_followers_url(account)) } - = link_to account_followers_url(account), title: (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? nil : number_with_delimiter(account.followers_count) do - %span.counter-number= (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) + = link_to account_followers_url(account), title: hide_followers_count(account) ? nil : number_with_delimiter(account.followers_count) do + %span.counter-number= hide_followers_count(account) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) %span.counter-label= t('accounts.followers', count: account.followers_count) .spacer .public-account-header__tabs__tabs__buttons diff --git a/app/views/directories/index.html.haml b/app/views/directories/index.html.haml index 0dc5e7d76..4189ce897 100644 --- a/app/views/directories/index.html.haml +++ b/app/views/directories/index.html.haml @@ -29,7 +29,7 @@ = number_to_human account.statuses_count, strip_insignificant_zeros: true %small= t('accounts.posts', count: account.statuses_count).downcase %td.accounts-table__count.optional - = (Setting.hide_followers_count || account.user&.setting_hide_followers_count) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) + = hide_followers_count(account) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true) %small= t('accounts.followers', count: account.followers_count).downcase %td.accounts-table__count - if account.last_status_at.present? -- cgit