diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index 8408d7eca..652b59e7c 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -507,8 +507,10 @@ def available_admin_sets def inject_show_theme_views if show_page_theme && show_page_theme != 'default_show' original_paths = view_paths - show_theme_view_path = Rails.root.join('app', 'views', "themes", show_page_theme.to_s) - prepend_view_path(show_theme_view_path) + Hyku::Application.theme_view_path_roots.each do |root| + show_theme_view_path = File.join(root, 'app', 'views', "themes", show_page_theme.to_s) + prepend_view_path(show_theme_view_path) + end yield # rubocop:disable Lint/UselessAssignment, Layout/SpaceAroundOperators, Style/RedundantParentheses # Do NOT change this line. This is calling the Rails view_paths=(paths) method and not a variable assignment. diff --git a/app/controllers/hyrax/contact_form_controller.rb b/app/controllers/hyrax/contact_form_controller.rb index e520429e5..4e098736b 100644 --- a/app/controllers/hyrax/contact_form_controller.rb +++ b/app/controllers/hyrax/contact_form_controller.rb @@ -104,8 +104,10 @@ def collections(rows: 6) def inject_theme_views if home_page_theme && home_page_theme != 'default_home' original_paths = view_paths - home_theme_view_path = Rails.root.join('app', 'views', "themes", home_page_theme.to_s) - prepend_view_path(home_theme_view_path) + Hyku::Application.theme_view_path_roots.each do |root| + home_theme_view_path = File.join(root, 'app', 'views', "themes", home_page_theme.to_s) + prepend_view_path(home_theme_view_path) + end yield # rubocop:disable Lint/UselessAssignment, Layout/SpaceAroundOperators, Style/RedundantParentheses # Do NOT change this line. This is calling the Rails view_paths=(paths) method and not a variable assignment. diff --git a/app/controllers/hyrax/pages_controller.rb b/app/controllers/hyrax/pages_controller.rb index 2c07c8e99..0107739fb 100644 --- a/app/controllers/hyrax/pages_controller.rb +++ b/app/controllers/hyrax/pages_controller.rb @@ -101,8 +101,10 @@ def collections(rows: 6) def inject_theme_views if home_page_theme && home_page_theme != 'default_home' original_paths = view_paths - home_theme_view_path = Rails.root.join('app', 'views', "themes", home_page_theme.to_s) - prepend_view_path(home_theme_view_path) + Hyku::Application.theme_view_path_roots.each do |root| + home_theme_view_path = File.join(root, 'app', 'views', "themes", home_page_theme.to_s) + prepend_view_path(home_theme_view_path) + end yield # rubocop:disable Lint/UselessAssignment, Layout/SpaceAroundOperators, Style/RedundantParentheses # Do NOT change this method. This is an override of the view_paths= method and not a variable assignment. diff --git a/config/application.rb b/config/application.rb index 060f1df9b..c256d9c00 100644 --- a/config/application.rb +++ b/config/application.rb @@ -68,6 +68,22 @@ class Application < Rails::Application # Add the middleware directory to the eager load paths config.eager_load_paths << Rails.root.join('app', 'middleware') + ## + # @return [Array] an array of strings in which we should be looking for theme view + # candidates. + # @see Hyrax::WorksControllerBehavior + # @see Hyrax::ContactFormController + # @see Hyrax::PagesController + # @see https://api.rubyonrails.org/classes/ActionView/ViewPaths.html#method-i-prepend_view_path + # + # @see .path_for + # @see + def self.theme_view_path_roots + returning_value = [Rails.root.to_s] + returning_value.push HykuKnapsack::Engine.root.to_s if defined?(HykuKnapsack) + returning_value + end + ## # @api public # @@ -75,6 +91,7 @@ class Application < Rails::Application # # @return [String] the path to the file, favoring those found in the knapsack but falling back # to those in the Rails.root. + # @see .theme_view_path_roots def self.path_for(relative_path) if defined?(HykuKnapsack) engine_path = HykuKnapsack::Engine.root.join(relative_path) @@ -93,9 +110,7 @@ def self.path_for(relative_path) config.middleware.use Rack::Deflater # The locale is set by a query parameter, so if it's not found render 404 - config.action_dispatch.rescue_responses.merge!( - "I18n::InvalidLocale" => :not_found - ) + config.action_dispatch.rescue_responses["I18n::InvalidLocale"] = :not_found if defined?(ActiveElasticJob) && ENV.fetch('HYRAX_ACTIVE_JOB_QUEUE', '') == 'elastic' Rails.application.configure do