diff --git a/app/controllers/admin/communication/website/index_pages_controller.rb b/app/controllers/admin/communication/website/index_pages_controller.rb index 695c59314096ac1751669647ab11e071bf0e0dc0..5127b2285487d60efefe6315a219899baba541b0 100644 --- a/app/controllers/admin/communication/website/index_pages_controller.rb +++ b/app/controllers/admin/communication/website/index_pages_controller.rb @@ -41,7 +41,7 @@ class Admin::Communication::Website::IndexPagesController < Admin::Communication def index_page_params params.require(:communication_website_index_page) .permit( - :title, :description, :text, :path, :featured_image, :featured_image_delete, + :title, :breadcrumb_title, :description, :header_text, :text, :path, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt ) .merge(university_id: current_university.id) diff --git a/app/models/communication/website/index_page.rb b/app/models/communication/website/index_page.rb index 2f8d96a9bdcdaa7b3926585a82cdf7d22563d789..93263f790067c15952aba15c48b9a73ca270cdf3 100644 --- a/app/models/communication/website/index_page.rb +++ b/app/models/communication/website/index_page.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text @@ -29,8 +31,6 @@ class Communication::Website::IndexPage < ApplicationRecord include WithFeaturedImage include WithBlobs - has_summernote :text - enum kind: { home: 0, communication_posts: 10, @@ -47,9 +47,11 @@ class Communication::Website::IndexPage < ApplicationRecord belongs_to :university belongs_to :website, foreign_key: :communication_website_id + has_summernote :header_text has_summernote :text - validates :title, :path, presence: true + validates :title, presence: true + validates :path, presence: true, unless: Proc.new { |p| p.home? } def to_s "#{title}" diff --git a/app/models/communication/website/index_page/administrators.rb b/app/models/communication/website/index_page/administrators.rb index 7d4b0191db24fede12be10b9b996677c525521d0..77d70286367a8e15083574a31b19f0268889b6a4 100644 --- a/app/models/communication/website/index_page/administrators.rb +++ b/app/models/communication/website/index_page/administrators.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/authors.rb b/app/models/communication/website/index_page/authors.rb index 3dbde4e04257de62dc2ced61a7265a85fedb10f9..ac8c199066acb3bd33ebe37d8a8fbfa0dcc20f72 100644 --- a/app/models/communication/website/index_page/authors.rb +++ b/app/models/communication/website/index_page/authors.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/communication_posts.rb b/app/models/communication/website/index_page/communication_posts.rb index a4fa2e93cdd8b3211c97e629f56ab7040f66ddcb..280f4ac363a68e2037e60d4f648777dcf48fd438 100644 --- a/app/models/communication/website/index_page/communication_posts.rb +++ b/app/models/communication/website/index_page/communication_posts.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/education_programs.rb b/app/models/communication/website/index_page/education_programs.rb index e37b33724f36d27f02b313b111f27928aa11237c..6deb5218cff41a2c46aa6445d08bf1bb32f4a092 100644 --- a/app/models/communication/website/index_page/education_programs.rb +++ b/app/models/communication/website/index_page/education_programs.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/home.rb b/app/models/communication/website/index_page/home.rb index 0cd4a282e6a1ce30d002f774c5db4ecb1a3c0185..f9e5dbf862b058d08c8bb66152b0209cb0114aad 100644 --- a/app/models/communication/website/index_page/home.rb +++ b/app/models/communication/website/index_page/home.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text @@ -33,4 +35,8 @@ class Communication::Website::IndexPage::Home < Communication::Website::IndexPag 'content/_index.html' end + def url + '/' + end + end diff --git a/app/models/communication/website/index_page/persons.rb b/app/models/communication/website/index_page/persons.rb index 68de1550664f11296c9b65559a18405612a8fd41..7560b9c3bcfef26bf8db4e34c86350ebfcee3f53 100644 --- a/app/models/communication/website/index_page/persons.rb +++ b/app/models/communication/website/index_page/persons.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/research_articles.rb b/app/models/communication/website/index_page/research_articles.rb index 2fb5905fd230d7873e28cc8c908e575bd7dd4792..35f8f089e8bf3905f94591a64664246ed0dcfa4c 100644 --- a/app/models/communication/website/index_page/research_articles.rb +++ b/app/models/communication/website/index_page/research_articles.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/research_volumes.rb b/app/models/communication/website/index_page/research_volumes.rb index c240e4a0a2a77b6582dd935eb1d8f4e93a410185..d21c7fd254e6955a920206c29262fb020dff5336 100644 --- a/app/models/communication/website/index_page/research_volumes.rb +++ b/app/models/communication/website/index_page/research_volumes.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/researchers.rb b/app/models/communication/website/index_page/researchers.rb index 727c395dd5920a112a76a895c1014039ff48b9f4..7d0d615dbfce294fecd217670ea124992b500ffe 100644 --- a/app/models/communication/website/index_page/researchers.rb +++ b/app/models/communication/website/index_page/researchers.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/models/communication/website/index_page/teachers.rb b/app/models/communication/website/index_page/teachers.rb index f979e22f585194d4bc44eb03d8b80904ee348c74..4ce22d763ddb2268c80bd039a49e4532b617ebdd 100644 --- a/app/models/communication/website/index_page/teachers.rb +++ b/app/models/communication/website/index_page/teachers.rb @@ -3,8 +3,10 @@ # Table name: communication_website_index_pages # # id :uuid not null, primary key +# breadcrumb_title :string # description :text # featured_image_alt :string +# header_text :string # kind :integer # path :string # text :text diff --git a/app/views/admin/communication/website/index_page/_static.html.erb b/app/views/admin/communication/website/index_page/_static.html.erb index 59106634cd30cde93969a81bdd4ad3b1084fd21f..570195e81ad1d34d078bd644fb5a678e32a21749 100644 --- a/app/views/admin/communication/website/index_page/_static.html.erb +++ b/app/views/admin/communication/website/index_page/_static.html.erb @@ -1,6 +1,7 @@ --- title: > <%= @about.title %> +breadcrumb_title: "<%= @about.breadcrumb_title.blank? ? @about.title : @about.breadcrumb_title %>" url: <%= @about.url %> <% if @about.featured_image.attached? %> image: "<%= @about.featured_image.blob.id %>" @@ -8,5 +9,7 @@ image_alt: "<%= @about.featured_image_alt %>" <% end %> description: > <%= prepare_text_for_static @about.description %> +header_text: > + <%= prepare_html_for_static @about.header_text, @website.university %> --- <%= prepare_html_for_static @about.text, @website.university %> diff --git a/app/views/admin/communication/website/index_page/homes/static.html.erb b/app/views/admin/communication/website/index_page/homes/static.html.erb index 252b46aaac2358a3a20e72413fe3f9501ec66403..0042b13cee883af590932bf8edce6224b38ed268 100644 --- a/app/views/admin/communication/website/index_page/homes/static.html.erb +++ b/app/views/admin/communication/website/index_page/homes/static.html.erb @@ -1,12 +1 @@ ---- -title: > - <%= @website.name %> -breadcrumb_title: "<%= @about.title %>" -<% if @about.featured_image.attached? %> -image: "<%= @about.featured_image.blob.id %>" -image_alt: "<%= @about.featured_image_alt %>" -<% end %> -description: > - <%= prepare_text_for_static @about.description %> ---- -<%= prepare_html_for_static @about.text, @website.university %> +<%= render 'admin/communication/website/index_page/static' %> diff --git a/app/views/admin/communication/website/index_pages/edit.html.erb b/app/views/admin/communication/website/index_pages/edit.html.erb index 84a91e7acd6c8f99264acad146ec3aa6227788ed..61394a3f3c4c5261c06ed90a8fd3f5470d09c99f 100644 --- a/app/views/admin/communication/website/index_pages/edit.html.erb +++ b/app/views/admin/communication/website/index_pages/edit.html.erb @@ -12,12 +12,17 @@ <div class="card-body"> <%= f.input :title, input_html: { name: 'communication_website_index_page[title]', id: 'communication_website_index_page_title' } %> <%= f.input :path, + required: true, input_html: { name: 'communication_website_index_page[path]', class: 'js-slug-input', data: { source: '#communication_website_index_page_title' } - } %> + } unless @index_page.home? %> + <%= f.input :breadcrumb_title, + input_html: { name: 'communication_website_index_page[breadcrumb_title]' }, + hint: t('simple_form.hints.communication_website_index_page.breadcrumb_title') %> <%= f.input :description, input_html: { name: 'communication_website_index_page[description]' } %> + <%= f.input :header_text, as: :summernote, input_html: { name: 'communication_website_index_page[header_text]' } %> <%= f.input :text, as: :summernote, input_html: { name: 'communication_website_index_page[text]' } %> </div> </div> diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index a77c09ee1ea83827d3ad252f84a3ef636ec2a63d..ac824d3f536894d0e39c5b159cac31e1afceba12 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -55,11 +55,13 @@ fr: parent: Catégorie parente slug: Slug communication/website/index_page: + breadcrumb_title: Nom affiché dans le fil d'ariane description: Description (SEO) featured_image: Image à la une featured_image_alt: Texte alternatif + header_text: Texte affiché dans le header slug: Slug - text: Texte + text: Texte de la page title: Titre communication/website/imported/category: original: Original @@ -197,3 +199,7 @@ fr: staff: Équipe teachers: Équipe pédagogique url: URL + simple_form: + hints: + communication_website_index_page: + breadcrumb_title: Si ce champ est vide le titre de la page sera utilisé dans le fil d'Ariane. diff --git a/db/migrate/20220217205201_add_fields_to_index_page.rb b/db/migrate/20220217205201_add_fields_to_index_page.rb new file mode 100644 index 0000000000000000000000000000000000000000..5a3827996db9c669eceb5a544fb66065d87ff241 --- /dev/null +++ b/db/migrate/20220217205201_add_fields_to_index_page.rb @@ -0,0 +1,6 @@ +class AddFieldsToIndexPage < ActiveRecord::Migration[6.1] + def change + add_column :communication_website_index_pages, :breadcrumb_title, :string + add_column :communication_website_index_pages, :header_text, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 362101367ebc22d71499b5c8cd6d8c8db6af843a..e7dc9d7ee63cd3e9b26c8ebe04e50d7ebcb1b0ec 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.define(version: 2022_02_17_183218) do +ActiveRecord::Schema.define(version: 2022_02_17_205201) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -252,6 +252,8 @@ ActiveRecord::Schema.define(version: 2022_02_17_183218) do t.integer "kind" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "breadcrumb_title" + t.string "header_text" t.index ["communication_website_id"], name: "idx_comm_website_index_page_on_communication_website_id" t.index ["university_id"], name: "index_communication_website_index_pages_on_university_id" end