From 6cb3514d64ec24b164484f4eb84363b96746d5d6 Mon Sep 17 00:00:00 2001 From: Jakub Mendyk Date: Thu, 23 Aug 2018 14:17:35 +0200 Subject: Add ability to change an instance default theme from the administration panel (#7092) (#8381) * Add default_settings class method to ScopedSettings ScopedSettings was extended to use value of unscoped setting instead of only using defaults set in config/settings.yml for selected settings. This adds possibility for admins to set default values of users' settings, for example default theme (as requested in #7092). * Add ability to change an instance default theme Closes #7092 --- app/views/admin/settings/edit.html.haml | 1 + 1 file changed, 1 insertion(+) (limited to 'app/views') diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index fda6b00f4..b5aa176a2 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -15,6 +15,7 @@ %hr/ .fields-group + = f.input :theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, include_blank: false = f.input :thumbnail, as: :file, wrapper: :with_block_label, label: t('admin.settings.thumbnail.title'), hint: t('admin.settings.thumbnail.desc_html') = f.input :hero, as: :file, wrapper: :with_block_label, label: t('admin.settings.hero.title'), hint: t('admin.settings.hero.desc_html') -- cgit From 69ba8f063c43139f811a747a3c17feadd29d423a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 23 Aug 2018 19:11:41 +0200 Subject: When registrations closed, link "Sign up" to joinmastodon.org (#8395) Fix #8393 --- app/views/auth/shared/_links.html.haml | 2 +- app/views/layouts/public.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/views') diff --git a/app/views/auth/shared/_links.html.haml b/app/views/auth/shared/_links.html.haml index 08b385092..516c625a6 100644 --- a/app/views/auth/shared/_links.html.haml +++ b/app/views/auth/shared/_links.html.haml @@ -3,7 +3,7 @@ %li= link_to t('auth.login'), new_session_path(resource_name) - if devise_mapping.registerable? && controller_name != 'registrations' - %li= link_to t('auth.register'), new_registration_path(resource_name) + %li= link_to t('auth.register'), open_registrations? ? new_registration_path(resource_name) : 'https://joinmastodon.org/#getting-started' - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %li= link_to t('auth.forgot_password'), new_password_path(resource_name) diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index ca9dac8bb..6bf7efb23 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -14,7 +14,7 @@ = link_to t('settings.back'), root_url, class: 'nav-link nav-button webapp-btn' - else = link_to t('auth.login'), new_user_session_path, class: 'webapp-btn nav-link nav-button' - = link_to t('auth.register'), new_user_registration_path, class: 'webapp-btn nav-link nav-button' + = link_to t('auth.register'), open_registrations? ? new_user_registration_path : 'https://joinmastodon.org/#getting-started', class: 'webapp-btn nav-link nav-button' .container= yield -- cgit From a2cabf3f4af9271d8bfdb13c1ae2b7a8b4e6fb88 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 24 Aug 2018 04:33:27 +0200 Subject: Add admin custom CSS setting (#8399) Fix #3894 --- app/controllers/admin/settings_controller.rb | 1 + app/controllers/custom_css_controller.rb | 10 ++++++++++ app/javascript/styles/mastodon/forms.scss | 11 +++++++++++ app/models/form/admin_settings.rb | 2 ++ app/presenters/instance_presenter.rb | 2 +- app/views/admin/settings/edit.html.haml | 2 +- app/views/layouts/application.html.haml | 3 +++ config/routes.rb | 1 + 8 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 app/controllers/custom_css_controller.rb (limited to 'app/views') diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 23e0444d0..7d38f76ae 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -24,6 +24,7 @@ module Admin peers_api_enabled show_known_fediverse_at_about_page preview_sensitive_media + custom_css ).freeze BOOLEAN_SETTINGS = %w( diff --git a/app/controllers/custom_css_controller.rb b/app/controllers/custom_css_controller.rb new file mode 100644 index 000000000..31e501609 --- /dev/null +++ b/app/controllers/custom_css_controller.rb @@ -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 diff --git a/app/javascript/styles/mastodon/forms.scss b/app/javascript/styles/mastodon/forms.scss index 020be5ad2..144b4a519 100644 --- a/app/javascript/styles/mastodon/forms.scss +++ b/app/javascript/styles/mastodon/forms.scss @@ -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; + } +} diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index db46cda7b..9fef7da97 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -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 diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb index 31365b646..a4e4af889 100644 --- a/app/presenters/instance_presenter.rb +++ b/app/presenters/instance_presenter.rb @@ -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 diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index b5aa176a2..f40edc35a 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -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 diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index df898d5a2..68a903197 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -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 || '' diff --git a/config/routes.rb b/config/routes.rb index 80a8b7b4c..0e54157dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 -- cgit