* Add: #883 管理者の設定したカスタムCSSをユーザー単位で無効にするオプション * ラベル変更
This commit is contained in:
parent
b30086dc6b
commit
943db145e4
12 changed files with 56 additions and 14 deletions
|
@ -13,17 +13,7 @@ class CustomCssController < ActionController::Base # rubocop:disable Rails/Appli
|
||||||
def custom_css_styles
|
def custom_css_styles
|
||||||
Setting.custom_css
|
Setting.custom_css
|
||||||
end
|
end
|
||||||
|
helper_method :custom_css_styles
|
||||||
def user_custom_css?
|
|
||||||
return false if current_user.nil?
|
|
||||||
|
|
||||||
current_user.setting_use_custom_css && current_user.custom_css_text.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_custom_css
|
|
||||||
current_user.custom_css_text
|
|
||||||
end
|
|
||||||
helper_method :custom_css_styles, :user_custom_css?, :user_custom_css
|
|
||||||
|
|
||||||
def set_user_roles
|
def set_user_roles
|
||||||
@user_roles = UserRole.providing_styles
|
@user_roles = UserRole.providing_styles
|
||||||
|
|
16
app/controllers/system_css_controller.rb
Normal file
16
app/controllers/system_css_controller.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class SystemCssController < ActionController::Base # rubocop:disable Rails/ApplicationController
|
||||||
|
before_action :set_user_roles
|
||||||
|
|
||||||
|
def show
|
||||||
|
expires_in 3.minutes, public: true
|
||||||
|
render content_type: 'text/css'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_user_roles
|
||||||
|
@user_roles = UserRole.providing_styles
|
||||||
|
end
|
||||||
|
end
|
|
@ -235,6 +235,12 @@ module ApplicationHelper
|
||||||
full_asset_url(instance_presenter.mascot&.file&.url || frontend_asset_path('images/elephant_ui_plane.svg'))
|
full_asset_url(instance_presenter.mascot&.file&.url || frontend_asset_path('images/elephant_ui_plane.svg'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def server_css?
|
||||||
|
return true if current_account&.user.nil?
|
||||||
|
|
||||||
|
current_account.user.setting_use_server_css
|
||||||
|
end
|
||||||
|
|
||||||
def user_custom_css?
|
def user_custom_css?
|
||||||
return false if current_account&.user.nil?
|
return false if current_account&.user.nil?
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,10 @@ module User::HasSettings
|
||||||
settings['web.hide_favourite_menu']
|
settings['web.hide_favourite_menu']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setting_use_server_css
|
||||||
|
settings['web.use_server_css']
|
||||||
|
end
|
||||||
|
|
||||||
def setting_use_custom_css
|
def setting_use_custom_css
|
||||||
settings['web.use_custom_css']
|
settings['web.use_custom_css']
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,6 +55,7 @@ class UserSettings
|
||||||
setting :use_blurhash, default: true
|
setting :use_blurhash, default: true
|
||||||
setting :use_pending_items, default: false
|
setting :use_pending_items, default: false
|
||||||
setting :use_system_font, default: false
|
setting :use_system_font, default: false
|
||||||
|
setting :use_server_css, default: true
|
||||||
setting :use_custom_css, default: false
|
setting :use_custom_css, default: false
|
||||||
setting :content_font_size, default: 'medium', in: %w(medium large x_large xx_large)
|
setting :content_font_size, default: 'medium', in: %w(medium large x_large xx_large)
|
||||||
setting :bookmark_category_needed, default: false
|
setting :bookmark_category_needed, default: false
|
||||||
|
|
6
app/views/custom_css/show_system.css.erb
Normal file
6
app/views/custom_css/show_system.css.erb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<%- @user_roles.each do |role| %>
|
||||||
|
.user-role-<%= role.id %> {
|
||||||
|
--user-role-accent: <%= role.color %>;
|
||||||
|
}
|
||||||
|
|
||||||
|
<%- end %>
|
|
@ -34,7 +34,10 @@
|
||||||
= csrf_meta_tags unless skip_csrf_meta_tags?
|
= csrf_meta_tags unless skip_csrf_meta_tags?
|
||||||
%meta{ name: 'style-nonce', content: request.content_security_policy_nonce }
|
%meta{ name: 'style-nonce', content: request.content_security_policy_nonce }
|
||||||
|
|
||||||
|
- if server_css?
|
||||||
= stylesheet_link_tag custom_css_path, skip_pipeline: true, host: root_url, media: 'all'
|
= stylesheet_link_tag custom_css_path, skip_pipeline: true, host: root_url, media: 'all'
|
||||||
|
- else
|
||||||
|
= stylesheet_link_tag system_css_path, skip_pipeline: true, host: root_url, media: 'all'
|
||||||
|
|
||||||
- if user_custom_css?
|
- if user_custom_css?
|
||||||
= stylesheet_link_tag user_custom_css_path({ version: user_custom_css_version }), skip_pipeline: true, host: root_url, media: 'all'
|
= stylesheet_link_tag user_custom_css_path({ version: user_custom_css_version }), skip_pipeline: true, host: root_url, media: 'all'
|
||||||
|
|
|
@ -8,6 +8,13 @@
|
||||||
= render 'shared/error_messages', object: current_user
|
= render 'shared/error_messages', object: current_user
|
||||||
|
|
||||||
= f.simple_fields_for :settings, current_user.settings do |ff|
|
= f.simple_fields_for :settings, current_user.settings do |ff|
|
||||||
|
.fields-group
|
||||||
|
= ff.input :'web.use_server_css',
|
||||||
|
hint: false,
|
||||||
|
label: I18n.t('simple_form.labels.defaults.setting_use_server_css'),
|
||||||
|
kmyblue: true,
|
||||||
|
wrapper: :with_label
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= ff.input :'web.use_custom_css',
|
= ff.input :'web.use_custom_css',
|
||||||
hint: false,
|
hint: false,
|
||||||
|
|
6
app/views/system_css/show.css.erb
Normal file
6
app/views/system_css/show.css.erb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<%- @user_roles.each do |role| %>
|
||||||
|
.user-role-<%= role.id %> {
|
||||||
|
--user-role-accent: <%= role.color %>;
|
||||||
|
}
|
||||||
|
|
||||||
|
<%- end %>
|
|
@ -329,9 +329,10 @@ en:
|
||||||
setting_trends: Show today's trends
|
setting_trends: Show today's trends
|
||||||
setting_unfollow_modal: Show confirmation dialog before unfollowing someone
|
setting_unfollow_modal: Show confirmation dialog before unfollowing someone
|
||||||
setting_use_blurhash: Show colorful gradients for hidden media
|
setting_use_blurhash: Show colorful gradients for hidden media
|
||||||
setting_use_custom_css: Enable custom CSS
|
setting_use_custom_css: Enable custom CSS set by yourself
|
||||||
setting_use_pending_items: Slow mode
|
setting_use_pending_items: Slow mode
|
||||||
setting_use_public_index: Include permitted accounts post to results of search
|
setting_use_public_index: Include permitted accounts post to results of search
|
||||||
|
setting_use_server_css: Enable server CSS set by the administrator
|
||||||
severity: Severity
|
severity: Severity
|
||||||
sign_in_token_attempt: Security code
|
sign_in_token_attempt: Security code
|
||||||
title: Title
|
title: Title
|
||||||
|
|
|
@ -329,9 +329,10 @@ ja:
|
||||||
setting_trends: 本日のトレンドタグを表示する
|
setting_trends: 本日のトレンドタグを表示する
|
||||||
setting_unfollow_modal: フォローを解除する前に確認ダイアログを表示する
|
setting_unfollow_modal: フォローを解除する前に確認ダイアログを表示する
|
||||||
setting_use_blurhash: 非表示のメディアを色付きのぼかしで表示する
|
setting_use_blurhash: 非表示のメディアを色付きのぼかしで表示する
|
||||||
setting_use_custom_css: カスタムCSSを有効にする
|
setting_use_custom_css: あなた自身が設定する以下のカスタムCSSを有効にする
|
||||||
setting_use_pending_items: 手動更新モード
|
setting_use_pending_items: 手動更新モード
|
||||||
setting_use_public_index: Mastodonの標準設定によって検索が許可されたアカウントの公開投稿を検索結果に含める
|
setting_use_public_index: Mastodonの標準設定によって検索が許可されたアカウントの公開投稿を検索結果に含める
|
||||||
|
setting_use_server_css: 管理者の設定したカスタムCSSを有効にする
|
||||||
severity: 重大性
|
severity: 重大性
|
||||||
sign_in_token_attempt: セキュリティコード
|
sign_in_token_attempt: セキュリティコード
|
||||||
title: タイトル
|
title: タイトル
|
||||||
|
|
|
@ -94,6 +94,7 @@ Rails.application.routes.draw do
|
||||||
get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
|
get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
|
||||||
get 'intent', to: 'intents#show'
|
get 'intent', to: 'intents#show'
|
||||||
get 'custom.css', to: 'custom_css#show', as: :custom_css
|
get 'custom.css', to: 'custom_css#show', as: :custom_css
|
||||||
|
get 'system.css', to: 'system_css#show', as: :system_css
|
||||||
get 'user_custom.css', to: 'user_custom_css#show', as: :user_custom_css
|
get 'user_custom.css', to: 'user_custom_css#show', as: :user_custom_css
|
||||||
|
|
||||||
get 'remote_interaction_helper', to: 'remote_interaction_helper#index'
|
get 'remote_interaction_helper', to: 'remote_interaction_helper#index'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue