diff --git a/app/models/communication/website/with_style.rb b/app/models/communication/website/with_style.rb index 1b209ad6ff2a5627b8e8b2121d47475542db7960..bb2220516ecae0e9269fc112c5aa47a93ecbf88a 100644 --- a/app/models/communication/website/with_style.rb +++ b/app/models/communication/website/with_style.rb @@ -10,17 +10,23 @@ module Communication::Website::WithStyle def load_style @style = '' - if url.present? - load_style_from url - load_style_from "#{url}/fr" if @style.blank? - load_style_from "#{url}/en" if @style.blank? - end - load_style_from "https://example.osuny.org" if @style.blank? + 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? + end + def load_style_from(url) data = URI.open url html = Nokogiri::HTML data