Browse Source

Add admin custom CSS setting (#8399)

Fix #3894
master
Eugen Rochko 5 years ago
committed by GitHub
parent
commit
a2cabf3f4a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 2 deletions
  1. +1
    -0
      app/controllers/admin/settings_controller.rb
  2. +10
    -0
      app/controllers/custom_css_controller.rb
  3. +11
    -0
      app/javascript/styles/mastodon/forms.scss
  4. +2
    -0
      app/models/form/admin_settings.rb
  5. +1
    -1
      app/presenters/instance_presenter.rb
  6. +1
    -1
      app/views/admin/settings/edit.html.haml
  7. +3
    -0
      app/views/layouts/application.html.haml
  8. +1
    -0
      config/routes.rb

+ 1
- 0
app/controllers/admin/settings_controller.rb View File

@@ -24,6 +24,7 @@ module Admin
peers_api_enabled
show_known_fediverse_at_about_page
preview_sensitive_media
custom_css
).freeze

BOOLEAN_SETTINGS = %w(


+ 10
- 0
app/controllers/custom_css_controller.rb View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true

class CustomCssController < ApplicationController
before_action :set_cache_headers

def show
skip_session!
render plain: Setting.custom_css || '', content_type: 'text/css'
end
end

+ 11
- 0
app/javascript/styles/mastodon/forms.scss View File

@@ -621,3 +621,14 @@ code {
.scope-danger {
color: $warning-red;
}

.form_admin_settings_site_short_description,
.form_admin_settings_site_description,
.form_admin_settings_site_extended_description,
.form_admin_settings_site_terms,
.form_admin_settings_custom_css,
.form_admin_settings_closed_registrations_message {
textarea {
font-family: 'mastodon-font-monospace', monospace;
}
}

+ 2
- 0
app/models/form/admin_settings.rb View File

@@ -42,6 +42,8 @@ class Form::AdminSettings
:show_known_fediverse_at_about_page=,
:preview_sensitive_media,
:preview_sensitive_media=,
:custom_css,
:custom_css=,
to: Setting
)
end

+ 1
- 1
app/presenters/instance_presenter.rb View File

@@ -14,7 +14,7 @@ class InstancePresenter
)

def contact_account
Account.find_local(Setting.site_contact_username)
Account.find_local(Setting.site_contact_username.gsub(/\A@/, ''))
end

def user_count


+ 1
- 1
app/views/admin/settings/edit.html.haml View File

@@ -49,7 +49,7 @@
.fields-group
= f.input :site_extended_description, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_description_extended.title'), hint: t('admin.settings.site_description_extended.desc_html'), input_html: { rows: 8 }
= f.input :site_terms, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_terms.title'), hint: t('admin.settings.site_terms.desc_html'), input_html: { rows: 8 }
= f.input :custom_css, wrapper: :with_block_label, as: :text, input_html: { rows: 8 }, label: t('admin.settings.custom_css.title'), hint: t('admin.settings.custom_css.desc_html')
%hr/

.fields-group


+ 3
- 0
app/views/layouts/application.html.haml View File

@@ -19,6 +19,9 @@
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
= csrf_meta_tags

- if Setting.custom_css.present?
= stylesheet_link_tag custom_css_path, media: 'all'

= yield :header_tags

- body_classes ||= @body_classes || ''


+ 1
- 0
config/routes.rb View File

@@ -23,6 +23,7 @@ Rails.application.routes.draw do
get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
get 'intent', to: 'intents#show'
get 'custom.css', to: 'custom_css#show', as: :custom_css

devise_scope :user do
get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite


Loading…
Cancel
Save