diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index 84085d6ac2c0b554bfc1e0b942e20d586205eadc..dfb92df94265d2e4acfc7c0c5d3d5481f697a21c 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -3,7 +3,7 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We through: :website def index - @homepage = @website.pages.kind_home.first + @homepage = @website.pages.home.first @first_level_pages = @homepage.children.ordered breadcrumb end diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index ed3728c7391027a4fbe7b73795db390730efafb4..1e0cc646ed83c7b29d4171b56d700aa9bbf04a7d 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -89,9 +89,9 @@ class Communication::Website::Page < ApplicationRecord descendants + active_storage_blobs + siblings + - git_block_dependencies + git_block_dependencies + + type_git_dependencies dependencies += [parent] if has_parent? - dependencies += special_page_git_dependencies(website) if is_special_page? dependencies.flatten end @@ -113,24 +113,19 @@ class Communication::Website::Page < ApplicationRecord page end - def full_width - kind_home? ? true - : attributes['full_width'] - end - def to_s "#{title}" end def best_featured_image # we don't want to fallback on homepage featured_image - return featured_image if featured_image.attached? || kind_home? || parent&.kind_home? + return featured_image if featured_image.attached? || is_home? || parent&.is_home? parent&.best_featured_image end def best_bodyclass return bodyclass if bodyclass.present? - parent&.best_bodyclass unless kind_home? || parent&.kind_home? + parent&.best_bodyclass unless is_home? || parent&.is_home? end def siblings diff --git a/app/models/communication/website/page/administrator.rb b/app/models/communication/website/page/administrator.rb index 169e5ad82659a67fce4fc1588df87d4a5575a549..90e37781efe8f33afd6858ff351bcb457ef83d09 100644 --- a/app/models/communication/website/page/administrator.rb +++ b/app/models/communication/website/page/administrator.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::Administrator < Communication::Website::Page "#{git_path_prefix}administrators/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.website.administrators.map(&:administrator) - ].flatten + ] end end diff --git a/app/models/communication/website/page/author.rb b/app/models/communication/website/page/author.rb index 2ef31f8af3c6282aabb0994719d95f1d64ff57ec..10e663553134a9de887aafbf42a7ea72616d5adc 100644 --- a/app/models/communication/website/page/author.rb +++ b/app/models/communication/website/page/author.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::Author < Communication::Website::Page "#{git_path_prefix}authors/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.website.authors.map(&:author) - ].flatten + ] end end diff --git a/app/models/communication/website/page/communication_post.rb b/app/models/communication/website/page/communication_post.rb index 10a7bba9623dd542ad64dbcbd9e0820b5bf56c06..708bd5524ab66263a4165e9931384a6f6be20112 100644 --- a/app/models/communication/website/page/communication_post.rb +++ b/app/models/communication/website/page/communication_post.rb @@ -45,12 +45,12 @@ class Communication::Website::Page::CommunicationPost < Communication::Website:: "#{git_path_prefix}posts/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.categories, website.authors.map(&:author), website.posts - ].flatten + ] end end diff --git a/app/models/communication/website/page/education_diploma.rb b/app/models/communication/website/page/education_diploma.rb index 62f304cb8103136f2eef23f95eb0a203f18851b4..5603a78e1d531005f6043c5237e428460e079c29 100644 --- a/app/models/communication/website/page/education_diploma.rb +++ b/app/models/communication/website/page/education_diploma.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::EducationDiploma < Communication::Website::P "#{git_path_prefix}diplomas/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.education_diplomas - ].flatten + ] end end diff --git a/app/models/communication/website/page/education_program.rb b/app/models/communication/website/page/education_program.rb index d06340d9a32218303212924e5bd130edcbb45cf7..be2cdf123f9094f3cc0e9e49097fc527922fd479 100644 --- a/app/models/communication/website/page/education_program.rb +++ b/app/models/communication/website/page/education_program.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::EducationProgram < Communication::Website::P "#{git_path_prefix}programs/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.education_programs - ].flatten + ] end end diff --git a/app/models/communication/website/page/home.rb b/app/models/communication/website/page/home.rb index 032a599c3fc6215c72d200de7afc4027ffdc314b..754a7a00ce78680f0c2e21a2dbe7e55a5fee28c8 100644 --- a/app/models/communication/website/page/home.rb +++ b/app/models/communication/website/page/home.rb @@ -45,6 +45,10 @@ class Communication::Website::Page::Home < Communication::Website::Page "#{git_path_prefix}_index.html" end + def full_width + true + end + def draftable? false end diff --git a/app/models/communication/website/page/organization.rb b/app/models/communication/website/page/organization.rb index 179fc2a57b0ab30a578d6acfd2f6a6735ae5508b..f31d856ce6bc11c0aea625fd22476bf9022d1247 100644 --- a/app/models/communication/website/page/organization.rb +++ b/app/models/communication/website/page/organization.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::Organization < Communication::Website::Page "#{git_path_prefix}organizations/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.organizations - ].flatten + ] end end diff --git a/app/models/communication/website/page/person.rb b/app/models/communication/website/page/person.rb index 7777925acae83ff43bf6d27d2dfc1cba09419fdd..6572ece248ddb99f3ab0e5624391b9a23c453299 100644 --- a/app/models/communication/website/page/person.rb +++ b/app/models/communication/website/page/person.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::Person < Communication::Website::Page "#{git_path_prefix}persons/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.people_with_facets - ].flatten + ] end end diff --git a/app/models/communication/website/page/research_paper.rb b/app/models/communication/website/page/research_paper.rb index f3c75ad19fc1f7ca004e1aca99f049c4dfbf0246..5e1669fdb4db19854599764c6dfca46ca2a3d000 100644 --- a/app/models/communication/website/page/research_paper.rb +++ b/app/models/communication/website/page/research_paper.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::ResearchPaper < Communication::Website::Page "#{git_path_prefix}papers/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.research_papers - ].flatten + ] end end diff --git a/app/models/communication/website/page/research_volume.rb b/app/models/communication/website/page/research_volume.rb index 5d5f124bd56ea99d98e0aca24c9039ddf5cad452..11d4d39a5488347822710654c91e5e4446fa19d4 100644 --- a/app/models/communication/website/page/research_volume.rb +++ b/app/models/communication/website/page/research_volume.rb @@ -45,10 +45,10 @@ class Communication::Website::Page::ResearchVolume < Communication::Website::Pag "#{git_path_prefix}volumes/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.research_volumes - ].flatten + ] end end diff --git a/app/models/communication/website/page/researcher.rb b/app/models/communication/website/page/researcher.rb index 14ac41857782d25471fe26e768526c52e96276c7..b3e33978429a9a3e341bfb05ec5a5e6f45a28b05 100644 --- a/app/models/communication/website/page/researcher.rb +++ b/app/models/communication/website/page/researcher.rb @@ -45,11 +45,10 @@ class Communication::Website::Page::Researcher < Communication::Website::Page "#{git_path_prefix}researchers/_index.html" end - - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.website.researchers.map(&:researcher) - ].flatten + ] end end diff --git a/app/models/communication/website/page/teacher.rb b/app/models/communication/website/page/teacher.rb index 7a36cc769d1e33ad76c9b7143fbc367f23d2dd08..20541510407c4d33fc533c1d10df035de3033122 100644 --- a/app/models/communication/website/page/teacher.rb +++ b/app/models/communication/website/page/teacher.rb @@ -45,7 +45,7 @@ class Communication::Website::Page::Teacher < Communication::Website::Page "#{git_path_prefix}teachers/_index.html" end - def git_dependencies(website) + def type_git_dependencies [ website.config_default_permalinks, website.website.teachers.map(&:teacher) diff --git a/app/models/communication/website/page/with_type.rb b/app/models/communication/website/page/with_type.rb index 52c0df179b5820ed9db11a2a596307bfc13deb96..8600451a55601600e0efb55ac05d092d3164c159 100644 --- a/app/models/communication/website/page/with_type.rb +++ b/app/models/communication/website/page/with_type.rb @@ -1,12 +1,23 @@ module Communication::Website::Page::WithType extend ActiveSupport::Concern + + included do + HOME_TYPE = '::Communication::Website::Page::Home' + + scope :home, -> { where(type: HOME_TYPE) } + end + # Communication::Website::Page::CommunicationPosts -> communication_posts # Used for i18n def type_key type.demodulize.underscore end + def is_home? + type == HOME_TYPE + end + def is_special_page? type.present? end @@ -36,4 +47,8 @@ module Communication::Website::Page::WithType def deletable? is_regular_page? end + + def type_git_dependencies + [] + end end \ No newline at end of file diff --git a/app/views/admin/communication/websites/pages/_form.html.erb b/app/views/admin/communication/websites/pages/_form.html.erb index 81496623e99884ca9c07124c5f89f7d691ca813b..21bcb9fac5645010234e1ec3877842669597c022 100644 --- a/app/views/admin/communication/websites/pages/_form.html.erb +++ b/app/views/admin/communication/websites/pages/_form.html.erb @@ -30,20 +30,20 @@ url = page.new_record? ? admin_communication_website_pages_path </div> </div> <div class="col-md-4"> - <% unless page.kind_home? %> + <% unless page.is_home? %> <div class="card flex-fill w-100"> <div class="card-header"> <h5 class="card-title mb-0"><%= t('metadata') %></h5> </div> <div class="card-body"> - <%= f.input :published if page.is_regular_page? %> + <%= f.input :published if page.draftable? %> <%= f.input :slug, as: :string, required: true, input_html: page.persisted? ? {} : { class: 'js-slug-input', data: { source: '#communication_website_page_title' } - } unless page.kind_home? %> + } unless page.is_home? %> <% if @website.languages.many? %> <%= f.input :language_id, collection: @website.languages, include_blank: false %> <% elsif @website.languages.any? %> @@ -53,7 +53,7 @@ url = page.new_record? ? admin_communication_website_pages_path collection: collection_tree(@website.pages, page), include_blank: false, label_method: ->(p) { sanitize p[:label] }, - value_method: ->(p) { p[:id] } unless page.kind_home? %> + value_method: ->(p) { p[:id] } unless page.is_home? %> <%= f.input :bodyclass if can?(:edit, @website) %> <%= f.input :full_width %> </div> diff --git a/app/views/admin/communication/websites/pages/_treebranch.html.erb b/app/views/admin/communication/websites/pages/_treebranch.html.erb index 8f92b6e4934687eaa9a62ebecbc5db7bad2ac0a6..1f5598eb6867c13a362e564f0e781d46e9e9e803 100644 --- a/app/views/admin/communication/websites/pages/_treebranch.html.erb +++ b/app/views/admin/communication/websites/pages/_treebranch.html.erb @@ -15,7 +15,7 @@ <%= link_to page, admin_communication_website_page_path(website_id: page.website.id, id: page.id), class: "#{'draft' unless page.published?}" %> - <% unless page.kind_home? %> + <% unless page.is_home? %> <span class="move_btn py-2 ps-2"><i class="fas fa-sort"></i></span> <% end %> <%= link_to children_admin_communication_website_page_path(website_id: page.website.id, id: page.id),