Skip to content

Commit

Permalink
Merge pull request #2010 from samvera/adding-knapsack-handling-for-files
Browse files Browse the repository at this point in the history
♻️ Add handling for Knapsack theme overrides
  • Loading branch information
jeremyf authored Oct 5, 2023
2 parents fd32f03 + 5e0cc2c commit de00833
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/hyrax/admin/appearances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def show
add_breadcrumbs
@form = form_class.new
@fonts = [@form.headline_font, @form.body_font]
@home_theme_information = YAML.load_file('config/home_themes.yml')
@show_theme_information = YAML.load_file('config/show_themes.yml')
@home_theme_information = YAML.load_file(Hyku::Application.path_for('config/home_themes.yml'))
@show_theme_information = YAML.load_file(Hyku::Application.path_for('config/show_themes.yml'))
@home_theme_names = load_home_theme_names
@show_theme_names = load_show_theme_names
@search_themes = load_search_themes
Expand Down
16 changes: 16 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ class Application < Rails::Application
# IiifPrint::SplitPdfs::AdventistPagesToJpgsSplitter
config.autoload_paths.unshift("#{Rails.root}/lib")

##
# @api public
#
# @param relative_path [String] lookup the relative paths first in the Knapsack then in Hyku.
#
# @return [String] the path to the file, favoring those found in the knapsack but falling back
# to those in the Rails.root.
def self.path_for(relative_path)
if defined?(HykuKnapsack)
engine_path = HykuKnapsack::Engine.root.join(relative_path)
return engine_path.to_s if engine_path.exist?
end

Rails.root.join(relative_path).to_s
end

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand Down

0 comments on commit de00833

Please sign in to comment.