Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ENV BUNDLE_DISABLE_LOCAL_BRANCH_CHECK=true
RUN bundle install --jobs "$(nproc)"
############## END KNAPSACK SPECIFIC CODE ################

RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DB_URL='postgresql://fake' bundle exec rake assets:precompile && yarn install
RUN RAILS_ENV=production SECRET_KEY_BASE=$(bin/rails secret) DB_ADAPTER=nulldb DB_URL='postgresql://fake' bundle exec rails assets:precompile && yarn install
CMD ./bin/web

FROM hyku-web AS hyku-worker
Expand Down
13 changes: 0 additions & 13 deletions app/services/hyrax/simple_schema_loader_decorator.rb

This file was deleted.

5 changes: 5 additions & 0 deletions config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@

Rails.application.config.after_initialize do
Hyrax.config do |config|
config.flexible = ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYRAX_FLEXIBLE', 'false'))

# Prepend to ensure knapsack profile is checked before the host app's profiles.
config.schema_loader_config_search_paths.unshift(HykuKnapsack::Engine.root) \
if config.respond_to?(:schema_loader_config_search_paths)
end
end
2 changes: 1 addition & 1 deletion hyku_knapsack.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
Dir["{app,config,db,lib}/**/*", "LICENSE", "Rakefile", "README.md"]
end

spec.add_dependency "rails", ">= 5.2.0"
spec.add_dependency "rails", ">= 7.2.0"

spec.add_development_dependency "rubocop-rake"
end
2 changes: 1 addition & 1 deletion hyrax-webapp
Submodule hyrax-webapp updated 448 files
7 changes: 7 additions & 0 deletions lib/hyku_knapsack.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# frozen_string_literal: true

# Respect Hyku's default: HYRAX_FLEXIBLE is off unless set by the app (e.g. .env, docker-compose).
# Do not set ENV['HYRAX_FLEXIBLE'] here so downstream apps control it.

require "hyku_knapsack/version"
require "hyku_knapsack/engine"

# Disable include_metadata only when flexible mode is explicitly enabled.
ENV['HYRAX_DISABLE_INCLUDE_METADATA'] = 'true' if ENV['HYRAX_FLEXIBLE'] == 'true'

module HykuKnapsack
# Your code goes here...
end
30 changes: 22 additions & 8 deletions lib/hyku_knapsack/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ module HykuKnapsack
class Engine < ::Rails::Engine
isolate_namespace HykuKnapsack

# Load knapsack initializers from config/initializers/ AFTER the host app's
# initializers run (e.g. after hyku's 1flexible.rb), so knapsack overrides win.
initializer 'hyku_knapsack.load_initializers', after: :load_config_initializers do
Dir[HykuKnapsack::Engine.root.join('config', 'initializers', '*.rb')].sort.each do |initializer|
load initializer
end
end

def self.load_translations!
HykuKnapsack::Engine.root.glob("config/locales/**/*.yml").each do |path|
I18n.load_path << path.to_s
Expand All @@ -30,6 +38,17 @@ def self.load_translations!
end

config.before_initialize do
# When running in flexible metadata mode, disable include_metadata for all resource
# types so that schemas are driven entirely by the M3 profile rather than core_metadata.
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYRAX_FLEXIBLE', 'false'))
if defined?(Hyrax) && Hyrax.respond_to?(:config)
Hyrax.config.work_include_metadata = false
Hyrax.config.collection_include_metadata = false
Hyrax.config.file_set_include_metadata = false
Hyrax.config.admin_set_include_metadata = false
end
end

config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"]

# if Hyku::Application.respond_to?(:user_devise_parameters=)
Expand All @@ -44,14 +63,9 @@ def self.load_translations!
# ]
# end

# Add knapsack schema search path
if Hyrax.config.respond_to?(:schema_loader_config_search_paths)
Hyrax.config.schema_loader_config_search_paths += [HykuKnapsack::Engine.root]
else
# Ensure we are prepending the Hyku::SimpleSchemaLoaderDecorator early
require HykuKnapsack::Engine.root.join('app', 'services', 'hyrax', 'simple_schema_loader_decorator')
Hyrax::SimpleSchemaLoader.prepend(Hyrax::SimpleSchemaLoaderDecorator)
end
# Prepend knapsack root so its config/metadata/*.yaml schemas are found first.
Hyrax.config.schema_loader_config_search_paths.unshift(HykuKnapsack::Engine.root) \
if Hyrax.config.respond_to?(:schema_loader_config_search_paths)
end

config.to_prepare do
Expand Down
2 changes: 1 addition & 1 deletion lib/hyku_knapsack/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module HykuKnapsack
VERSION = "6.0.0"
VERSION = "7.0.0"
end
9 changes: 6 additions & 3 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# frozen_string_literal: true

# This file is copied to spec/ when you run 'rails generate rspec:install'
require "spec_helper"

# Set environment variables BEFORE requiring Rails environment
# so initializers read the correct values on first load.
ENV["RAILS_ENV"] ||= "test"
# Use Hyku default (false) unless a spec or .env sets HYRAX_FLEXIBLE.
ENV['HYRAX_FLEXIBLE'] ||= 'false'

require "spec_helper"

# require File.expand_path('../config/environment', __dir__)
require File.expand_path("../hyrax-webapp/config/environment", __dir__)
# Prevent database truncation if the environment is production
Expand Down
Loading