From 8084d5b6dc86235006366a9543985927439a1c33 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 26 Dec 2022 15:35:19 +0100 Subject: [PATCH] precompute --- app/models/concerns/with_blocks.rb | 5 +++++ .../admin/communication/websites/categories/static.html.erb | 5 +++++ .../admin/communication/websites/pages/static.html.erb | 6 +++++- .../admin/communication/websites/posts/static.html.erb | 5 +++++ app/views/admin/education/diplomas/static.html.erb | 5 +++++ app/views/admin/education/programs/static.html.erb | 5 +++++ .../admin/university/people/administrators/static.html.erb | 5 +++++ app/views/admin/university/people/authors/static.html.erb | 5 +++++ .../admin/university/people/researchers/static.html.erb | 5 +++++ app/views/admin/university/people/static.html.erb | 5 +++++ app/views/admin/university/people/teachers/static.html.erb | 5 +++++ 11 files changed, 55 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/with_blocks.rb b/app/models/concerns/with_blocks.rb index faa5518b9..81d3707d1 100644 --- a/app/models/concerns/with_blocks.rb +++ b/app/models/concerns/with_blocks.rb @@ -8,4 +8,9 @@ module WithBlocks def git_block_dependencies blocks.collect &:git_dependencies end + + # Basic rule is: TOC if 2 titles or more + def show_toc? + (blocks.collect(&:title).uniq.compact - ['']).many? + end end diff --git a/app/views/admin/communication/websites/categories/static.html.erb b/app/views/admin/communication/websites/categories/static.html.erb index 482d80b62..48296bc43 100644 --- a/app/views/admin/communication/websites/categories/static.html.erb +++ b/app/views/admin/communication/websites/categories/static.html.erb @@ -1,6 +1,11 @@ --- title: "<%= @about.name %>" <%= render 'admin/application/static/permalink', forced_slug: @about.slug_with_ancestors_slugs %> +layout: + full_width: <%= @about.full_width %> + toc: + present: <%= @about.show_toc? %> + offcanvas: <%= !@about.full_width %> <% if @about.parent %> parent: "<%= @about.parent.path %>" <% end %> diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb index ffa172256..b2c2c29fe 100644 --- a/app/views/admin/communication/websites/pages/static.html.erb +++ b/app/views/admin/communication/websites/pages/static.html.erb @@ -11,7 +11,11 @@ has: teachers: <%= @website.has_teachers? %> <% end %> position: <%= @about.position %> -full_width: <%= @about.full_width %> +layout: + full_width: <%= @about.full_width %> + toc: + offcanvas: <%= !@about.full_width %> + present: <%= @about.show_toc? %> bodyclass: <%= @about.best_bodyclass %> <%= render 'admin/communication/unsplash/static' %> <% if @about.children.published.any? %> diff --git a/app/views/admin/communication/websites/posts/static.html.erb b/app/views/admin/communication/websites/posts/static.html.erb index 414ff5871..6d656aefb 100644 --- a/app/views/admin/communication/websites/posts/static.html.erb +++ b/app/views/admin/communication/websites/posts/static.html.erb @@ -1,6 +1,11 @@ --- title: "<%= @about.title %>" date: "<%= @about.published_at.iso8601 %>" +layout: + full_width: false + toc: + present: <%= @about.show_toc? %> + offcanvas: false <%= render 'admin/application/static/permalink' %> <% if @about.pinned %> weight: 1 diff --git a/app/views/admin/education/diplomas/static.html.erb b/app/views/admin/education/diplomas/static.html.erb index 894edd414..99527ec82 100644 --- a/app/views/admin/education/diplomas/static.html.erb +++ b/app/views/admin/education/diplomas/static.html.erb @@ -7,6 +7,11 @@ short_name: > <%= render 'admin/application/chapo/static' %> level: <%= @about.level_i18n %> ects: <%= @about.ects %> +layout: + full_width: true + toc: + present: <%= @about.show_toc? %> + offcanvas: true duration: > <%= prepare_text_for_static @about.duration %> <%= render 'admin/communication/blocks/static', about: @about %> diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index 4d6adbf4b..2850a1601 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -10,6 +10,11 @@ administrator_involvements = @about.involvements_through_roles title: > <%= @about.name %> url: <%= @about.path_in_website(@website) %> +layout: + full_width: false + toc: + present: <%= @about.show_toc? %> + offcanvas: true <% if @about.downloadable_summary.attached? %> downloadable_summary: <%= @about.downloadable_summary.blob_id %> <% end %> diff --git a/app/views/admin/university/people/administrators/static.html.erb b/app/views/admin/university/people/administrators/static.html.erb index efa819c71..a2599f50b 100644 --- a/app/views/admin/university/people/administrators/static.html.erb +++ b/app/views/admin/university/people/administrators/static.html.erb @@ -10,4 +10,9 @@ last_name: > <%= @about.last_name %> description: > <%= prepare_text_for_static @about.description %> +layout: + full_width: true + toc: + present: <%= @about.show_toc? %> + offcanvas: true --- diff --git a/app/views/admin/university/people/authors/static.html.erb b/app/views/admin/university/people/authors/static.html.erb index 1515d73ef..176213561 100644 --- a/app/views/admin/university/people/authors/static.html.erb +++ b/app/views/admin/university/people/authors/static.html.erb @@ -10,4 +10,9 @@ last_name: > <%= @about.last_name %> description: > <%= prepare_text_for_static @about.description %> +layout: + full_width: true + toc: + present: <%= @about.show_toc? %> + offcanvas: true --- diff --git a/app/views/admin/university/people/researchers/static.html.erb b/app/views/admin/university/people/researchers/static.html.erb index fcb6ac9f6..d4333567b 100644 --- a/app/views/admin/university/people/researchers/static.html.erb +++ b/app/views/admin/university/people/researchers/static.html.erb @@ -10,4 +10,9 @@ last_name: > <%= @about.last_name %> description: > <%= prepare_text_for_static @about.description %> +layout: + full_width: true + toc: + present: <%= @about.show_toc? %> + offcanvas: true --- diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb index 6bbe8ea29..b48c3d79d 100644 --- a/app/views/admin/university/people/static.html.erb +++ b/app/views/admin/university/people/static.html.erb @@ -22,6 +22,11 @@ image: "<%= @about.best_picture.blob.id %>" description: > <%= prepare_text_for_static @about.description %> <%= render 'admin/application/chapo/static' %> +layout: + full_width: true + toc: + present: <%= @about.show_toc? %> + offcanvas: true roles: <% if @about.author.for_website?(@website) %> - author diff --git a/app/views/admin/university/people/teachers/static.html.erb b/app/views/admin/university/people/teachers/static.html.erb index e5665c0e1..45a4e5e94 100644 --- a/app/views/admin/university/people/teachers/static.html.erb +++ b/app/views/admin/university/people/teachers/static.html.erb @@ -10,4 +10,9 @@ last_name: > <%= @about.last_name %> description: > <%= prepare_text_for_static @about.description %> +layout: + full_width: true + toc: + present: <%= @about.show_toc? %> + offcanvas: true --- -- GitLab