Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ TO MAIN: Introduce Hyku::Application.theme_view_path_roots #2008

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/concerns/hyrax/works_controller_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,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 = root.join('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.
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/hyrax/contact_form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = root.join('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.
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/hyrax/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = root.join('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.
Expand Down
15 changes: 15 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ def self.utf_8_encode(string)
end

class Application < Rails::Application
##
# @return [Array<String>] 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
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

# Add this line to load the lib folder first because we need
config.autoload_paths.unshift("#{Rails.root}/lib")

Expand Down
Loading