diff --git a/app/models/communication/website/menu.rb b/app/models/communication/website/menu.rb index 29bb82bfa363041167fe0f2f6ba3cbc20e48f328..2e46762f9aa74a0024aeddda8c6f74b90e826c71 100644 --- a/app/models/communication/website/menu.rb +++ b/app/models/communication/website/menu.rb @@ -46,10 +46,7 @@ class Communication::Website::Menu < ApplicationRecord end def git_path(website) - path = "data/menus/" - # TODO I18n : Right now, we continue to send only a master version - # path += "#{website.default_language.iso_code}/" if website.languages.any? - "#{path}#{identifier}.yml" + "data/menus/#{language.iso_code}/#{identifier}.yml" end def template_static diff --git a/app/models/communication/website/permalink.rb b/app/models/communication/website/permalink.rb index 276d8df83af5f599212cc2f6cc269c287ae73505..88f821fd28202d11e3338cce0ff2accac97f517b 100644 --- a/app/models/communication/website/permalink.rb +++ b/app/models/communication/website/permalink.rb @@ -54,9 +54,9 @@ class Communication::Website::Permalink < ApplicationRecord scope :current, -> { where(is_current: true) } scope :not_current, -> { where(is_current: false) } - def self.config_in_website(website) + def self.config_in_website(website, language) required_kinds_in_website(website).map { |permalink_class| - [permalink_class.static_config_key, permalink_class.pattern_in_website(website)] + [permalink_class.static_config_key, permalink_class.pattern_in_website(website, language)] }.to_h end @@ -84,12 +84,13 @@ class Communication::Website::Permalink < ApplicationRecord MAPPING.keys.include?(lookup_key) end - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) raise NotImplementedError end def pattern - self.class.pattern_in_website(website) + language = about.respond_to?(:language) ? about.language : website.default_language + self.class.pattern_in_website(website, language) end def computed_path @@ -122,8 +123,9 @@ class Communication::Website::Permalink < ApplicationRecord # Can be overwritten (Page for example) def published_path # TODO I18n doit prendre la langue du about + language = about.respond_to?(:language) ? about.language : website.default_language p = "" - p += "/#{website.default_language.iso_code}" if website.languages.many? + p += "/#{language.iso_code}" if website.languages.many? p += pattern substitutions.each do |key, value| p.gsub! ":#{key}", "#{value}" diff --git a/app/models/communication/website/permalink/administrator.rb b/app/models/communication/website/permalink/administrator.rb index 9a95d44d5c83cced6089ee19483dbe44e0f0f4fe..9a30340077f3897539cd9aacbc9700518f5f0ead 100644 --- a/app/models/communication/website/permalink/administrator.rb +++ b/app/models/communication/website/permalink/administrator.rb @@ -33,7 +33,7 @@ class Communication::Website::Permalink::Administrator < Communication::Website: end # /equipe/:slug/roles/ - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::Person).slug_with_ancestors}/:slug/roles/" end end diff --git a/app/models/communication/website/permalink/author.rb b/app/models/communication/website/permalink/author.rb index 8c0b639b40240d817036818b4b92b9546e5b8fa3..7cd0e41d3d66760c7b8a85580c9d711ba561bf4e 100644 --- a/app/models/communication/website/permalink/author.rb +++ b/app/models/communication/website/permalink/author.rb @@ -34,7 +34,7 @@ class Communication::Website::Permalink::Author < Communication::Website::Permal end # /equipe/:slug/actualites/ - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::Person).slug_with_ancestors}/:slug/#{website.special_page(Communication::Website::Page::CommunicationPost).slug}/" end end diff --git a/app/models/communication/website/permalink/category.rb b/app/models/communication/website/permalink/category.rb index 852dbfb3fe07c16c8b5f671e225666688caccb49..b4ae97e26c4ebf150a1e5579a75cfa5e7317c8e4 100644 --- a/app/models/communication/website/permalink/category.rb +++ b/app/models/communication/website/permalink/category.rb @@ -33,8 +33,8 @@ class Communication::Website::Permalink::Category < Communication::Website::Perm end # /actualites/:slug/ - def self.pattern_in_website(website) - "/#{website.special_page(Communication::Website::Page::CommunicationPost).slug_with_ancestors}/:slug/" + def self.pattern_in_website(website, language) + "/#{website.special_page(Communication::Website::Page::CommunicationPost, language: language).slug_with_ancestors}/:slug/" end protected diff --git a/app/models/communication/website/permalink/diploma.rb b/app/models/communication/website/permalink/diploma.rb index 64e9f2a9e37862da851be2f0019635105dbbfd7c..8b46f82a384e6ec208415bf4460a328432d040c6 100644 --- a/app/models/communication/website/permalink/diploma.rb +++ b/app/models/communication/website/permalink/diploma.rb @@ -33,7 +33,7 @@ class Communication::Website::Permalink::Diploma < Communication::Website::Perma end # /diplomes/:slug/ - def self.pattern_in_website(website) - "/#{website.special_page(Communication::Website::Page::EducationDiploma).slug_with_ancestors}/:slug/" + def self.pattern_in_website(website, language) + "/#{website.special_page(Communication::Website::Page::EducationDiploma, language: language).slug_with_ancestors}/:slug/" end end diff --git a/app/models/communication/website/permalink/organization.rb b/app/models/communication/website/permalink/organization.rb index c3d3e8ec7d1c9e200d83eba3e935a80b801a82a1..6c203f9e8ab5895887ed9c0683c06a311b669f87 100644 --- a/app/models/communication/website/permalink/organization.rb +++ b/app/models/communication/website/permalink/organization.rb @@ -33,7 +33,7 @@ class Communication::Website::Permalink::Organization < Communication::Website:: end # /organisations/:slug/ - def self.pattern_in_website(website) - "/#{website.special_page(Communication::Website::Page::Organization).slug_with_ancestors}/:slug/" + def self.pattern_in_website(website, language) + "/#{website.special_page(Communication::Website::Page::Organization, language: language).slug_with_ancestors}/:slug/" end end diff --git a/app/models/communication/website/permalink/paper.rb b/app/models/communication/website/permalink/paper.rb index 430fee83b4743d2f765a2391b1576e27da5fd88a..25e7fd2d125c1fb744270bd4b07e1e9e1cb3ae8c 100644 --- a/app/models/communication/website/permalink/paper.rb +++ b/app/models/communication/website/permalink/paper.rb @@ -33,7 +33,7 @@ class Communication::Website::Permalink::Paper < Communication::Website::Permali end # /papiers/:slug/ - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::ResearchPaper).slug_with_ancestors}/:year-:month-:day-:slug/" end diff --git a/app/models/communication/website/permalink/person.rb b/app/models/communication/website/permalink/person.rb index 760c5d9ce0c3ca9a8b5eab4031de9bf0f26bc4bb..ecd620e56503faf44b048bbc4f97181ca45bb8d9 100644 --- a/app/models/communication/website/permalink/person.rb +++ b/app/models/communication/website/permalink/person.rb @@ -33,7 +33,7 @@ class Communication::Website::Permalink::Person < Communication::Website::Permal end # /equipe/:slug/ - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::Person).slug_with_ancestors}/:slug/" end end diff --git a/app/models/communication/website/permalink/post.rb b/app/models/communication/website/permalink/post.rb index 8525ea0e63446354baa41106427fb8556fa2debd..b12ce72babd5d143531909e42f75e1f207deeacf 100644 --- a/app/models/communication/website/permalink/post.rb +++ b/app/models/communication/website/permalink/post.rb @@ -33,8 +33,8 @@ class Communication::Website::Permalink::Post < Communication::Website::Permalin end # /actualites/2022-10-21-un-article/ - def self.pattern_in_website(website) - "/#{website.special_page(Communication::Website::Page::CommunicationPost).slug_with_ancestors}/:year-:month-:day-:slug/" + def self.pattern_in_website(website, language) + "/#{website.special_page(Communication::Website::Page::CommunicationPost, language: language).slug_with_ancestors}/:year-:month-:day-:slug/" end protected diff --git a/app/models/communication/website/permalink/program.rb b/app/models/communication/website/permalink/program.rb index 8c1c0e02dda11940996d4c18f0e22708c47399e3..69b8da1fb0904452db4504e578b3b9b8e2f20f8d 100644 --- a/app/models/communication/website/permalink/program.rb +++ b/app/models/communication/website/permalink/program.rb @@ -33,7 +33,7 @@ class Communication::Website::Permalink::Program < Communication::Website::Perma end # /formations/:slug/ - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::EducationProgram).slug_with_ancestors}/:slug/" end end diff --git a/app/models/communication/website/permalink/researcher.rb b/app/models/communication/website/permalink/researcher.rb index d9a85ca2e6ceac30a2bfd37cbcc414c28dfc45c9..59d8dd7a836e66b3949810571f872b2707286a31 100644 --- a/app/models/communication/website/permalink/researcher.rb +++ b/app/models/communication/website/permalink/researcher.rb @@ -34,7 +34,7 @@ class Communication::Website::Permalink::Researcher < Communication::Website::Pe # /equipe/:slug/papers/ # FIXME - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::Person).slug_with_ancestors}/:slug/papers/" end end diff --git a/app/models/communication/website/permalink/teacher.rb b/app/models/communication/website/permalink/teacher.rb index 6a75142aa196cd79dd88b2cac0285bd3fcb5c63f..a952bbfdf8758d852fbce0299b9d5896fe843f12 100644 --- a/app/models/communication/website/permalink/teacher.rb +++ b/app/models/communication/website/permalink/teacher.rb @@ -34,7 +34,7 @@ class Communication::Website::Permalink::Teacher < Communication::Website::Perma # /equipe/:slug/programs/ # FIXME - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::Person).slug_with_ancestors}/:slug/programs/" end end diff --git a/app/models/communication/website/permalink/volume.rb b/app/models/communication/website/permalink/volume.rb index 96774e65de72512b292fee2ca322f3c8ae6790f6..81b2aab5c1afd1e9190538a2b35588f1c5b3c7df 100644 --- a/app/models/communication/website/permalink/volume.rb +++ b/app/models/communication/website/permalink/volume.rb @@ -33,7 +33,7 @@ class Communication::Website::Permalink::Volume < Communication::Website::Permal end # /volumes/:slug/ - def self.pattern_in_website(website) + def self.pattern_in_website(website, language) "/#{website.special_page(Communication::Website::Page::ResearchVolume).slug_with_ancestors}/:year-:slug/" end diff --git a/app/views/admin/communication/websites/configs/default_languages/static.html.erb b/app/views/admin/communication/websites/configs/default_languages/static.html.erb index 8657a91ea7bbfbd54c57a9aba19d5484276d8b9d..f221d66584ca48a27f353b934d42306431f08bc8 100644 --- a/app/views/admin/communication/websites/configs/default_languages/static.html.erb +++ b/app/views/admin/communication/websites/configs/default_languages/static.html.erb @@ -6,4 +6,8 @@ contentDir: content/<%= language.iso_code %> languageCode: <%= language.iso_code %> languageName: <%= language.name %> + permalinks: + <% Communication::Website::Permalink.config_in_website(@website, language).each do |key, value| %> + <%= key %>: <%= value %> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/configs/default_permalinks/static.html.erb b/app/views/admin/communication/websites/configs/default_permalinks/static.html.erb index 27ed0728ff2dc7ab5e9a9d2cc748e0d2445768cc..ec8135a858f5574a2e1383055dba4c1326282df5 100644 --- a/app/views/admin/communication/websites/configs/default_permalinks/static.html.erb +++ b/app/views/admin/communication/websites/configs/default_permalinks/static.html.erb @@ -1,5 +1,2 @@ # DO NOT EDIT THIS FILE BY HAND - IT WILL BE OVERWRITTEN BY OSUNY - -<% Communication::Website::Permalink.config_in_website(@website).each do |key, value| %> -<%= key %>: <%= value %> -<% end %> \ No newline at end of file +# Moved to languages.yml