Skip to content
Snippets Groups Projects
Unverified Commit 8e35724c authored by Sébastien Gaya's avatar Sébastien Gaya Committed by GitHub
Browse files

Merge pull request #832 from noesya/fix/websites-routes

fix website route & layout preview
parents 7f9d20ee 917d941b
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ module Communication::Website::WithStyle
extend ActiveSupport::Concern
def preview_style
load_style if style_outdated?
load_style if style_outdated?
style
end
......@@ -10,13 +10,21 @@ module Communication::Website::WithStyle
def load_style
@style = ''
load_style_from url
load_style_from_website_url if url.present?
load_style_from_example
substitute_fonts_urls_in_style!
self.update_columns style: @style,
style_updated_at: Date.today
end
def load_style_from_website_url
load_style_from url
load_style_from "#{url}/fr" if @style.blank?
load_style_from "#{url}/en" if @style.blank?
end
def load_style_from_example
load_style_from "https://example.osuny.org" if @style.blank?
substitute_fonts_urls_in_style!
self.update_columns style: @style,
style_updated_at: Date.today
end
def load_style_from(url)
......@@ -39,7 +47,7 @@ module Communication::Website::WithStyle
end
def style_outdated?
style_updated_at.nil? || style_updated_at < Date.yesterday
style_updated_at.nil? || style_updated_at < Date.yesterday
end
end
\ No newline at end of file
......@@ -7,7 +7,7 @@
<% if @website %>
<link rel="stylesheet" media="all" href="<%= style_admin_communication_website_path @website.id, website_id: nil %>" />
<% else %>
<%= stylesheet_link_tag 'admin', media: 'all' %>
<%= stylesheet_link_tag 'admin/pure', media: 'all' %>
<% end %>
</head>
<body>
......
......@@ -5,12 +5,10 @@ namespace :communication do
end
resources :websites do
member do
scope '/:lang' do
get :import
post :import
get :style
get :analytics
end
get :import
post :import
get :style
get :analytics
end
resources :pages, controller: 'websites/pages', path: '/:lang/pages' do
collection do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment