diff --git a/app/models/communication/website/permalink.rb b/app/models/communication/website/permalink.rb index 22148ea3e975570bb9cf6042c7fee516709c11dd..ee04fd3867029e7c2588afd7e885022486c36da2 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 3b17b83ef26ba578aa1571a310fff10bad980a4f..89f797a3c37d9f4e0782a2e788f366b7bfc1986e 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 d6d5c455ee2fcfc7ddc0f17a4b777c293d6ae1b6..95f834da2682e67f59b56ab07159f4e46cda53f0 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 a92f46b2af4dc63c45c9fcdde20e3e67507fa0fb..22040b310c562e164dff04f54085610a5f9067b2 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 66af43f700743814d639f7612f5d653f480ac8b0..a660cd8db305f16cd631b02413d02dcf6851516e 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 6d79a23f7d32dfe67aff16938e1dd3f6547358a3..1b8299b32d27d640276ccdebc30fd295b3e6bd41 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 e19f88c3fa7fa81190e7ad7ffe5521f78271d9f1..efa819c710c16cbc5e0f446461b17caf4438812d 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 c6a35683b3af6154e9fea1d360ff352cb0c99a67..1515d73efd810260e045a38093f87c028007aad7 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 d0910f05eb29387ae72ccc06374b086ea232b1ab..fcb6ac9f655eafbdd47827e47c717c008d91585e 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 9dc526daf9f12f78398080f31e4d3f6880d2f430..e5665c0e1aa82f5d7d79ce7c83057f59030a73c4 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 %> ---