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
belongs_to :website, class_name: 'Communication::Website'
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?
previous_path == path && previous_sha == sha
end
......
......@@ -75,6 +75,10 @@ class Communication::Website::Page < ApplicationRecord
"content/pages/#{path}/_index.html".gsub(/\/+/, '/')
end
def git_dependencies(identifier)
descendents
end
def list_of_other_pages
website.list_of_pages.reject! { |p| p[:id] == id }
end
......
......@@ -11,8 +11,10 @@ module WithGit
def sync_with_git
websites.each do |website|
identifiers.each do |identifier|
git_file = git_files.where(website: website, about: self, identifier: identifier).first_or_create
website.git_repository.add_git_file git_file
Communication::Website::GitFile.sync website, self, identifier
git_dependencies(identifier).each do |object|
Communication::Website::GitFile.sync website, object, identifier
end
end
website.git_repository.sync!
end
......@@ -21,7 +23,11 @@ module WithGit
def git_path_static
""
''
end
def git_dependencies(identifier)
[]
end
# Overridden for multiple files generation
......@@ -33,15 +39,4 @@ module WithGit
def websites
[website]
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
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