about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/forms.scss7
-rw-r--r--app/controllers/settings/preferences_controller.rb3
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/status.rb5
-rw-r--r--app/views/settings/preferences/show.html.haml10
5 files changed, 26 insertions, 1 deletions
diff --git a/app/assets/stylesheets/forms.scss b/app/assets/stylesheets/forms.scss
index 890a00510..18258099b 100644
--- a/app/assets/stylesheets/forms.scss
+++ b/app/assets/stylesheets/forms.scss
@@ -326,3 +326,10 @@ code {
     flex: 0 0 auto;
   }
 }
+
+.user_allowed_languages {
+  li {
+    float: left;
+    width: 50%;
+  }
+}
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 6762faee4..04a85849d 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -25,7 +25,8 @@ class Settings::PreferencesController < ApplicationController
 
   def user_params
     params.require(:user).permit(
-      :locale
+      :locale,
+      allowed_languages: []
     )
   end
 
diff --git a/app/models/account.rb b/app/models/account.rb
index 03584b4e6..c5fc6d7ab 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -82,6 +82,8 @@ class Account < ApplicationRecord
            prefix: true,
            allow_nil: true
 
+  delegate :allowed_languages, to: :user, prefix: false, allow_nil: true
+
   def follow!(other_account)
     active_relationships.where(target_account: other_account).first_or_create!(target_account: other_account)
   end
diff --git a/app/models/status.rb b/app/models/status.rb
index f005813e5..3243d1ecb 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -119,6 +119,10 @@ class Status < ApplicationRecord
   end
 
   class << self
+    def in_allowed_languages(account)
+      where(language: account.allowed_languages)
+    end
+
     def as_home_timeline(account)
       where(account: [account] + account.following)
     end
@@ -198,6 +202,7 @@ class Status < ApplicationRecord
 
     def filter_timeline_for_account(query, account)
       query = query.not_excluded_by_account(account)
+      query = query.in_allowed_languages(account) if account.allowed_languages.present?
       query.merge(account_silencing_filter(account))
     end
 
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index 8a4113ab4..10618ebf6 100644
--- a/app/views/settings/preferences/show.html.haml
+++ b/app/views/settings/preferences/show.html.haml
@@ -7,6 +7,16 @@
   .fields-group
     = f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }
 
+    = f.input :allowed_languages,
+      collection: I18n.available_locales,
+      wrapper: :with_label,
+      include_blank: false,
+      label_method: lambda { |locale| human_locale(locale) },
+      required: false,
+      as: :check_boxes,
+      collection_wrapper_tag: 'ul',
+      item_wrapper_tag: 'li'
+
     = f.input :setting_default_privacy, collection: Status.visibilities.keys - ['direct'], wrapper: :with_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), content_tag(:span, I18n.t("statuses.visibilities.#{visibility}_long"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
 
   .fields-group