Skip to content

Commit

Permalink
Merge pull request #2149 from samvera/i35-valkyrize-hyku-routes-and-r…
Browse files Browse the repository at this point in the history
…edirects

I35 valkyrize hyku routes and redirects
  • Loading branch information
Kirk Wang authored Jan 16, 2024
2 parents f6cd241 + 126b312 commit f0145c9
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 14 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ TB_RSPEC_OPTIONS="--format RspecJunitFormatter --out rspec.xml"
# Comment out these 5 for single tenancy / Uncomment for multi
HYKU_ADMIN_HOST=hyku.test
HYKU_ADMIN_ONLY_TENANT_CREATION=false
HYKU_BLOCK_VALKYRIE_REDIRECT=false
HYKU_DEFAULT_HOST=%{tenant}.hyku.test
HYKU_ROOT_HOST=hyku.test
HYKU_MULTITENANT=true
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/hyrax/generic_work_resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ class GenericWorkResourcesController < ApplicationController
# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::GenericWorkResourcePresenter
end
end
3 changes: 3 additions & 0 deletions app/controllers/hyrax/image_resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ class ImageResourcesController < ApplicationController
# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::ImageResourcePresenter
end
end
7 changes: 7 additions & 0 deletions app/helpers/hyku_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ def admin_only_tenant_creation?
ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYKU_ADMIN_ONLY_TENANT_CREATION', false))
end

# We don't want to use Turbolinks because it blocks the
# redirects from AF works to Valkyrie works in the edit and show
# TODO: When there are no more AF works, we can remove this and remove the ENV variable
def block_valkyrie_redirect?
ActiveModel::Type::Boolean.new.cast(ENV.fetch('HYKU_BLOCK_VALKYRIE_REDIRECT', true))
end

def parent_path(parent_doc)
model = parent_doc['has_model_ssim'].first
path = "hyrax_#{model.underscore}_path"
Expand Down
6 changes: 6 additions & 0 deletions app/presenters/hyrax/generic_work_resource_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module Hyrax
class GenericWorkResourcePresenter < Hyku::WorkShowPresenter
end
end
6 changes: 6 additions & 0 deletions app/presenters/hyrax/image_resource_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module Hyrax
class ImageResourcePresenter < Hyku::WorkShowPresenter
end
end
4 changes: 2 additions & 2 deletions app/views/hyrax/base/_show_actions.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%# OVERRIDE Hyrax v5.0.0rc2 Adjust permission checks for delete %>
<%# OVERRIDE Hyrax v5.0.0rc2 Adjust permission checks for delete and add analytics button and add ENV to control turbolinks %>
<div class="row show-actions button-row-top-two-column">
<div class="col-sm-6">
<% if !workflow_restriction?(presenter) %>
Expand Down Expand Up @@ -27,7 +27,7 @@
<div class="col-sm-6 text-right">
<% if presenter.editor? && !workflow_restriction?(presenter) %>
<%= link_to t('.edit'), edit_polymorphic_path([main_app, presenter]), class: 'btn btn-secondary' %>
<%= link_to t('.edit'), edit_polymorphic_path([main_app, presenter]), class: 'btn btn-secondary', data: { turbolinks: block_valkyrie_redirect? } %>
<% if presenter.member_count > 1 %>
<%= link_to t("hyrax.file_manager.link_text"), polymorphic_path([main_app, :file_manager, presenter]), class: 'btn btn-secondary' %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%# OVERRIDE Hyrax v5.0.0rc2 Restrict who can remove works from collections %>
<%# OVERRIDE Hyrax v5.0.0rc2 Restrict who can remove works from collections and add ENV to control turbolinks %>
<% id = document.id %>
<tr id="document_<%= id %>">
<td>&nbsp;
Expand All @@ -15,7 +15,7 @@
<% end %>
<div class="media-body">
<p class="media-heading">
<strong><%= link_to document.title_or_label, [main_app, document], id: "src_copy_link#{id}", class: "#{'document-title' if document.title_or_label == document.label}" %></strong>
<strong><%= link_to document.title_or_label, [main_app, document], id: "src_copy_link#{id}", class: "#{'document-title' if document.title_or_label == document.label}", data: { turbolinks: block_valkyrie_redirect? } %></strong>
<a href="#" class="small" title="Click for more details"><i id="expand_<%= id %>" class="fa fa-chevron-right"></i></a>
</p>
<%= render_other_collection_links(document, @presenter.id) %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/hyrax/dashboard/works/_list_works.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%# OVERRIDE Hyrax v5.0.0rc2 to add appropriate alt tag %>
<%# OVERRIDE Hyrax v5.0.0rc2 to add appropriate alt tag and add ENV to control turbolinks %>

<tr id="document_<%= document.id %>">
<td>
Expand All @@ -7,7 +7,7 @@
</td>
<td>
<div class='media'>
<%= link_to [main_app, document], class: 'mr-2' do %>
<%= link_to [main_app, document], class: 'mr-2', data: { turbolinks: block_valkyrie_redirect? } do %>
<%# OVERRIDE begin %>
<%= document_presenter(document)&.thumbnail&.thumbnail_tag(
{ class: 'd-none d-md-block file_listing_thumbnail', alt: block_for(name: 'default_work_image_text') || "#{document.title_or_label} #{t('hyrax.homepage.admin_sets.thumbnail')}" },
Expand All @@ -19,7 +19,7 @@
<div class='media-body'>
<div class='media-heading'>

<%= link_to [main_app, document], id: "src_copy_link#{document.id}", class: 'document-title' do %>
<%= link_to [main_app, document], id: "src_copy_link#{document.id}", class: 'document-title', data: { turbolinks: block_valkyrie_redirect? } do %>
<span class="sr-only">
<%= t("hyrax.dashboard.my.sr.show_label") %>
</span>
Expand Down
4 changes: 2 additions & 2 deletions app/views/hyrax/homepage/_featured_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<%# OVERRIDE Hyrax v5.0.0rc2 to remove the hardcorded image width %>
<%# OVERRIDE Hyrax v5.0.0rc2 to remove the hardcorded image width and add ENV to control turbolinks %>
<div>
<div class="featured-item-title">
<span class="sr-only"><%= t('hyrax.homepage.featured_works.document.title_label') %></span>
<h3>
<%= link_to [main_app, featured] do %>
<%= link_to [main_app, featured], data: { turbolinks: block_valkyrie_redirect? } do %>
<%# OVERRIDE begin %>
<%= render_thumbnail_tag(featured, {alt: "#{featured.title.first.to_s} #{ t('hyrax.homepage.admin_sets.thumbnail')}" }, {suppress_link: true}) + featured.title.first %>
<%# OVERRIDE end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/hyrax/homepage/_recent_document.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<%# OVERRIDE Hyrax 3.4.1 to allow links to support shared search %>
<%# OVERRIDE Hyrax 3.4.1 to allow links to support shared search and add ENV to control turbolinks %>
<li class="recent-item">
<div class="row">
<div class="col-sm-12">
<span class="sr-only"><%= t('hyrax.homepage.recently_uploaded.document.title_label') %></span>
<h3>
<%= render_thumbnail_tag recent_document, {}, {suppress_link: true} %>
<%= link_to recent_document.title_or_label, generate_work_url(recent_document.to_h, request) %>
<%= link_to recent_document.title_or_label, generate_work_url(recent_document.to_h, request), data: { turbolinks: block_valkyrie_redirect? } %>
</h3>
<p class="recent-field">
<span class="recent-label"><%= t('hyrax.homepage.recently_uploaded.document.depositor_label') %>:</span> <%= link_to_profile recent_document.depositor(t('hyrax.homepage.recently_uploaded.document.depositor_missing')) %>
Expand Down
8 changes: 5 additions & 3 deletions app/views/hyrax/my/works/_list_works.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%# OVERRIDE Hyrax v5.0.0rc2 to add appropriate alt tag %>
<%# OVERRIDE Hyrax v5.0.0rc2 to add appropriate alt tag and add ENV to control turbolinks%>

<tr id="document_<%= document.id %>">

Expand All @@ -10,13 +10,15 @@
<td>
<div class='media'>
<%# OVERRIDE begin %>
<%= link_to [main_app, document], class: 'mr-2' do %>
<%= link_to [main_app, document], class: 'mr-2', data: { turbolinks: block_valkyrie_redirect? } do %>
<%= render_thumbnail_tag document, { class: 'd-none d-md-block file_listing_thumbnail', alt: block_for(name: 'default_work_image_text') || "#{document.title_or_label} #{t('hyrax.homepage.admin_sets.thumbnail')}" }, { suppress_link: true } %>
<% end %>
<%# OVERRIDE end %>

<div class='media-body'>
<%= link_to [main_app, document], id: "src_copy_link#{document.id}", class: 'document-title' do %>
<%# OVERRIDE begin %>
<%= link_to [main_app, document], id: "src_copy_link#{document.id}", class: 'document-title', data: { turbolinks: block_valkyrie_redirect? } do %>
<%# OVERRIDE end %>
<span class="sr-only">
<%= t("hyrax.dashboard.my.sr.show_label") %>
</span>
Expand Down
9 changes: 9 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
require 'sidekiq/web' if ENV.fetch('HYRAX_ACTIVE_JOB_QUEUE', 'sidekiq') == 'sidekiq'

Rails.application.routes.draw do # rubocop:disable Metrics/BlockLength
Hyrax.config.curation_concerns.each do |resource|
next if resource.to_s.match?(/.+Resource\z/)

resource = resource.to_s.underscore

get "/concern/#{resource}s/:id/edit", to: redirect("/concern/#{resource}_resources/%{id}/edit")
get "/concern/#{resource}s/:id", to: redirect("/concern/#{resource}_resources/%{id}")
end

resources :identity_providers
concern :range_searchable, BlacklightRangeLimit::Routes::RangeSearchable.new
concern :iiif_search, BlacklightIiifSearch::Routes.new
Expand Down
2 changes: 2 additions & 0 deletions ops/demo-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ extraEnvVars: &envVars
value: hyku-demo.$BASE_URL
- name: HYKU_ADMIN_ONLY_TENANT_CREATION
value: "true"
- name: HYKU_BLOCK_VALKYRIE_REDIRECT
value: "false"
- name: HYKU_ALLOW_#
value: "false"
- name: HYKU_DEFAULT_HOST
Expand Down
2 changes: 2 additions & 0 deletions ops/iiif-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ extraEnvVars: &envVars
value: hyku-iiif.$BASE_URL
- name: HYKU_ADMIN_ONLY_TENANT_CREATION
value: "true"
- name: HYKU_BLOCK_VALKYRIE_REDIRECT
value: "false"
- name: HYKU_ALLOW_#
value: "false"
- name: HYKU_DEFAULT_HOST
Expand Down
2 changes: 2 additions & 0 deletions ops/iiif.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ extraEnvVars: &envVars
value: hyku-iiif.$BASE_URL
- name: HYKU_ADMIN_ONLY_TENANT_CREATION
value: "true"
- name: HYKU_BLOCK_VALKYRIE_REDIRECT
value: "false"
- name: HYKU_ALLOW_#
value: "false"
- name: HYKU_DEFAULT_HOST
Expand Down
2 changes: 2 additions & 0 deletions ops/review-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ extraEnvVars: &envVars
value: hyku-$CI_MERGE_REQUEST_ID.example.com
- name: HYKU_ADMIN_ONLY_TENANT_CREATION
value: "true"
- name: HYKU_BLOCK_VALKYRIE_REDIRECT
value: "false"
- name: HYKU_CONTACT_EMAIL
value: samvera@example.com
- name: HYKU_DEFAULT_HOST
Expand Down
2 changes: 2 additions & 0 deletions ops/staging-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ extraEnvVars: &envVars
value: hyku-staging.$BASE_URL
- name: HYKU_ADMIN_ONLY_TENANT_CREATION
value: "true"
- name: HYKU_BLOCK_VALKYRIE_REDIRECT
value: "false"
- name: HYKU_ALLOW_#
value: "false"
- name: HYKU_DEFAULT_HOST
Expand Down

0 comments on commit f0145c9

Please # to comment.