From 57e21cf47e7c1bf0b5f1c034e756944f9d57fb39 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Tue, 11 Aug 2020 16:32:01 -0500 Subject: [UI] Move CSS for style settings to custom web app CSS controller --- app/controllers/user_webapp_css_controller.rb | 33 ++++++++++++++++++++++++++- app/views/layouts/application.html.haml | 28 ++--------------------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/app/controllers/user_webapp_css_controller.rb b/app/controllers/user_webapp_css_controller.rb index fcfbf9aed..8ad9fbd2e 100644 --- a/app/controllers/user_webapp_css_controller.rb +++ b/app/controllers/user_webapp_css_controller.rb @@ -14,10 +14,41 @@ class UserWebappCssController < ApplicationController private - def css + def css_dashed_nest + return unless @account.user&.setting_style_dashed_nest + + %( + div[data-nest-level] + { border-style: dashed; } + ) + end + + def css_underline_a + return unless @account.user&.setting_style_underline_a + + %( + .status__content__text a, + .reply-indicator__content a, + .composer--reply > .content a, + .account__header__content a + { text-decoration: underline; } + + .status__content__text a:hover, + .reply-indicator__content a:hover, + .composer--reply > .content a:hover, + .account__header__content a:hover + { text-decoration: none; } + ) + end + + def css_webapp @account.user&.setting_style_css_webapp_errors.blank? ? (@account.user&.setting_style_css_webapp || '') : '' end + def css + "#{css_dashed_nest}\n#{css_underline_a}\n#{css_webapp}".squish + end + def set_account @account = Account.find(params[:id]) end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f3f29f43e..34f742c16 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -39,34 +39,10 @@ - if Setting.custom_css.present? = stylesheet_link_tag custom_css_path, media: 'all' - - - if current_account&.user&.setting_style_css_webapp.present? - = stylesheet_link_tag user_webapp_css_path(current_account.id), media: 'all' - - - if current_account&.user&.setting_style_dashed_nest - :css - div[data-nest-level] { - border-style: dashed; - } - - if current_account&.user&.setting_style_underline_a - :css - .status__content__text a, - .reply-indicator__content a, - .composer--reply > .content a, - .account__header__content a - { - text-decoration: underline; - } + - if current_account&.user.present? + = stylesheet_link_tag user_webapp_css_path(current_account.id), media: 'all' - .status__content__text a:hover, - .reply-indicator__content a:hover, - .composer--reply > .content a:hover, - .account__header__content a:hover - { - text-decoration: none; - } - = yield :header_overrides %body{ class: body_classes } -- cgit