Skip to content
Snippets Groups Projects
Commit f5381931 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

page saves descendents

parent df2a814b
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,11 @@ class Communication::Website::GitFile < ApplicationRecord ...@@ -25,6 +25,11 @@ class Communication::Website::GitFile < ApplicationRecord
belongs_to :website, class_name: 'Communication::Website' belongs_to :website, class_name: 'Communication::Website'
belongs_to :about, polymorphic: true belongs_to :about, polymorphic: true
def self.sync(website, object, identifier)
git_file = where(website: website, about: object, identifier: identifier).first_or_create
website.git_repository.add_git_file git_file
end
def synced? def synced?
previous_path == path && previous_sha == sha previous_path == path && previous_sha == sha
end end
......
...@@ -75,6 +75,10 @@ class Communication::Website::Page < ApplicationRecord ...@@ -75,6 +75,10 @@ class Communication::Website::Page < ApplicationRecord
"content/pages/#{path}/_index.html".gsub(/\/+/, '/') "content/pages/#{path}/_index.html".gsub(/\/+/, '/')
end end
def git_dependencies(identifier)
descendents
end
def list_of_other_pages def list_of_other_pages
website.list_of_pages.reject! { |p| p[:id] == id } website.list_of_pages.reject! { |p| p[:id] == id }
end end
......
...@@ -11,8 +11,10 @@ module WithGit ...@@ -11,8 +11,10 @@ module WithGit
def sync_with_git def sync_with_git
websites.each do |website| websites.each do |website|
identifiers.each do |identifier| identifiers.each do |identifier|
git_file = git_files.where(website: website, about: self, identifier: identifier).first_or_create Communication::Website::GitFile.sync website, self, identifier
website.git_repository.add_git_file git_file git_dependencies(identifier).each do |object|
Communication::Website::GitFile.sync website, object, identifier
end
end end
website.git_repository.sync! website.git_repository.sync!
end end
...@@ -21,7 +23,11 @@ module WithGit ...@@ -21,7 +23,11 @@ module WithGit
def git_path_static def git_path_static
"" ''
end
def git_dependencies(identifier)
[]
end end
# Overridden for multiple files generation # Overridden for multiple files generation
...@@ -33,15 +39,4 @@ module WithGit ...@@ -33,15 +39,4 @@ module WithGit
def websites def websites
[website] [website]
end end
protected
def sync_git_files
websites.each do |website|
identifiers.each do |identifier|
git_file = git_files.where(website: website, about: self, identifier: identifier).first_or_create
website.sync_file git_file
end
end
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment