diff --git a/app/models/communication/website/author.rb b/app/models/communication/website/author.rb index 25480be7f5693ede23069e5ecf3c46194dd4b686..65b8783fb19201cfe51698040769b66f6f948f8d 100644 --- a/app/models/communication/website/author.rb +++ b/app/models/communication/website/author.rb @@ -58,7 +58,7 @@ class Communication::Website::Author < ApplicationRecord def github_manifest super << { identifier: "collection_item", - generated_path: "_data/authors/#{slug}.yml", + generated_path: -> { "_data/authors/#{slug}.yml" }, data: -> (github_file) { ApplicationController.render( template: "admin/communication/website/authors/jekyll_collection", formats: [:yml], diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index 0211ad17295ebc8962d808d00e1ed08e9341f053..11a09fe23f8acaf215e09168c3ad24d861ef2b9c 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -84,7 +84,7 @@ class Communication::Website::Category < ApplicationRecord def github_manifest super << { identifier: "collection_item", - generated_path: "_data/categories/#{slug}.yml", + generated_path: -> { "_data/categories/#{slug}.yml" }, data: -> (github_file) { ApplicationController.render( template: "admin/communication/website/categories/jekyll_collection", formats: [:yml], diff --git a/app/models/communication/website/github_file.rb b/app/models/communication/website/github_file.rb index 11b428692fc6215520e806c6974678ef362e0c00..2abf6433c4f041c301ecb85a3d3ca9ea51aa3d7d 100644 --- a/app/models/communication/website/github_file.rb +++ b/app/models/communication/website/github_file.rb @@ -27,16 +27,16 @@ class Communication::Website::GithubFile < ApplicationRecord after_destroy :remove_from_github def publish - return unless valid? && github.valid? + return unless valid_for_publication? && github.valid? add_to_batch(github) if github.commit_batch(github_commit_message) - update_column :github_path, manifest_data[:generated_path] + update_column :github_path, manifest_data[:generated_path].call end end handle_asynchronously :publish, queue: 'default' def add_to_batch(github) - return unless valid? + return unless valid_for_publication? github.add_to_batch github_params add_media_to_batch(github) end @@ -82,7 +82,7 @@ class Communication::Website::GithubFile < ApplicationRecord def github_params { - path: manifest_data[:generated_path], + path: manifest_data[:generated_path].call, previous_path: github_path, data: manifest_data[:data].call(self) } @@ -122,7 +122,7 @@ class Communication::Website::GithubFile < ApplicationRecord } end - def valid? + def valid_for_publication? return about.published? if about_type == 'Communication::Website::Post' true end diff --git a/app/models/concerns/with_github_files.rb b/app/models/concerns/with_github_files.rb index 5a6aea780fb94eb018285974e004f5d3d56c8140..e42292cca5052348c7247501af8a4f76e4ad2c4e 100644 --- a/app/models/concerns/with_github_files.rb +++ b/app/models/concerns/with_github_files.rb @@ -28,7 +28,7 @@ module WithGithubFiles [ { identifier: "primary", - generated_path: github_path_generated, + generated_path: -> { github_path_generated }, data: -> (github_file) { to_jekyll(github_file) }, has_media: true }