]> cat aescling's git repositories - mastodon.git/commitdiff
Add admin setting to disable followers count
authorThibaut Girka <thib@sitedethib.com>
Mon, 17 Dec 2018 19:36:30 +0000 (20:36 +0100)
committerThibG <thib@sitedethib.com>
Thu, 20 Dec 2018 13:51:12 +0000 (14:51 +0100)
app/controllers/admin/settings_controller.rb
app/controllers/follower_accounts_controller.rb
app/helpers/stream_entries_helper.rb
app/models/form/admin_settings.rb
app/serializers/rest/account_serializer.rb
app/views/accounts/_header.html.haml
app/views/admin/settings/edit.html.haml
app/views/directories/index.html.haml
config/locales/en.yml
config/settings.yml

index 76b3c3a2b29d28606ee29fe0e71da7da5ca81f31..9624df96bf50d8476cc2e653be3341f05b9dbc91 100644 (file)
@@ -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(
index 461e6d70e7c4e7b886997bc0792e1dbf502860f0..13043b1b98385a9d6b7e2b884801a32e10bde160 100644 (file)
@@ -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)),
index 033d435c49780920e2902d23ab06491bb61de2bd..e37cfbda4854fb987ad0b7ee918aa78272e13996 100644 (file)
@@ -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)
index 34c75e3bfb6fcfa81fed5e5951e2cc269c58fccf..d568200ed05de4f257ad911f95c5053d72655c10 100644 (file)
@@ -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,
index 12adc971cb76a6894338b2dcf342d34026b287a3..a3f2ad036c4abc4f32e246a9127dbf5ada0eade0 100644 (file)
@@ -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
index 370e7e470f50dc6aa3decb02695fbce3afa058a4..458c86ce508e7888ba2e12db4214fc63c6a94b9a 100644 (file)
@@ -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
index bcf57aac0fd3216998a7b5841bb638deb90ea1ad..e3ceb4344fe61f191a967ca7f28b4c0358ae2c8d 100644 (file)
@@ -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
index 88706def7b7fc93725c72a0f63af0c787d06bed3..7f6ad13e66abc7ed78a8abdb6da0a110cd546c30 100644 (file)
                 %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
index 735a88efddf088b1b6f43e0bc5f6da61a2f76a46..e722788feac9e9b2d6f5c41d46584889c767a16e 100644 (file)
@@ -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
index 2cac28b6372babfabbcdb19fba6b0945a04747a0..bd6578bd42740b8db2bd8a528081c6388e596472 100644 (file)
@@ -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