From 063eb0bb6729e530f3fda17faf310a608cc4eb93 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Thu, 17 Feb 2022 22:13:43 +0100 Subject: [PATCH] index pages --- .../communication/website/index_pages_controller.rb | 2 +- app/models/communication/website/index_page.rb | 8 +++++--- .../website/index_page/administrators.rb | 2 ++ .../communication/website/index_page/authors.rb | 2 ++ .../website/index_page/communication_posts.rb | 2 ++ .../website/index_page/education_programs.rb | 2 ++ app/models/communication/website/index_page/home.rb | 6 ++++++ .../communication/website/index_page/persons.rb | 2 ++ .../website/index_page/research_articles.rb | 2 ++ .../website/index_page/research_volumes.rb | 2 ++ .../communication/website/index_page/researchers.rb | 2 ++ .../communication/website/index_page/teachers.rb | 2 ++ .../website/index_page/_static.html.erb | 3 +++ .../website/index_page/homes/static.html.erb | 13 +------------ .../communication/website/index_pages/edit.html.erb | 7 ++++++- config/locales/communication/fr.yml | 8 +++++++- .../20220217205201_add_fields_to_index_page.rb | 6 ++++++ db/schema.rb | 4 +++- 18 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20220217205201_add_fields_to_index_page.rb diff --git a/app/controllers/admin/communication/website/index_pages_controller.rb b/app/controllers/admin/communication/website/index_pages_controller.rb index 695c59314..5127b2285 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 2f8d96a9b..93263f790 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 7d4b0191d..77d702863 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 3dbde4e04..ac8c19906 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 a4fa2e93c..280f4ac36 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 e37b33724..6deb5218c 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 0cd4a282e..f9e5dbf86 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 68de15506..7560b9c3b 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 2fb5905fd..35f8f089e 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 c240e4a0a..d21c7fd25 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 727c395dd..7d0d615db 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 f979e22f5..4ce22d763 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 59106634c..570195e81 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 252b46aaa..0042b13ce 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 84a91e7ac..61394a3f3 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 a77c09ee1..ac824d3f5 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 000000000..5a3827996 --- /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 362101367..e7dc9d7ee 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 -- GitLab