From 477f89c275b906861c855e0398be5f3d6cd5285f Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 22 Jul 2022 18:12:50 +0200 Subject: [PATCH] preview style --- app/models/communication/website/with_style.rb | 6 +++++- app/views/admin/layouts/preview.html.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/communication/website/with_style.rb b/app/models/communication/website/with_style.rb index 831c7c4c7..b4591010d 100644 --- a/app/models/communication/website/with_style.rb +++ b/app/models/communication/website/with_style.rb @@ -2,11 +2,15 @@ module Communication::Website::WithStyle extend ActiveSupport::Concern def preview_style - return '' if url.blank? + return '' unless has_style? load_style if style_outdated? style end + def has_style? + !url.blank? + end + protected def load_style diff --git a/app/views/admin/layouts/preview.html.erb b/app/views/admin/layouts/preview.html.erb index 791854a7d..fb153506c 100644 --- a/app/views/admin/layouts/preview.html.erb +++ b/app/views/admin/layouts/preview.html.erb @@ -4,7 +4,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title><%= yield :title %></title> - <% if @website %> + <% if @website && @website.has_style? %> <link rel="stylesheet" media="all" href="<%= style_admin_communication_website_path @website.id, website_id: nil %>" /> <% else %> <%= stylesheet_link_tag 'admin', media: 'all' %> -- GitLab