Add: #406 ユーザーのカスタムCSS (#825)

* Add: #406 ユーザーのカスタムCSS

* Fix lint

* Fix lint

* カスタムCSSの保存先を変更

* キャッシュを考慮して別URLに変更
This commit is contained in:
KMY(雪あすか) 2024-08-29 07:55:01 +09:00 committed by GitHub
parent 5ffd7593f1
commit 665c632d66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 283 additions and 4 deletions

View file

@ -101,6 +101,8 @@ class User < ApplicationRecord
accepts_nested_attributes_for :invite_request, reject_if: ->(attributes) { attributes['text'].blank? && !Setting.require_invite_text }
validates :invite_request, presence: true, on: :create, if: :invite_text_required?
has_one :custom_css, inverse_of: :user, dependent: :destroy
validates :email, presence: true, email_address: true
validates_with UserEmailValidator, if: -> { ENV['EMAIL_DOMAIN_LISTS_APPLY_AFTER_CONFIRMATION'] == 'true' || !confirmed? }
@ -227,6 +229,22 @@ class User < ApplicationRecord
prepare_returning_user!
end
def disable_css
false
end
def custom_css_text
custom_css&.css.to_s
end
def custom_css_text=(val)
if custom_css.present?
custom_css.update!(css: val)
else
CustomCss.create!(user: self, css: val)
end
end
def pending?
!approved?
end