Skip to content

Commit

Permalink
Merge branch 'main' into blacklight_advanced_and_range
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Oct 1, 2023
2 parents 36590bc + 5458a49 commit 4bbb426
Show file tree
Hide file tree
Showing 30 changed files with 405 additions and 21 deletions.
25 changes: 25 additions & 0 deletions app/actors/hyrax/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

# OVERRIDE Hyrax 2.9 to add in import flag
module Hyrax
module Actors
class Environment
# @param [ActiveFedora::Base] curation_concern work to operate on
# @param [Ability] current_ability the authorizations of the acting user
# @param [ActionController::Parameters] attributes user provided form attributes
def initialize(curation_concern, current_ability, attributes, importing = false)
@curation_concern = curation_concern
@current_ability = current_ability
@attributes = attributes.to_h.with_indifferent_access
@importing = importing
end

attr_reader :curation_concern, :current_ability, :attributes, :importing

# @return [User] the user from the current_ability
def user
current_ability.current_user
end
end
end
end
14 changes: 14 additions & 0 deletions app/factories/bulkrax/object_factory_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# Add ability to mark environment as from bulk import
module Bulkrax
module ObjectFactoryDecorator
# @param [Hash] attrs the attributes to put in the environment
# @return [Hyrax::Actors::Environment]
def environment(attrs)
Hyrax::Actors::Environment.new(object, Ability.new(@user), attrs, true)
end
end
end

::Bulkrax::ObjectFactory.prepend(Bulkrax::ObjectFactoryDecorator)
4 changes: 4 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
# limit to 5 attempts
retry_on StandardError, wait: :exponentially_longer, attempts: 5 do |_job, _exception|
# Log error, do nothing, etc.
end
end
3 changes: 1 addition & 2 deletions app/jobs/reindex_collections_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
class ReindexCollectionsJob < ApplicationJob
def perform
Collection.find_each do |collection|
collection.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX)
collection.update_index
ReindexItemJob.perform_later(collection)
end
end
end
9 changes: 9 additions & 0 deletions app/jobs/reindex_file_sets_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class ReindexFileSetsJob < ApplicationJob
def perform
FileSet.find_each do |file_set|
ReindexItemJob.perform_later(file_set)
end
end
end
7 changes: 7 additions & 0 deletions app/jobs/reindex_item_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class ReindexItemJob < ApplicationJob
def perform(item)
item.update_index
end
end
6 changes: 4 additions & 2 deletions app/jobs/reindex_works_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

class ReindexWorksJob < ApplicationJob
def perform
Hyrax.config.registered_curation_concern_types.each do |work_type|
work_type.constantize.find_each(&:update_index)
Site.instance.available_works.each do |work_type|
work_type.constantize.find_each do |work|
ReindexItemJob.perform_later(work)
end
end
end
end
3 changes: 2 additions & 1 deletion app/middleware/account_elevator.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true

require 'apartment/elevators/generic'
# Apartment middleware for switching tenants based on the
# CNAME entry for an account.
class AccountElevator < Apartment::Elevators::Generic
include AccountSwitch
# @return [String] The tenant to switch to
def parse_tenant_name(request)
account = Account.from_request(request)

account || Account.new.reset! # reset everything if no account is present
account&.tenant
end
end
20 changes: 20 additions & 0 deletions app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<h2 class="text-center">Forgot your password?</h2>
<div class="row center-block">
<div class="col-md-6 col-md-offset-3">
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="form-group">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", class: "form-control" %>
</div>

<div class="form-group text-center">
<%= f.submit "Send me reset password instructions", class: 'btn btn-primary' %>
</div>
<% end %>
<div class="text-center">
<%= render "devise/shared/links" %>
</div>
</div>
</div>
26 changes: 26 additions & 0 deletions app/views/devise/registrations/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h2 class="text-center pt-40 pb-40"><%= t(".sign_up_header") %></h2>
<div class="row center-block">
<div class="col-md-8 col-md-offset-2">
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: 'form-horizontal' }) do |f| %>
<small>
<%= f.error_notification %>
</small>

<div class="form-inputs">
<%= f.input :display_name, required: true, wrapper: :inline %>
<%= f.input :email, required: true, autofocus: true, wrapper: :inline %>
<%= f.input :password, required: true, wrapper: :inline %>
<%= f.input :password_confirmation, required: true, wrapper: :inline %>
</div>

<div class="form-group text-center">
<%= render 'devise/shared/links' %>
</div>
<div class="text-center pb-40">
<%= f.button :submit, t(".sign_up") %>
</div>
</div>
<% end %>
</div>
</div>

31 changes: 31 additions & 0 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

<h2 class="text-center">Log in</h2>
<div class="row center-block">
<div class="col-md-6 col-md-offset-3">
<%= form_for(resource, as: resource_name, url: session_path(resource_name), class: "form-horizontal") do |f| %>
<div class="form-group">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, class: "form-control" %>
</div>

<div class="form-group">
<%= f.label :password, class: "control-label" %><br />
<%= f.password_field :password, autocomplete: "off", class: "form-control" %>
</div>

<% if devise_mapping.rememberable? -%>
<div class="form-group text-center">
<%= f.check_box :remember_me %>
<%= f.label :remember_me, class: "control-label" %>
</div>
<% end -%>

<div class="form-group text-center">
<%= f.submit "Log in", class: 'btn btn-primary' %>
</div>
<% end %>
<div class="text-center">
<%= render "devise/shared/links" %>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/devise/shared/_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% end -%>

<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to t(".forgot_your_password"), new_password_path(resource_name) %><br />
<%= link_to t(".forgot_your_password"), new_password_path(resource_name), class: 'lh-40' %><br />
<% end -%>

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
Expand Down
56 changes: 48 additions & 8 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,34 @@
Bundler.require(*groups)

module Hyku
# Providing a common method to ensure consistent UTF-8 encoding. Also removing the tricksy Byte
# Order Marker character which is an invisible 0 space character.
#
# @note In testing, we encountered errors with the file's character encoding
# (e.g. `Encoding::UndefinedConversionError`). The following will force the encoding to
# UTF-8 and replace any invalid or undefined characters from the original encoding with a
# "?".
#
# Given that we still have the original, and this is a derivative, the forced encoding
# should be acceptable.
#
# @param [String]
# @return [String]
#
# @see https://sentry.io/organizations/scientist-inc/issues/3773392603/?project=6745020&query=is%3Aunresolved&referrer=issue-stream
# @see https://github.com/samvera-labs/bulkrax/pull/689
# @see https://github.com/samvera-labs/bulkrax/issues/688
# @see https://github.com/scientist-softserv/adventist-dl/issues/179
def self.utf_8_encode(string)
string
.encode(Encoding.find('UTF-8'), invalid: :replace, undef: :replace, replace: "?")
.delete("\xEF\xBB\xBF")
end

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

# 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 All @@ -33,22 +60,33 @@ class Application < Rails::Application
end

config.to_prepare do
# Allows us to use decorator files in the app directory

# Add any extra services before IiifPrint::PluggableDerivativeService to enable processing
Hyrax::DerivativeService.services = [IiifPrint::PluggableDerivativeService]

# When you are ready to use the derivative rodeo instead of the pluggable uncomment the
# following and comment out the preceding Hyrax::DerivativeService.service
#
# Hyrax::DerivativeService.services = [
# Adventist::TextFileTextExtractionService,
# IiifPrint::DerivativeRodeoService,
# Hyrax::FileSetDerivativesService]

DerivativeRodeo::Generators::HocrGenerator.additional_tessearct_options = "-l eng_best"

# Allows us to use decorator files
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

config.to_prepare do
# Allows us to use decorator files in the app directory
Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

# OAI additions
Dir.glob(File.join(File.dirname(__FILE__), "../lib/oai/**/*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
# OAI additions
Dir.glob(File.join(File.dirname(__FILE__), "../lib/oai/**/*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

# resolve reloading issue in dev mode
Expand All @@ -67,6 +105,8 @@ class Application < Rails::Application
Object.include(AccountSwitch)
end

# copies tinymce assets directly into public/assets
config.tinymce.install = :copy
##
# Psych Allow YAML Classes
#
Expand Down
1 change: 1 addition & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

login: &login
adapter: <%= ENV['DB_ADAPTER'] || 'postgresql' %>
schema_search_path: "public,shared_extensions"
host: <%= ENV['DB_HOST'] %>
username: <%= ENV['DB_USER'] %>
password: <%= ENV['DB_PASSWORD'] %>
Expand Down
1 change: 1 addition & 0 deletions config/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ production:
password: fedoraAdmin
url: http://<%= ENV['FCREPO_HOST'] || 'localhost' %>:<%= ENV['FCREPO_PORT'] || 8080 %>/<%= ENV['FCREPO_REST_PATH'] || 'rest' %>
base_path: <%= ENV['FCREPO_BASE_PATH'] || '/prod' %>
request: { timeout: 600, open_timeout: 60}
11 changes: 11 additions & 0 deletions config/initializers/active_fedora_override.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Based on https://github.com/samvera/hyrax/issues/4581#issuecomment-843085122

# Monkey-patch to short circuit ActiveModel::Dirty which attempts to load the whole master files ordered list when calling nodes_will_change!
# This leads to a stack level too deep exception when attempting to delete a master file from a media object on the manage files step.
# See https://github.com/samvera/active_fedora/pull/1312/commits/7c8bbbefdacefd655a2ca653f5950c991e1dc999#diff-28356c4daa0d55cbaf97e4269869f510R100-R103
ActiveFedora::Aggregation::ListSource.class_eval do
def attribute_will_change!(attr)
return super unless attr == 'nodes'
attributes_changed_by_setter[:nodes] = true
end
end
2 changes: 2 additions & 0 deletions config/initializers/apartment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
# Any schemas added here will be available along with your selected Tenant.
#
# config.persistent_schemas = %w{ hstore }
config.persistent_schemas = ['shared_extensions']


# <== PostgreSQL only options
#
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ de:
accept_until: Diese Einladung wird in %{due_date} fällig.
hello: Hallo %{email}
ignore: |-
Wenn Sie die Einladung nicht akzeptieren möchten, ignorieren Sie bitte diese E-Mail. <br />
Wenn Sie die Einladung nicht akzeptieren möchten, ignorieren Sie bitte diese E-Mail.
Ihr Konto wird erst dann erstellt, wenn Sie auf den obigen Link zugreifen und Ihr Passwort festlegen.
someone_invited_you: Jemand hat Sie zu %{url} eingeladen, können Sie es über den Link unten akzeptieren.
subject: Einladungshinweise
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ en:
accept_until: This invitation will be due in %{due_date}.
hello: Hello %{email}
ignore: |-
If you don't want to accept the invitation, please ignore this email.<br />
If you don't want to accept the invitation, please ignore this email.
Your account won't be created until you access the link above and set your password.
someone_invited_you: Someone has invited you to %{url}, you can accept it through the link below.
subject: Invitation instructions
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ es:
accept_until: Esta invitación será %{due_date}.
hello: Hola %{email}
ignore: |-
Si no desea aceptar la invitación, ignore este correo electrónico.<br />
Si no desea aceptar la invitación, ignore este correo electrónico.
Su cuenta no se creará hasta que acceda al enlace anterior y establezca su contraseña.
someone_invited_you: Alguien te ha invitado a %{url}, puedes aceptarlo a través del siguiente enlace.
subject: Instrucciones de invitación
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fr:
accept_until: Cette invitation sera due en %{due_date}.
hello: Bonjour %{email}
ignore: |-
Si vous ne souhaitez pas accepter l'invitation, ignorez ce courriel. <br />
Si vous ne souhaitez pas accepter l'invitation, ignorez ce courriel.
Votre compte ne sera créé que lorsque vous accédez au lien ci-dessus et définissez votre mot de passe.
someone_invited_you: Quelqu'un vous a invité %{url}, vous pouvez l'accepter par le lien ci-dessous.
subject: Instructions d'invitation
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ it:
accept_until: Questo invito sarà dovuto in %{due_date}.
hello: Ciao %{email}
ignore: |-
Se non desideri accettare l'invito, ignora questa email. <br />
Se non desideri accettare l'invito, ignora questa email.
Il tuo account non verrà creato finché non accedi al link precedente e imposta la tua password.
someone_invited_you: Qualcuno ti ha invitato a %{url}, puoi accettarlo tramite il link qui sotto.
subject: Istruzioni di invito
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pt-BR:
accept_until: Este convite será devido em %{due_date}.
hello: Olá %{email}
ignore: |-
Se você não deseja aceitar o convite, ignore este e-mail. <br />
Se você não deseja aceitar o convite, ignore este e-mail.
Sua conta não será criada até você acessar o link acima e definir sua senha.
someone_invited_you: Alguém convidou você para %{url}, você pode aceitá-lo através do link abaixo.
subject: Instruções de convite
Expand Down
2 changes: 1 addition & 1 deletion config/locales/devise_invitable.zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ zh:
accept_until: 此邀请将到期 %{due_date}.
hello: 你好 %{email}
ignore: |-
如果您不想接受邀请,请忽略此电子邮件。<br />
如果您不想接受邀请,请忽略此电子邮件。
在您访问以上链接并设置密码之前,您的帐户将不会被创建。
someone_invited_you: 有人邀请你到 %{url},您可以通过以下链接接受。
subject: 邀请说明
Expand Down
Loading

0 comments on commit 4bbb426

Please sign in to comment.