From 03235ddc08a7236357b0174f29d2a63c5ca1a8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Mon, 5 Dec 2022 15:00:43 +0100 Subject: [PATCH] static --- app/models/communication/website/permalink.rb | 3 ++- app/models/communication/website/permalink/category.rb | 2 +- app/models/concerns/with_permalink_in_website.rb | 2 +- .../admin/communication/websites/categories/static.html.erb | 2 +- app/views/admin/education/diplomas/static.html.erb | 2 +- app/views/admin/university/organizations/static.html.erb | 2 +- .../admin/university/people/administrators/static.html.erb | 2 +- app/views/admin/university/people/authors/static.html.erb | 2 +- app/views/admin/university/people/researchers/static.html.erb | 2 +- app/views/admin/university/people/teachers/static.html.erb | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/models/communication/website/permalink.rb b/app/models/communication/website/permalink.rb index 22148ea3e..ee04fd386 100644 --- a/app/models/communication/website/permalink.rb +++ b/app/models/communication/website/permalink.rb @@ -74,7 +74,7 @@ class Communication::Website::Permalink < ApplicationRecord def computed_path return nil unless published? - @computed_path ||= published_path + @computed_path ||= Static.clean_path(published_path) end protected @@ -91,4 +91,5 @@ class Communication::Website::Permalink < ApplicationRecord def set_university self.university_id = website.university_id end + end diff --git a/app/models/communication/website/permalink/category.rb b/app/models/communication/website/permalink/category.rb index 3b17b83ef..89f797a3c 100644 --- a/app/models/communication/website/permalink/category.rb +++ b/app/models/communication/website/permalink/category.rb @@ -8,7 +8,7 @@ class Communication::Website::Permalink::Category < Communication::Website::Perm end def self.pattern_in_website(website) - "#{self.special_page(:communication_posts).path_without_language}:slug/" + "#{website.special_page(:communication_posts).path_without_language}:slug/" end protected diff --git a/app/models/concerns/with_permalink_in_website.rb b/app/models/concerns/with_permalink_in_website.rb index d6d5c455e..95f834da2 100644 --- a/app/models/concerns/with_permalink_in_website.rb +++ b/app/models/concerns/with_permalink_in_website.rb @@ -13,7 +13,7 @@ module WithPermalinkInWebsite new_permalink = Communication::Website::Permalink.for_object(self, website) # If the object had no permalink or if its path changed, we create a new permalink - if last_permalink.nil? || new_permalink.computed_path.present? && last_permalink.path != new_permalink.computed_path + if new_permalink.computed_path.present? && (last_permalink.nil? || last_permalink.path != new_permalink.computed_path) last_permalink&.update(is_current: false) new_permalink.path = new_permalink.computed_path new_permalink.save diff --git a/app/views/admin/communication/websites/categories/static.html.erb b/app/views/admin/communication/websites/categories/static.html.erb index a92f46b2a..22040b310 100644 --- a/app/views/admin/communication/websites/categories/static.html.erb +++ b/app/views/admin/communication/websites/categories/static.html.erb @@ -1,6 +1,6 @@ --- title: "<%= @about.name %>" -<%#= render 'admin/application/static/permalink' %> +<%= render 'admin/application/static/permalink' %> <% if @about.parent %> parent: "<%= @about.parent.path %>" <% end %> diff --git a/app/views/admin/education/diplomas/static.html.erb b/app/views/admin/education/diplomas/static.html.erb index 66af43f70..a660cd8db 100644 --- a/app/views/admin/education/diplomas/static.html.erb +++ b/app/views/admin/education/diplomas/static.html.erb @@ -1,7 +1,7 @@ --- title: > <%= prepare_text_for_static @about.name %> -slug: "<%= @about.slug %>" +<%= render 'admin/application/static/permalink' %> short_name: > <%= prepare_text_for_static @about.short_name %> level: <%= @about.level_i18n %> diff --git a/app/views/admin/university/organizations/static.html.erb b/app/views/admin/university/organizations/static.html.erb index 6d79a23f7..1b8299b32 100644 --- a/app/views/admin/university/organizations/static.html.erb +++ b/app/views/admin/university/organizations/static.html.erb @@ -1,7 +1,7 @@ --- title: > <%= @about.to_s %> -slug: "<%= @about.slug %>" +<%= render 'admin/application/static/permalink' %> long_name: > <%= @about.long_name %> kind: "<%= @about.kind %>" diff --git a/app/views/admin/university/people/administrators/static.html.erb b/app/views/admin/university/people/administrators/static.html.erb index e19f88c3f..efa819c71 100644 --- a/app/views/admin/university/people/administrators/static.html.erb +++ b/app/views/admin/university/people/administrators/static.html.erb @@ -1,13 +1,13 @@ --- title: > Responsabilités de <%= @about.to_s %> +<%= render 'admin/application/static/permalink' %> person: > <%= @about.to_s %> first_name: > <%= @about.first_name %> last_name: > <%= @about.last_name %> -slug: "<%= @about.slug %>" description: > <%= prepare_text_for_static @about.description %> --- diff --git a/app/views/admin/university/people/authors/static.html.erb b/app/views/admin/university/people/authors/static.html.erb index c6a35683b..1515d73ef 100644 --- a/app/views/admin/university/people/authors/static.html.erb +++ b/app/views/admin/university/people/authors/static.html.erb @@ -1,13 +1,13 @@ --- title: > Actualités de <%= @about.to_s %> +<%= render 'admin/application/static/permalink' %> person: > <%= @about.to_s %> first_name: > <%= @about.first_name %> last_name: > <%= @about.last_name %> -slug: "<%= @about.slug %>" description: > <%= prepare_text_for_static @about.description %> --- diff --git a/app/views/admin/university/people/researchers/static.html.erb b/app/views/admin/university/people/researchers/static.html.erb index d0910f05e..fcb6ac9f6 100644 --- a/app/views/admin/university/people/researchers/static.html.erb +++ b/app/views/admin/university/people/researchers/static.html.erb @@ -1,13 +1,13 @@ --- title: > Publications de <%= @about.to_s %> +<%= render 'admin/application/static/permalink' %> person: > <%= @about.to_s %> first_name: > <%= @about.first_name %> last_name: > <%= @about.last_name %> -slug: "<%= @about.slug %>" description: > <%= prepare_text_for_static @about.description %> --- diff --git a/app/views/admin/university/people/teachers/static.html.erb b/app/views/admin/university/people/teachers/static.html.erb index 9dc526daf..e5665c0e1 100644 --- a/app/views/admin/university/people/teachers/static.html.erb +++ b/app/views/admin/university/people/teachers/static.html.erb @@ -1,13 +1,13 @@ --- title: > Enseignements de <%= @about.to_s %> +<%= render 'admin/application/static/permalink' %> person: > <%= @about.to_s %> first_name: > <%= @about.first_name %> last_name: > <%= @about.last_name %> -slug: "<%= @about.slug %>" description: > <%= prepare_text_for_static @about.description %> --- -- GitLab