From 966038b1960b43f66009566ac20248b86de1dcac Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Wed, 31 Jan 2024 12:39:59 -0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20boot=20problem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix will add a few more requires to the engine.rb file and also move the simple schema loader decorator to the valkyrie_adapter because when a valkyrie application is booting up, the schema path needs to be in place before loading the yaml. --- lib/iiif_print.rb | 3 +++ lib/iiif_print/engine.rb | 4 ---- lib/iiif_print/persistence_layer/valkyrie_adapter.rb | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/iiif_print.rb b/lib/iiif_print.rb index 3132c1b0..48bfd21f 100644 --- a/lib/iiif_print.rb +++ b/lib/iiif_print.rb @@ -22,6 +22,9 @@ require "iiif_print/split_pdfs/child_work_creation_from_pdf_service" require "iiif_print/split_pdfs/derivative_rodeo_splitter" require "iiif_print/split_pdfs/destroy_pdf_child_works_service" +require "iiif_print/persistence_layer" +require "iiif_print/persistence_layer/active_fedora_adapter" +require "iiif_print/persistence_layer/valkyrie_adapter" # rubocop:disable Metrics/ModuleLength module IiifPrint diff --git a/lib/iiif_print/engine.rb b/lib/iiif_print/engine.rb index 0437fc8a..a4d1feeb 100644 --- a/lib/iiif_print/engine.rb +++ b/lib/iiif_print/engine.rb @@ -51,10 +51,6 @@ class Engine < ::Rails::Engine Hyrax::IiifManifestPresenter.prepend(IiifPrint::IiifManifestPresenterBehavior) Hyrax::IiifManifestPresenter::Factory.prepend(IiifPrint::IiifManifestPresenterFactoryBehavior) Hyrax::ManifestBuilderService.prepend(IiifPrint::ManifestBuilderServiceBehavior) - - # Hyrax::SimpleSchemaLoader was introduced in Hyrax 3.0; as this gem supports Hyrax 2.9.6 we need to be cautious - 'Hyrax::SimpleSchemaLoader'.safe_constantize&.prepend(IiifPrint::SimpleSchemaLoaderDecorator) - Hyrax::Renderers::FacetedAttributeRenderer.prepend(Hyrax::Renderers::FacetedAttributeRendererDecorator) Hyrax::WorksControllerBehavior.prepend(IiifPrint::WorksControllerBehaviorDecorator) diff --git a/lib/iiif_print/persistence_layer/valkyrie_adapter.rb b/lib/iiif_print/persistence_layer/valkyrie_adapter.rb index fa2e3322..d80979f9 100644 --- a/lib/iiif_print/persistence_layer/valkyrie_adapter.rb +++ b/lib/iiif_print/persistence_layer/valkyrie_adapter.rb @@ -21,6 +21,9 @@ def self.object_ordered_works(object) # @param work_type [Class] # @return the indexer for the given :work_type def self.decorate_with_adapter_logic(work_type:) + # Originally prepended in the engine.rb but this placement loads it sooner. + Hyrax::SimpleSchemaLoader.prepend(IiifPrint::SimpleSchemaLoaderDecorator) + work_type.send(:include, Hyrax::Schema(:child_works_from_pdf_splitting)) unless work_type.included_modules.include?(Hyrax::Schema(:child_works_from_pdf_splitting)) # TODO: Use `Hyrax::ValkyrieIndexer.indexer_class_for` once changes are merged. indexer = "#{work_type}Indexer".constantize From 1ccdccc91903b4bea512df72a96b0998f2519b2f Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Wed, 31 Jan 2024 15:49:06 -0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Move=20SimpleSchemaLoader=20?= =?UTF-8?q?to=20initializer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/initializers/simple_schema_loader.rb | 1 + lib/iiif_print/persistence_layer/valkyrie_adapter.rb | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) create mode 100644 config/initializers/simple_schema_loader.rb diff --git a/config/initializers/simple_schema_loader.rb b/config/initializers/simple_schema_loader.rb new file mode 100644 index 00000000..83cc7d7c --- /dev/null +++ b/config/initializers/simple_schema_loader.rb @@ -0,0 +1 @@ +Hyrax::SimpleSchemaLoader.prepend(IiifPrint::SimpleSchemaLoaderDecorator) diff --git a/lib/iiif_print/persistence_layer/valkyrie_adapter.rb b/lib/iiif_print/persistence_layer/valkyrie_adapter.rb index d80979f9..fa2e3322 100644 --- a/lib/iiif_print/persistence_layer/valkyrie_adapter.rb +++ b/lib/iiif_print/persistence_layer/valkyrie_adapter.rb @@ -21,9 +21,6 @@ def self.object_ordered_works(object) # @param work_type [Class] # @return the indexer for the given :work_type def self.decorate_with_adapter_logic(work_type:) - # Originally prepended in the engine.rb but this placement loads it sooner. - Hyrax::SimpleSchemaLoader.prepend(IiifPrint::SimpleSchemaLoaderDecorator) - work_type.send(:include, Hyrax::Schema(:child_works_from_pdf_splitting)) unless work_type.included_modules.include?(Hyrax::Schema(:child_works_from_pdf_splitting)) # TODO: Use `Hyrax::ValkyrieIndexer.indexer_class_for` once changes are merged. indexer = "#{work_type}Indexer".constantize