From 958dbc67d1dc363ebb5de21980fbfa0d672502d0 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Mon, 12 Dec 2022 14:49:04 +0100 Subject: [PATCH] =?UTF-8?q?La=20structure=20de=20cat=C3=A9gories=20est=20m?= =?UTF-8?q?aintenant=20flatten=20artificiellement=20sur=20github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/communication/website/category.rb | 4 ++-- app/views/admin/application/static/_permalink.html.erb | 2 +- .../communication/websites/categories/static.html.erb | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index a00ecbed6..3f378dcb0 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -81,7 +81,7 @@ class Communication::Website::Category < ApplicationRecord end def git_path(website) - "content/categories/#{path}/_index.html" + "content/categories/#{slug_with_ancestors_slugs}/_index.html" end def template_static @@ -108,7 +108,7 @@ class Communication::Website::Category < ApplicationRecord end def slug_with_ancestors_slugs - (ancestors.map(&:slug) << slug).join('/') + (ancestors.map(&:slug) << slug).join('-') end protected diff --git a/app/views/admin/application/static/_permalink.html.erb b/app/views/admin/application/static/_permalink.html.erb index 754eaa149..0566d251f 100644 --- a/app/views/admin/application/static/_permalink.html.erb +++ b/app/views/admin/application/static/_permalink.html.erb @@ -1,6 +1,6 @@ url: "<%= @about.current_permalink_in_website(@website)&.path %>" <% if @about.respond_to?(:slug) && @about.slug.present? %> -slug: "<%= @about.slug %>" +slug: "<%= forced_slug || @about.slug %>" <% end %> <% previous_permalinks = @about.previous_permalinks_in_website(@website).where.not(path: "/") diff --git a/app/views/admin/communication/websites/categories/static.html.erb b/app/views/admin/communication/websites/categories/static.html.erb index 22040b310..482d80b62 100644 --- a/app/views/admin/communication/websites/categories/static.html.erb +++ b/app/views/admin/communication/websites/categories/static.html.erb @@ -1,9 +1,15 @@ --- title: "<%= @about.name %>" -<%= render 'admin/application/static/permalink' %> +<%= render 'admin/application/static/permalink', forced_slug: @about.slug_with_ancestors_slugs %> <% if @about.parent %> parent: "<%= @about.parent.path %>" <% end %> +<% if @about.children.any? %> +children: +<% @about.children.ordered.each do |child| %> + - <%= child.path %> +<% end %> +<% end %> position: <%= @about.position %> <%= render 'admin/communication/unsplash/static' %> description: > -- GitLab