From 864b1757b5808d758205b3381f634c4a4f759c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Mon, 6 Dec 2021 18:50:42 +0100 Subject: [PATCH] wip website clean --- .../website/with_publishable_objects.rb | 31 ++----------------- app/models/research/journal/article.rb | 5 +-- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/app/models/communication/website/with_publishable_objects.rb b/app/models/communication/website/with_publishable_objects.rb index 98bb2b20e..78b8d7f2b 100644 --- a/app/models/communication/website/with_publishable_objects.rb +++ b/app/models/communication/website/with_publishable_objects.rb @@ -5,25 +5,10 @@ module Communication::Website::WithPublishableObjects def publish_about_object # TODO: Handle Research::Journal then use the commented version. - # publish_object(about) unless about.nil? - publish_object(about) if about.is_a?(Education::School) + # about.force_publish! unless about.nil? + about.force_publish! if about.is_a?(Education::School) end - def publish_object(object) - # "object" can be an Education::Program, ... - return unless github.valid? - object_model_name = object.class.name.demodulize - if object.respond_to?(:github_path) - github_path = object.github_path - else - root_folder = "_#{object_model_name.pluralize.underscore}" - github_path = "#{root_folder}/#{object.id}.md" - end - github_commit_message = "[#{object_model_name}] Save #{object.to_s}" - github.publish(path: github_path, commit: github_commit_message, data: object.to_jekyll) - end - handle_asynchronously :publish_object, queue: 'default' - def publish_blob(blob) return unless github.valid? blob.analyze unless blob.analyzed? @@ -38,18 +23,6 @@ module Communication::Website::WithPublishableObjects end handle_asynchronously :publish_blob, queue: 'default' - def remove_object(object) - return unless github.valid? - if object.respond_to?(:github_path) - github_path = object.github_path - else - root_folder = "_#{object_model_name.pluralize.underscore}" - github_path = "#{root_folder}/#{object.id}.md" - end - github_commit_message = "[#{object_model_name}] Remove #{object.to_s}" - github.remove(github_path, github_commit_message) - end - def remove_blob(blob) return unless github.valid? github_path = "_data/media/#{blob.id[0..1]}/#{blob.id}.yml" diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb index 1dd1124fb..4c9e45517 100644 --- a/app/models/research/journal/article.rb +++ b/app/models/research/journal/article.rb @@ -63,9 +63,6 @@ class Research::Journal::Article < ApplicationRecord private def update_researchers - return unless websites.any? - researchers.each do |researcher| - websites.each { |website| website.publish_object(researcher) } - end + researchers.each(&:force_publish!) end end -- GitLab