]> cat aescling's git repositories - mastodon.git/commitdiff
Moved flavour UI into own prefs tab
authorkibigo! <marrus-sh@users.noreply.github.com>
Mon, 11 Dec 2017 01:56:17 +0000 (17:56 -0800)
committerkibigo! <marrus-sh@users.noreply.github.com>
Mon, 11 Dec 2017 04:32:27 +0000 (20:32 -0800)
app/controllers/settings/flavours_controller.rb [new file with mode: 0644]
app/controllers/settings/preferences_controller.rb
app/javascript/core/settings.js
app/javascript/flavours/glitch/names.yml
app/javascript/flavours/vanilla/names.yml
app/views/settings/flavours/show.html.haml [new file with mode: 0644]
app/views/settings/preferences/show.html.haml
config/locales/en.yml
config/locales/simple_form.en.yml
config/navigation.rb
config/routes.rb

diff --git a/app/controllers/settings/flavours_controller.rb b/app/controllers/settings/flavours_controller.rb
new file mode 100644 (file)
index 0000000..865d5a4
--- /dev/null
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+class Settings::FlavoursController < Settings::BaseController
+
+  def index
+    redirect_to action: 'show', flavour: current_flavour
+  end
+
+  def show
+    unless Themes.instance.flavours.include?(params[:flavour]) or params[:flavour] == current_flavour
+      redirect_to action: 'show', flavour: current_flavour
+    end
+
+    @listing = Themes.instance.flavours
+    @selected = params[:flavour]
+  end
+
+  def update
+    user_settings.update(user_settings_params(params[:flavour]).to_h)
+    redirect_to action: 'show', flavour: params[:flavour]
+  end
+
+  private
+
+  def user_settings
+    UserSettingsDecorator.new(current_user)
+  end
+
+  def user_settings_params(flavour)
+    params.require(:user).merge({ setting_flavour: flavour }).permit(
+      :setting_flavour,
+      :setting_skin
+    )
+  end
+end
index 9177d37da61e1c0e18fff10f2be38073ab1a042c..7cd1abe0c9831cfa3a5cacbad778233055eb818b 100644 (file)
@@ -39,8 +39,6 @@ class Settings::PreferencesController < Settings::BaseController
       :setting_reduce_motion,
       :setting_system_font_ui,
       :setting_noindex,
-      :setting_flavour,
-      :setting_skin,
       notification_emails: %i(follow follow_request reblog favourite mention digest),
       interactions: %i(must_be_follower must_be_following)
     )
index ada5fba2b1d3c50783cb72dd6a357d10b3fa7c33..c9edcf197c71774c4025ee7f7b71e2ba5576c564 100644 (file)
@@ -37,7 +37,3 @@ delegate(document, '#account_header', 'change', ({ target }) => {
 
   header.style.backgroundImage = `url(${url})`;
 });
-
-delegate(document, '#user_setting_flavour, #user_setting_skin', 'change', ({ target }) => {
-  target.form.submit();
-});
index b3d579cb27b3733a250d60d4c705b68fb9ed2546..ef82abed2f285e88a6d54983ea6675464c7e254b 100644 (file)
@@ -1,6 +1,8 @@
 en:
   flavours:
-    glitch: Glitch Edition
+    glitch:
+      description: The default flavour for GlitchSoc instances.
+      name: Glitch Edition
   skins:
     glitch:
       default: Default
index 8816fcb3ab9bd506f588197a53eff21672e7a4a5..94326f6ee3c6157dc8ac10f94d66958dde462586 100644 (file)
@@ -1,6 +1,8 @@
 en:
   flavours:
-    vanilla: Vanilla Mastodon
+    vanilla:
+      description: The theme used by vanilla Mastodon instances. This theme might not support all of the features of GlitchSoc.
+      name: Vanilla Mastodon
   skins:
     vanilla:
       default: Default
diff --git a/app/views/settings/flavours/show.html.haml b/app/views/settings/flavours/show.html.haml
new file mode 100644 (file)
index 0000000..488fd2d
--- /dev/null
@@ -0,0 +1,16 @@
+- content_for :page_title do
+  = t "flavours.#{@selected}.name", default: @selected
+
+= simple_form_for current_user, url: settings_flavour_path(@selected), html: { method: :put } do |f|
+  = render 'shared/error_messages', object: current_user
+
+  .flavour-description
+    = t "flavours.#{@selected}.description", default: ''
+
+  %hr/
+
+  .fields-group
+    = f.input :setting_skin, collection: Themes.instance.skins_for(@selected), label_method: lambda { |skin| I18n.t("skins.#{@selected}.#{skin}", default: skin) }, wrapper: :with_label, include_blank: false
+
+  .actions
+    = f.button :button, t('generic.use_this'), type: :submit
index 45a3b2eb0773585302225f6df5994e4d440f0095..d1459d93ca2a790dcd166de178403e2edc5e662e 100644 (file)
   %h4= t 'preferences.web'
 
   .fields-group
-    - if Themes.instance.flavours.size > 1
-      = f.input :setting_flavour, collection: Themes.instance.flavours, label_method: lambda { |flavour| I18n.t("flavours.#{flavour}", default: flavour) }, wrapper: :with_label, include_blank: false
-      = f.input :setting_skin, collection: Themes.instance.skins_for(current_flavour), label_method: lambda { |skin| I18n.t("skins.#{current_flavour}.#{skin}", default: skin) }, wrapper: :with_label, include_blank: false
-
     = f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label
     = f.input :setting_boost_modal, as: :boolean, wrapper: :with_label
     = f.input :setting_favourite_modal, as: :boolean, wrapper: :with_label
index c8acc237aca38ff85772755d34b1dcc0cd62c99c..804f9b199af4da8fe1b9213d8ec6d38d15192954 100644 (file)
@@ -424,6 +424,7 @@ en:
     changes_saved_msg: Changes successfully saved!
     powered_by: powered by %{link}
     save_changes: Save changes
+    use_this: Use this
     validation_errors:
       one: Something isn't quite right yet! Please review the error below
       other: Something isn't quite right yet! Please review %{count} errors below
@@ -587,6 +588,7 @@ en:
     development: Development
     edit_profile: Edit profile
     export: Data export
+    flavours: Flavours
     followers: Authorized followers
     import: Import
     keyword_mutes: Muted keywords
index 1722eea7bd4f7b4f3fe2ac82bfc158d2a6b16d0f..aa6940e9169afb652f13611d3393fcda9c1c7b96 100644 (file)
@@ -13,7 +13,6 @@ en:
         note:
           one: <span class="note-counter">1</span> character left
           other: <span class="note-counter">%{count}</span> characters left
-        setting_flavour: Affects how Mastodon looks when you're logged in from any device
         setting_noindex: Affects your public profile and status pages
         setting_skin: Reskins the selected Mastodon flavour
       imports:
@@ -47,7 +46,6 @@ en:
         setting_default_sensitive: Always mark media as sensitive
         setting_delete_modal: Show confirmation dialog before deleting a toot
         setting_favourite_modal: Show confirmation dialog before favouriting
-        setting_flavour: Flavour
         setting_noindex: Opt-out of search engine indexing
         setting_reduce_motion: Reduce motion in animations
         setting_skin: Skin
index 3f4c00dfa9d184cec029cebc93be63d316503057..b08b1769de4c697385b1a07ae047da53596e59e6 100644 (file)
@@ -17,6 +17,12 @@ SimpleNavigation::Configuration.run do |navigation|
       settings.item :follower_domains, safe_join([fa_icon('users fw'), t('settings.followers')]), settings_follower_domains_url
     end
 
+    primary.item :flavours, safe_join([fa_icon('paint-brush fw'), t('settings.flavours')]), settings_flavours_url do |flavours|
+      Themes.instance.flavours.each do |flavour|
+        flavours.item flavour.to_sym, safe_join([fa_icon('star fw'), t("flavours.#{flavour}.name", default: flavour)]), settings_flavour_url(flavour)
+      end
+    end
+
     primary.item :invites, safe_join([fa_icon('user-plus fw'), t('invites.title')]), invites_path, if: proc { Setting.min_invite_role == 'user' }
 
     primary.item :development, safe_join([fa_icon('code fw'), t('settings.development')]), settings_applications_url do |development|
index a41e76c2cc77b6f2cde93142715f5f3d4401ecbc..75b9c2d58f1c25cafdf1ee3167ba3a149b7fd3a4 100644 (file)
@@ -102,6 +102,8 @@ Rails.application.routes.draw do
       end
     end
 
+    resources :flavours, only: [:index, :show, :update], param: :flavour
+
     resource :delete, only: [:show, :destroy]
     resource :migration, only: [:show, :update]
 
@@ -240,7 +242,7 @@ Rails.application.routes.draw do
       resources :media,      only: [:create, :update]
       resources :blocks,     only: [:index]
       resources :mutes,      only: [:index] do
-        collection do 
+        collection do
           get 'details'
         end
       end