From 51956c40bf13a5a654661e47b0534a77bc67a36d Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Tue, 10 Dec 2024 06:48:02 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A0=EF=B8=8F=20Resolve=20loading=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit will resolve some zeitwerk work issues and also remove the SavedSearchesController as it is deprecated. Ref: - https://github.com/projectblacklight/blacklight_advanced_search/issues/105 --- hydra/.gitignore | 2 + hydra/Gemfile | 4 +- hydra/Gemfile.lock | 45 ++++++++++++------- .../app/controllers/application_controller.rb | 4 ++ .../controllers/saved_searches_controller.rb | 6 --- .../controllers/search_history_controller.rb | 3 +- hydra/config/application.rb | 7 ++- hydra/config/environments/development.rb | 8 ++-- hydra/config/initializers/bulkrax.rb | 5 --- hydra/config/initializers/inflections.rb | 6 +-- hydra/config/initializers/zeitwerk.rb | 8 ++++ hydra/db/schema.rb | 36 +++++++-------- .../search_builder_decorator.rb | 0 13 files changed, 76 insertions(+), 58 deletions(-) delete mode 100644 hydra/app/controllers/saved_searches_controller.rb create mode 100644 hydra/config/initializers/zeitwerk.rb rename hydra/{app => lib}/blacklight/access_controls/search_builder_decorator.rb (100%) diff --git a/hydra/.gitignore b/hydra/.gitignore index 48fb168..7389524 100644 --- a/hydra/.gitignore +++ b/hydra/.gitignore @@ -15,3 +15,5 @@ # Ignore Byebug command history file. .byebug_history + +public/assets/* diff --git a/hydra/Gemfile b/hydra/Gemfile index c258304..e6c4fbb 100644 --- a/hydra/Gemfile +++ b/hydra/Gemfile @@ -38,7 +38,7 @@ gem 'bootsnap', '>= 1.4.2', require: false gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript' -# OAI-PMH +# OAI-PMH # ===================================================== gem 'blacklight_oai_provider', github: 'projectblacklight/blacklight_oai_provider', ref: '428da77' @@ -50,7 +50,7 @@ gem 'whenever', require: false # ===================================================== # Switch the comments on these two lines to work on Bulkrax locally # gem 'bulkrax', git: 'https://github.com/samvera-labs/bulkrax.git' , ref: 'b689afa' -gem 'bulkrax' +gem 'bulkrax', github: 'samvera/bulkrax', branch: 'hydra-rails-7-support' # Dependices for Thumbnail Creation # ===================================================== diff --git a/hydra/Gemfile.lock b/hydra/Gemfile.lock index 6f03413..d575371 100644 --- a/hydra/Gemfile.lock +++ b/hydra/Gemfile.lock @@ -24,6 +24,28 @@ GIT rsolr (>= 1.1.2, < 3) ruby-progressbar (~> 1.0) +GIT + remote: https://github.com/samvera/bulkrax.git + revision: b1774c34fc0951f885230520e4b97d38fe4c0dad + branch: hydra-rails-7-support + specs: + bulkrax (8.3.0) + bagit (~> 0.6.0) + coderay + denormalize_fields + iso8601 (~> 0.9.0) + kaminari + language_list (~> 1.2, >= 1.2.1) + libxml-ruby (~> 5.0) + loofah (>= 2.2.3) + marcel + oai (>= 0.4, < 2.x) + rack (>= 2.0.6) + rails (>= 5.1.6) + rdf (>= 2.0.2, < 4.0) + rubyzip + simple_form + GEM remote: https://rubygems.org/ specs: @@ -139,21 +161,6 @@ GEM autoprefixer-rails (>= 9.1.0) popper_js (>= 2.11.8, < 3) builder (3.3.0) - bulkrax (7.0.0) - bagit (~> 0.4) - coderay - denormalize_fields - iso8601 (~> 0.9.0) - kaminari - language_list (~> 1.2, >= 1.2.1) - libxml-ruby (~> 3.2.4) - loofah (>= 2.2.3) - oai (>= 0.4, < 2.x) - rack (>= 2.0.6) - rails (>= 5.1.6) - rdf (>= 2.0.2, < 4.0) - rubyzip - simple_form byebug (11.1.3) cancancan (3.6.1) childprocess (5.1.0) @@ -216,6 +223,7 @@ GEM net-http (>= 0.5.0) fcrepo_wrapper (0.9.0) ruby-progressbar + ffi (1.17.0-aarch64-linux-gnu) ffi (1.17.0-x86_64-linux-gnu) fiddle (1.1.5) fugit (1.11.1) @@ -311,7 +319,7 @@ GEM parslet rdf (~> 3.0) rdf-vocab (~> 3.0) - libxml-ruby (3.2.4) + libxml-ruby (5.0.3) link_header (0.0.8) linkeddata (3.3.1) json-ld (~> 3.3) @@ -378,6 +386,8 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.4) + nokogiri (1.17.0-aarch64-linux) + racc (~> 1.4) nokogiri (1.17.0-x86_64-linux) racc (~> 1.4) oai (1.2.1) @@ -691,6 +701,7 @@ GEM zeitwerk (2.7.1) PLATFORMS + aarch64-linux x86_64-linux DEPENDENCIES @@ -703,7 +714,7 @@ DEPENDENCIES blacklight_range_limit bootsnap (>= 1.4.2) bootstrap (~> 5.1) - bulkrax + bulkrax! bundler byebug coffee-rails (~> 4.2) diff --git a/hydra/app/controllers/application_controller.rb b/hydra/app/controllers/application_controller.rb index 8027532..1d7c073 100644 --- a/hydra/app/controllers/application_controller.rb +++ b/hydra/app/controllers/application_controller.rb @@ -24,4 +24,8 @@ def authenticate_if_needed # removing the following 2 lines will re-enable devise auth def authenticate_user! end + + def current_user + super || guest_user + end end diff --git a/hydra/app/controllers/saved_searches_controller.rb b/hydra/app/controllers/saved_searches_controller.rb deleted file mode 100644 index e9051e9..0000000 --- a/hydra/app/controllers/saved_searches_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true -class SavedSearchesController < ApplicationController - include Blacklight::SavedSearches - - helper BlacklightAdvancedSearch::RenderConstraintsOverride -end diff --git a/hydra/app/controllers/search_history_controller.rb b/hydra/app/controllers/search_history_controller.rb index 67cb014..1250b6d 100644 --- a/hydra/app/controllers/search_history_controller.rb +++ b/hydra/app/controllers/search_history_controller.rb @@ -1,6 +1,5 @@ class SearchHistoryController < ApplicationController include Blacklight::SearchHistory - - helper BlacklightRangeLimit::ViewHelperOverride + helper BlacklightAdvancedSearch::RenderConstraintsOverride helper RangeLimitHelper end diff --git a/hydra/config/application.rb b/hydra/config/application.rb index e95ff3b..1f1c43e 100755 --- a/hydra/config/application.rb +++ b/hydra/config/application.rb @@ -12,7 +12,7 @@ class Application < Rails::Application config.load_defaults 5.2 # Autoload lib/ folder including all subdirectories - config.autoload_paths += Dir["#{config.root}/lib/**/"] + config.autoload_paths << Rails.root.join('lib') # use SideKiq by default config.active_job.queue_adapter = :sidekiq @@ -21,6 +21,11 @@ class Application < Rails::Application Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")).sort.each do |c| Rails.configuration.cache_classes ? require(c) : load(c) end + + Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*_decorator*.rb")).sort.each do |c| + puts c + Rails.configuration.cache_classes ? require(c) : load(c) + end end # Settings in config/environments/* take precedence over those specified here. diff --git a/hydra/config/environments/development.rb b/hydra/config/environments/development.rb index d0ac8fb..36f8aa1 100755 --- a/hydra/config/environments/development.rb +++ b/hydra/config/environments/development.rb @@ -64,7 +64,7 @@ # Suppress logger output for asset requests. config.assets.quiet = true - # Email Tests + # Email Tests config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true config.action_mailer.delivery_method = :smtp @@ -75,7 +75,7 @@ port: 25, enable_starttls_auto: true } - + # Raises error for missing translations # config.action_view.raise_on_missing_translations = true @@ -84,8 +84,8 @@ config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.active_job.queue_adapter = :sidekiq - + # developers can add their individual ips to this value. This configuration can also take an array - config.web_console.allowed_ips = %w(127.0.0.1 172.0.0.0/8) + config.web_console.allowed_ips = %w(127.0.0.1 172.0.0.0/8 0.0.0.0/0) config.web_console.development_only = false end diff --git a/hydra/config/initializers/bulkrax.rb b/hydra/config/initializers/bulkrax.rb index 605286e..1a30328 100644 --- a/hydra/config/initializers/bulkrax.rb +++ b/hydra/config/initializers/bulkrax.rb @@ -111,8 +111,3 @@ # # specific delimeter should likely be present in the multi_value_element_split_on expression. # # config.multi_value_element_join_on = ' | ' # end - -# Sidebar for hyrax 3+ support -if Object.const_defined?(:Hyrax) && ::Hyrax::DashboardController&.respond_to?(:sidebar_partials) - Hyrax::DashboardController.sidebar_partials[:repository_content] << 'hyrax/dashboard/sidebar/bulkrax_sidebar_additions' -end diff --git a/hydra/config/initializers/inflections.rb b/hydra/config/initializers/inflections.rb index ac033bf..b4b5767 100755 --- a/hydra/config/initializers/inflections.rb +++ b/hydra/config/initializers/inflections.rb @@ -11,6 +11,6 @@ # end # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' -# end +ActiveSupport::Inflector.inflections(:en) do |inflect| + inflect.acronym 'API' # needed because of Bulkrax::API +end diff --git a/hydra/config/initializers/zeitwerk.rb b/hydra/config/initializers/zeitwerk.rb new file mode 100644 index 0000000..9d912e1 --- /dev/null +++ b/hydra/config/initializers/zeitwerk.rb @@ -0,0 +1,8 @@ +# Bulkrax is still a very Hyrax focused gem and though there has been +# work to make it more generic, there are still some Hyrax specific +# constants that are loaded when the gem is loaded. This initializer +# will ignore all files that have 'hyrax' in the path so that Bulkrax +# can be used in this Hydra application +Dir.glob(Bulkrax::Engine.root.join('**', '*hyrax*')).each do |path| + Rails.autoloaders.main.ignore(path) if File.directory?(path) +end diff --git a/hydra/db/schema.rb b/hydra/db/schema.rb index 79b456f..db6d4f5 100644 --- a/hydra/db/schema.rb +++ b/hydra/db/schema.rb @@ -33,10 +33,10 @@ t.bigint "importerexporter_id" t.text "raw_metadata" t.text "parsed_metadata" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.datetime "last_error_at" - t.datetime "last_succeeded_at" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.datetime "last_error_at", precision: nil + t.datetime "last_succeeded_at", precision: nil t.string "importerexporter_type", default: "Bulkrax::Importer" t.integer "import_attempts", default: 0 t.string "status_message", default: "Pending" @@ -65,10 +65,10 @@ t.string "export_source" t.string "export_from" t.string "export_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.datetime "last_error_at" - t.datetime "last_succeeded_at" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.datetime "last_error_at", precision: nil + t.datetime "last_succeeded_at", precision: nil t.date "start_date" t.date "finish_date" t.string "work_visibility" @@ -86,8 +86,8 @@ t.integer "processed_records", default: 0 t.integer "deleted_records", default: 0 t.integer "failed_records", default: 0 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.integer "processed_collections", default: 0 t.integer "failed_collections", default: 0 t.integer "total_collection_entries", default: 0 @@ -111,11 +111,11 @@ t.integer "limit" t.text "parser_fields" t.text "field_mapping" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.boolean "validate_only" - t.datetime "last_error_at" - t.datetime "last_succeeded_at" + t.datetime "last_error_at", precision: nil + t.datetime "last_succeeded_at", precision: nil t.string "status_message", default: "Pending" t.index ["user_id"], name: "index_bulkrax_importers_on_user_id" end @@ -124,8 +124,8 @@ t.bigint "importer_run_id", null: false t.string "parent_id", null: false t.string "child_id", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.integer "order", default: 0 t.index ["child_id"], name: "index_bulkrax_pending_relationships_on_child_id" t.index ["importer_run_id"], name: "index_bulkrax_pending_relationships_on_importer_run_id" @@ -141,8 +141,8 @@ t.string "statusable_type" t.integer "runnable_id" t.string "runnable_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.index ["error_class"], name: "index_bulkrax_statuses_on_error_class" t.index ["runnable_id", "runnable_type"], name: "bulkrax_statuses_runnable_idx" t.index ["statusable_id", "statusable_type"], name: "bulkrax_statuses_statusable_idx" diff --git a/hydra/app/blacklight/access_controls/search_builder_decorator.rb b/hydra/lib/blacklight/access_controls/search_builder_decorator.rb similarity index 100% rename from hydra/app/blacklight/access_controls/search_builder_decorator.rb rename to hydra/lib/blacklight/access_controls/search_builder_decorator.rb