-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚙️ Move Engine's to_prepare to an initializer
This commit will resolve load ordering. Previously, we were loading the decorators from HykuKnapsack before we load the App's, which is standard behavior, but we actually want the decorators from HykuKnapsack to load last.
- Loading branch information
Showing
4 changed files
with
52 additions
and
50 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...s/hyrax/collection_presenter_decorator.rb → ...ers/adl/collection_presenter_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
# OVERRIDE HYRAX 3.5.0 | ||
module Hyrax | ||
module Adl | ||
module CollectionPresenterDecorator | ||
module ClassMethods | ||
# Terms is the list of fields displayed by | ||
# app/views/collections/_show_descriptions.html.erb | ||
def terms | ||
super + Collection.additional_terms | ||
super - [:size] + Collection.additional_terms | ||
end | ||
end | ||
end | ||
end | ||
|
||
Hyrax::CollectionPresenter.singleton_class.prepend(Hyrax::CollectionPresenterDecorator::ClassMethods) | ||
Hyrax::CollectionPresenter.singleton_class.prepend(Adl::CollectionPresenterDecorator::ClassMethods) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
# This is the opposite of what you usually want to do. Normally app views override engine | ||
# views and app decorators override engine decorators but in our case things in the Knapsack | ||
# override what is in the application. | ||
# | ||
# Furthermore we need to account for when the ApplicationController and it's descendants set | ||
# their individual view_paths. By looping through all descendants, we ensure that we have | ||
# the Knapsack views at the beginning of the list of view_paths. | ||
# | ||
# In the load sequence, when we load ApplicationController, we establish the view_path for all | ||
# future descendants. When we then encounter a descendant, we copy the | ||
# ApplicationController's view_path to the descendant; then later after we've encountered most | ||
# all of the descendants we updated the ApplicationController's view_path, but that does not | ||
# propogate to the descendants' copied view_path. | ||
Rails.application.config.to_prepare do | ||
HykuKnapsack::Engine.root.glob("app/**/*_decorator*.rb").sort.each do |c| | ||
Rails.configuration.cache_classes ? require(c) : load(c) | ||
end | ||
|
||
HykuKnapsack::Engine.root.glob("lib/**/*_decorator*.rb").sort.each do |c| | ||
Rails.configuration.cache_classes ? require(c) : load(c) | ||
end | ||
|
||
([::ApplicationController] + ::ApplicationController.descendants).each do |klass| | ||
paths = klass.view_paths.collect(&:to_s) | ||
paths = [HykuKnapsack::Engine.root.join('app', 'views').to_s] + paths | ||
klass.view_paths = paths.uniq | ||
end | ||
::ApplicationController.send :helper, HykuKnapsack::Engine.helpers | ||
|
||
GenericWorkResourceForm.include Hyrax::FormFields(:slug_metadata) | ||
GenericWorkResourceForm.include(SlugBugValkyrie) | ||
ImageResourceForm.include Hyrax::FormFields(:slug_metadata) | ||
ImageResourceForm.include(SlugBugValkyrie) | ||
|
||
Hyrax::Forms::CollectionForm.terms += ::Collection.additional_terms | ||
::Collection.include ::Hyrax::CollectionBehavior | ||
::Collection.include SlugMetadata | ||
::Collection.include AdventistMetadata | ||
::Collection.include DogBiscuits::JournalArticleMetadata | ||
::Collection.include DogBiscuits::BibliographicCitation | ||
::Collection.include DogBiscuits::DateIssued | ||
::Collection.include DogBiscuits::Geo | ||
::Collection.include DogBiscuits::PlaceOfPublication | ||
::Collection.include DogBiscuits::RemoteUrl | ||
Hyrax::CollectionPresenter.delegate(*::Collection.additional_terms, to: :solr_document) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters