diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 1b53a75e6d9bf2694d9863c29c498d96b3a6ff00..72f5ddb8be1dabf5cbaf76b8b71245e82a1fa267 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -30,7 +30,7 @@ # fk_rails_bb6a496c08 (university_id => universities.id) # class Communication::Website < ApplicationRecord - self.filter_attributes += [ :access_token ] + self.filter_attributes += [:access_token] include WithUniversity include WithAbouts diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index 3f378dcb0c0f7130b6ba06dac72eb44d30984485..1d3d87c76bac03cbf4af9916db090c2f35f33c1e 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/#{slug_with_ancestors_slugs}/_index.html" + "#{git_path_content_prefix(website)}categories/#{slug_with_ancestors_slugs}/_index.html" end def template_static diff --git a/app/models/communication/website/page/with_path.rb b/app/models/communication/website/page/with_path.rb index 636653db273c76330877ba215a68926a2b8cb8d4..9ff256b1287cb2986f1c5486fbccce43dcfb8004 100644 --- a/app/models/communication/website/page/with_path.rb +++ b/app/models/communication/website/page/with_path.rb @@ -33,13 +33,17 @@ module Communication::Website::Page::WithPath def git_path(website) return unless website.id == communication_website_id && published + + path = git_path_content_prefix(website) if kind_home? - "content/_index.html" + path += "_index.html" elsif has_special_git_path? - "content/#{kind.split('_').last}/_index.html" + path += "#{kind.split('_').last}/_index.html" else - "content/pages/#{path}/_index.html" + path += "pages/#{path_without_language}/_index.html" end + + path end def url diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 72f74c3216bb9d7c9c260cf28e7f192b32671fec..5704cc4b8cd3f3558e5e448bfc4e5668e870813e 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -108,7 +108,7 @@ class Communication::Website::Post < ApplicationRecord end def git_path(website) - "content/posts/#{static_path}.html" if website.id == communication_website_id && published && published_at + "#{git_path_content_prefix(website)}posts/#{static_path}.html" if website.id == communication_website_id && published && published_at end def static_path diff --git a/app/models/concerns/with_git.rb b/app/models/concerns/with_git.rb index 2da1884f0aa962081594b1faf6f41e69ea5e68d6..2c07b0b2d6a9f462ea65885f72cded7c8d66d552 100644 --- a/app/models/concerns/with_git.rb +++ b/app/models/concerns/with_git.rb @@ -12,6 +12,14 @@ module WithGit raise NotImplementedError end + def git_path_content_prefix(website) + # Handle legacy language-less websites + # TODO: Right now, we use the language of the website. It HAS TO get the language from the object including this concern. + path = "content/" + path += "#{website.languages.first.iso_code}/" if website.languages.any? + path + end + def before_git_sync # Can be override to force some process before sync # ex: ActiveStorage Blob analyze diff --git a/app/models/education/diploma.rb b/app/models/education/diploma.rb index 00cd553a0cdbd586676252089d7dd8ef37647468..614f4afd87d2970da8891f77d9f65eb777c96f84 100644 --- a/app/models/education/diploma.rb +++ b/app/models/education/diploma.rb @@ -66,7 +66,7 @@ class Education::Diploma < ApplicationRecord end def git_path(website) - "content/diplomas/#{slug}/_index.html" if for_website?(website) + "#{git_path_content_prefix(website)}diplomas/#{slug}/_index.html" if for_website?(website) end def git_dependencies(website) diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 9ffd591ce0c441fcef7d454c00db8bc9d96bcbee..271faf60ca81ecb33d91a77fea6582dfb2a25e0b 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -133,7 +133,7 @@ class Education::Program < ApplicationRecord end def git_path(website) - "content/programs/#{path}/_index.html" if for_website?(website) + "#{git_path_content_prefix(website)}programs/#{path}/_index.html" if for_website?(website) end def path_in_website(website) diff --git a/app/models/research/journal/paper.rb b/app/models/research/journal/paper.rb index 36cb94a1b3f5a3970b6b6a98f411382e12602ad2..d257f16a5c07b33900bb5145714662409120023d 100644 --- a/app/models/research/journal/paper.rb +++ b/app/models/research/journal/paper.rb @@ -62,7 +62,7 @@ class Research::Journal::Paper < ApplicationRecord scope :ordered, -> { order(published_at: :desc, created_at: :desc) } def git_path(website) - "content/papers/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" if (volume.nil? || volume.published_at) && published_at + "#{git_path_content_prefix(website)}papers/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" if (volume.nil? || volume.published_at) && published_at end def template_static diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb index 52fd676b46e5700341de25fe225f530817d7fe91..2b14ba3bfcbc3268ca035b1ff3e09c56535a4104 100644 --- a/app/models/research/journal/volume.rb +++ b/app/models/research/journal/volume.rb @@ -53,7 +53,7 @@ class Research::Journal::Volume < ApplicationRecord end def git_path(website) - "content/volumes/#{published_at.year}/#{slug}/_index.html" if published_at + "#{git_path_content_prefix(website)}volumes/#{published_at.year}/#{slug}/_index.html" if published_at end def template_static diff --git a/app/models/university/organization.rb b/app/models/university/organization.rb index b7e6cd4ae954f2d7584b16f20372f62e7f3d4b8b..31c57551e4fcb3762a7855bde913e3d9558f5cdd 100644 --- a/app/models/university/organization.rb +++ b/app/models/university/organization.rb @@ -108,7 +108,7 @@ class University::Organization < ApplicationRecord end def git_path(website) - "content/organizations/#{slug}.html" if for_website?(website) + "#{git_path_content_prefix(website)}organizations/#{slug}.html" if for_website?(website) end def to_s diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 1e7716b6ac7fc06824dbc35baf12a46211d4b617..39479bef34e70254f0b61f81661ea111a15b2961 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -177,7 +177,7 @@ class University::Person < ApplicationRecord end def git_path(website) - "content/persons/#{slug}.html" if for_website?(website) + "#{git_path_content_prefix(website)}persons/#{slug}.html" if for_website?(website) end def git_dependencies(website) diff --git a/app/models/university/person/administrator.rb b/app/models/university/person/administrator.rb index cc72eecb845fcee9fab00f9ae0392abaf37ff746..d90758a2487459dfce9196a368037dfee4243978 100644 --- a/app/models/university/person/administrator.rb +++ b/app/models/university/person/administrator.rb @@ -51,7 +51,7 @@ class University::Person::Administrator < University::Person end def git_path(website) - "content/administrators/#{slug}/_index.html" if for_website?(website) + "#{git_path_content_prefix(website)}administrators/#{slug}/_index.html" if for_website?(website) end def template_static diff --git a/app/models/university/person/author.rb b/app/models/university/person/author.rb index 08ad2f90c90ac9da272ffacc8ddea0c64946b0a2..a41fe14bfffcd7fe9cc90a07ced424a0efe0e0bb 100644 --- a/app/models/university/person/author.rb +++ b/app/models/university/person/author.rb @@ -51,7 +51,7 @@ class University::Person::Author < University::Person end def git_path(website) - "content/authors/#{slug}/_index.html" if for_website?(website) + "#{git_path_content_prefix(website)}authors/#{slug}/_index.html" if for_website?(website) end def template_static diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index 254d0ce1fa9f08b9f2f081a8a73a599eff2b280e..2a54ba57de38d7633616e26caa27ae85f3554c11 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -51,7 +51,7 @@ class University::Person::Researcher < University::Person end def git_path(website) - "content/researchers/#{slug}/_index.html" if for_website?(website) + "#{git_path_content_prefix(website)}researchers/#{slug}/_index.html" if for_website?(website) end def template_static diff --git a/app/models/university/person/teacher.rb b/app/models/university/person/teacher.rb index 83303c45cd346f38aeaeeccadd665b2764275f2c..7d74764617dd1d8613017b80d454759790dcae49 100644 --- a/app/models/university/person/teacher.rb +++ b/app/models/university/person/teacher.rb @@ -52,7 +52,7 @@ class University::Person::Teacher < University::Person end def git_path(website) - "content/teachers/#{slug}/_index.html" if for_website?(website) + "#{git_path_content_prefix(website)}teachers/#{slug}/_index.html" if for_website?(website) end def template_static