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 ...@@ -2,7 +2,7 @@ module Communication::Website::WithStyle
extend ActiveSupport::Concern extend ActiveSupport::Concern
def preview_style def preview_style
load_style if style_outdated? load_style if style_outdated?
style style
end end
...@@ -10,13 +10,21 @@ module Communication::Website::WithStyle ...@@ -10,13 +10,21 @@ module Communication::Website::WithStyle
def load_style def load_style
@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}/fr" if @style.blank?
load_style_from "#{url}/en" 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? 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 end
def load_style_from(url) def load_style_from(url)
...@@ -39,7 +47,7 @@ module Communication::Website::WithStyle ...@@ -39,7 +47,7 @@ module Communication::Website::WithStyle
end end
def style_outdated? def style_outdated?
style_updated_at.nil? || style_updated_at < Date.yesterday style_updated_at.nil? || style_updated_at < Date.yesterday
end end
end end
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<% if @website %> <% if @website %>
<link rel="stylesheet" media="all" href="<%= style_admin_communication_website_path @website.id, website_id: nil %>" /> <link rel="stylesheet" media="all" href="<%= style_admin_communication_website_path @website.id, website_id: nil %>" />
<% else %> <% else %>
<%= stylesheet_link_tag 'admin', media: 'all' %> <%= stylesheet_link_tag 'admin/pure', media: 'all' %>
<% end %> <% end %>
</head> </head>
<body> <body>
......
...@@ -5,12 +5,10 @@ namespace :communication do ...@@ -5,12 +5,10 @@ namespace :communication do
end end
resources :websites do resources :websites do
member do member do
scope '/:lang' do get :import
get :import post :import
post :import get :style
get :style get :analytics
get :analytics
end
end end
resources :pages, controller: 'websites/pages', path: '/:lang/pages' do resources :pages, controller: 'websites/pages', path: '/:lang/pages' do
collection 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