diff --git a/app/controllers/admin/communication/extranets_controller.rb b/app/controllers/admin/communication/extranets_controller.rb index 717958ce9cd5444c7928a25283b217b56f492a46..29a4fcffef9ab0e06083d093a3aaa6491b434272 100644 --- a/app/controllers/admin/communication/extranets_controller.rb +++ b/app/controllers/admin/communication/extranets_controller.rb @@ -73,11 +73,13 @@ class Admin::Communication::ExtranetsController < Admin::Communication::Applicat :feature_posts, :has_sso, :host, + :home_sentence, :logo, :logo_delete, :name, :privacy_policy, - :registration_contact, + :registration_contact, + :sass, :sso_target_url, :sso_cert, :sso_name_identifier_format, diff --git a/app/controllers/extranet/style_controller.rb b/app/controllers/extranet/style_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..dea8f4d4b07d08303b30e5c00abfabf28fc330eb --- /dev/null +++ b/app/controllers/extranet/style_controller.rb @@ -0,0 +1,5 @@ +class Extranet::StyleController < Extranet::ApplicationController + def index + render body: current_extranet.css, content_type: 'text/css' + end +end \ No newline at end of file diff --git a/app/models/communication/extranet.rb b/app/models/communication/extranet.rb index ae1a93f4b064453bd522c9f6f6cb0ebbbf51d0ba..ab3057119687b4bd4bbbb82dda400464c2523408 100644 --- a/app/models/communication/extranet.rb +++ b/app/models/communication/extranet.rb @@ -6,16 +6,19 @@ # about_type :string indexed => [about_id] # color :string # cookies_policy :text +# css :text # feature_alumni :boolean default(FALSE) # feature_assets :boolean default(FALSE) # feature_contacts :boolean default(FALSE) # feature_jobs :boolean default(FALSE) # feature_posts :boolean default(FALSE) # has_sso :boolean default(FALSE) +# home_sentence :text # host :string # name :string # privacy_policy :text # registration_contact :string +# sass :text # sso_button_label :string # sso_cert :text # sso_mapping :jsonb @@ -44,6 +47,7 @@ class Communication::Extranet < ApplicationRecord include WithAbouts include WithFeatures include WithLegal + include WithStyle include WithSso include WithUniversity diff --git a/app/models/communication/extranet/with_style.rb b/app/models/communication/extranet/with_style.rb new file mode 100644 index 0000000000000000000000000000000000000000..f3d5e22a20738005e14b489f1e7223eda8ba0b53 --- /dev/null +++ b/app/models/communication/extranet/with_style.rb @@ -0,0 +1,13 @@ +module Communication::Extranet::WithStyle + extend ActiveSupport::Concern + + included do + before_validation :generate_css + end + + protected + + def generate_css + self.css = SassC::Sass2Scss.convert sass + end +end \ No newline at end of file diff --git a/app/views/admin/communication/extranets/_form.html.erb b/app/views/admin/communication/extranets/_form.html.erb index df19b8c67ae8fcb01a6b139f7e71cbef9c4fef3a..62246a4bc018bc966a6e44890cdecf4083468d69 100644 --- a/app/views/admin/communication/extranets/_form.html.erb +++ b/app/views/admin/communication/extranets/_form.html.erb @@ -22,6 +22,8 @@ preview: 100, direct_upload: true %> <%= f.input :color, as: :color %> + <%= f.input :home_sentence %> + <%= f.input :sass %> <% end %> </div> <div class="col-xl-6"> diff --git a/app/views/extranet/application/_head.html.erb b/app/views/extranet/application/_head.html.erb index 8c49787e7e8f1a20a1f3cfcf58fe389588486c40..4609cab2b9793793b613f0ef125b97eb0952d880 100644 --- a/app/views/extranet/application/_head.html.erb +++ b/app/views/extranet/application/_head.html.erb @@ -4,6 +4,7 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> <%= stylesheet_link_tag 'extranet', media: 'all' %> +<link rel="stylesheet" href="<%= extranet_style_path(format: :css) %>" media="all"> <%= javascript_include_tag 'extranet' %> <% if current_extranet.favicon.attached? %> <%= favicon_link_tag url_for(current_extranet.favicon.variant(:thumb)) %> diff --git a/app/views/extranet/home/index.html.erb b/app/views/extranet/home/index.html.erb index 48168a94af5631bcf60db58abcd615011c0db5e8..b821aa90de4ff2f9e76fbf0855a20f5ac336c806 100644 --- a/app/views/extranet/home/index.html.erb +++ b/app/views/extranet/home/index.html.erb @@ -1,13 +1,18 @@ <% content_for :title, current_context %> <% content_for :header do %> - <h1><%# TODO i18n %> - Bienvenue sur l’extranet <%= current_context %>. - Retrouvez les <%= link_to University::Person::Alumnus.model_name.human(count: 2).downcase, university_persons_path %>, - <% if current_extranet.should_show_years? %> - recherchez par <%= link_to Education::AcademicYear.model_name.human(count: 2).downcase, education_academic_years_path %>, + <h1> + <% if current_extranet.home_sentence.present? %> + <%= current_extranet.home_sentence.html_safe %> + <% else %> + <%# TODO i18n %> + Bienvenue sur l’extranet <%= current_context %>. + Retrouvez les <%= link_to University::Person::Alumnus.model_name.human(count: 2).downcase, university_persons_path %>, + <% if current_extranet.should_show_years? %> + recherchez par <%= link_to Education::AcademicYear.model_name.human(count: 2).downcase, education_academic_years_path %>, + <% end %> + explorez les <%= link_to Education::Cohort.model_name.human(count: 2).downcase, education_cohorts_path %>, + découvrez les <%= link_to University::Organization.model_name.human(count: 2).downcase, university_organizations_path %>. <% end %> - explorez les <%= link_to Education::Cohort.model_name.human(count: 2).downcase, education_cohorts_path %>, - découvrez les <%= link_to University::Organization.model_name.human(count: 2).downcase, university_organizations_path %>. </h1> <% end %> diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 1ce3a81f7e1d1cae513859231bea011311b7add5..e7f0e9b1057fe98db3e11af11878db810b5d9ec4 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,5 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf +# Mime::Type.register "text/css", :css Mime::Type.register "application/xml", :xml, %w( text/xml application/x-xml ) diff --git a/config/routes/extranet.rb b/config/routes/extranet.rb index 7ee4169e1cc45f80afe25429ca9ff6ef364cd657..f7a659b44716a575dad287448387960f47bb9663 100644 --- a/config/routes/extranet.rb +++ b/config/routes/extranet.rb @@ -19,4 +19,5 @@ get 'terms' => 'extranet/pages#terms', as: :terms get 'privacy-policy' => 'extranet/pages#privacy_policy', as: :privacy_policy get 'cookies-policy' => 'extranet/pages#cookies_policy', as: :cookies_policy get 'data' => 'extranet/pages#data', as: :data +get 'extranet' => 'extranet/style#index', as: :extranet_style, constraints: { format: 'css' } root to: 'extranet/home#index' diff --git a/db/migrate/20230227052540_add_look_to_extranets.rb b/db/migrate/20230227052540_add_look_to_extranets.rb new file mode 100644 index 0000000000000000000000000000000000000000..698556cdf5cec963dab35d96fc84e31034c6ccb1 --- /dev/null +++ b/db/migrate/20230227052540_add_look_to_extranets.rb @@ -0,0 +1,7 @@ +class AddLookToExtranets < ActiveRecord::Migration[7.0] + def change + add_column :communication_extranets, :home_sentence, :text + add_column :communication_extranets, :sass, :text + add_column :communication_extranets, :css, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 6b4d26f9969a4a15a9335a769a2a03bc3382311e..83c445005f4226a7f9a714ec7a7070565fdece41 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_02_27_045821) do +ActiveRecord::Schema[7.0].define(version: 2023_02_27_052540) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -118,6 +118,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_27_045821) do t.boolean "feature_assets", default: false t.boolean "feature_posts", default: false t.boolean "feature_jobs", default: false + t.text "home_sentence" + t.text "sass" + t.text "css" t.index ["about_type", "about_id"], name: "index_communication_extranets_on_about" t.index ["university_id"], name: "index_communication_extranets_on_university_id" end diff --git a/test/fixtures/communication/extranets.yml b/test/fixtures/communication/extranets.yml index 927e244492a6cd6138ff337a25bd951916dd52fb..32d364d3e55c226aa13e6fcacf8c069de294cc3e 100644 --- a/test/fixtures/communication/extranets.yml +++ b/test/fixtures/communication/extranets.yml @@ -6,16 +6,19 @@ # about_type :string indexed => [about_id] # color :string # cookies_policy :text +# css :text # feature_alumni :boolean default(FALSE) # feature_assets :boolean default(FALSE) # feature_contacts :boolean default(FALSE) # feature_jobs :boolean default(FALSE) # feature_posts :boolean default(FALSE) # has_sso :boolean default(FALSE) +# home_sentence :text # host :string # name :string # privacy_policy :text # registration_contact :string +# sass :text # sso_button_label :string # sso_cert :text # sso_mapping :jsonb diff --git a/test/models/communication/extranet_test.rb b/test/models/communication/extranet_test.rb index 4cc7a451f63b533a32b33959d3af474e322e3b31..504f037d0f2ffdab7721c74bf3d60750bac26cf8 100644 --- a/test/models/communication/extranet_test.rb +++ b/test/models/communication/extranet_test.rb @@ -6,16 +6,19 @@ # about_type :string indexed => [about_id] # color :string # cookies_policy :text +# css :text # feature_alumni :boolean default(FALSE) # feature_assets :boolean default(FALSE) # feature_contacts :boolean default(FALSE) # feature_jobs :boolean default(FALSE) # feature_posts :boolean default(FALSE) # has_sso :boolean default(FALSE) +# home_sentence :text # host :string # name :string # privacy_policy :text # registration_contact :string +# sass :text # sso_button_label :string # sso_cert :text # sso_mapping :jsonb