Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Ensure we pass query to IIIF viewer #280

Closed
wants to merge 1 commit into from

Conversation

jeremyf
Copy link
Contributor

@jeremyf jeremyf commented Oct 9, 2023

In the later versions of Hyku, they override the Hyrax view of
app/views/catalog/_index_header_list_default.html.erb; so IIIF Print's
strategy of overriding that view does not work. (Because Hyku's view
path rightly takes higher precedence than any Gem).

Looking at the updated view, the URL is generated via a helper method.
So our approach to adding the parent_query or query parameter leverages
extending the helper method.

We still need the view override, as it reflects a prior state of
Hyku (and Hyrax) that some implementations will continue to use.

Below is a diff of the files in Hyku v5.0.1 and IIIF Print. I
have not resolved all of these things but am close:

diff of the files in Hyku v5.0.1 and IIIF Print
❯ diff hyrax-webapp/app/views/catalog/_index_header_list_default.html.erb ../iiif_print/app/views/catalog/_index_header_list_default.html.erb
1,2c1,2
< <%# OVERRIDE Hyrax 3.4.0 to support shared search %>
< <% model = document.hydra_model %>
---
> <%# OVERRIDE Hyrax 2.9.6 to show parent_query params if metadata is found in parent record %>
>
4,9c4,12
<     <% if model == Hyrax::PcdmCollection || model < Hyrax::PcdmCollection %>
<         <h4 class="search-result-title"><%= link_to document.title_or_label, generate_work_url(document, request) %></h4>
<         <%= Hyrax::CollectionPresenter.new(document, current_ability).collection_type_badge %>
<     <% else %>
<         <h4 class="search-result-title"><%= link_to document.title_or_label, generate_work_url(document, request) %></h4>
<     <% end %>
---
>   <h3 class="search-result-title">
>   <% if params['q'].present? && document.any_highlighting? %>
>     <%= link_to document.title_or_label, [document, { parent_query: params['q'] }] %></h3>
>   <% elsif params['q'].present? %>
>     <%= link_to document.title_or_label, [document, { query: params['q'] }] %></h3>
>   <% else %>
>     <%= link_to document.title_or_label, document %></h3>
>   <% end %>
>   </h3>

Co-authored-by: Kirk Wang [email protected]

allow(helper).to receive(:current_account) { account }
end

describe '#generate_work_url' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏿

@jeremyf jeremyf force-pushed the update-query-param-passing-for-newer-hyku branch from 1b4d50d to 91dc886 Compare November 27, 2023 17:53
In the later versions of Hyku, they override the Hyrax view of
`app/views/catalog/_index_header_list_default.html.erb`; so IIIF Print's
strategy of overriding that view does not work.  (Because Hyku's view
path rightly takes higher precedence than any Gem).

Looking at the updated view, the URL is generated via a helper method.
So our approach to adding the parent_query or query parameter leverages
extending the helper method.

We still need the view override, as it reflects a prior state of
Hyku (and Hyrax) that some implementations will continue to use.

Below is a *diff of the files in Hyku v5.0.1 and IIIF Print*.  I
have not resolved all of these things but am close:

<details>
<summary>diff of the files in Hyku v5.0.1 and IIIF Print</summary>

```
❯ diff hyrax-webapp/app/views/catalog/_index_header_list_default.html.erb ../iiif_print/app/views/catalog/_index_header_list_default.html.erb
1,2c1,2
< <%# OVERRIDE Hyrax 3.4.0 to support shared search %>
< <% model = document.hydra_model %>
---
> <%# OVERRIDE Hyrax 2.9.6 to show parent_query params if metadata is found in parent record %>
>
4,9c4,12
<     <% if model == Hyrax::PcdmCollection || model < Hyrax::PcdmCollection %>
<         <h4 class="search-result-title"><%= link_to document.title_or_label, generate_work_url(document, request) %></h4>
<         <%= Hyrax::CollectionPresenter.new(document, current_ability).collection_type_badge %>
<     <% else %>
<         <h4 class="search-result-title"><%= link_to document.title_or_label, generate_work_url(document, request) %></h4>
<     <% end %>
---
>   <h3 class="search-result-title">
>   <% if params['q'].present? && document.any_highlighting? %>
>     <%= link_to document.title_or_label, [document, { parent_query: params['q'] }] %></h3>
>   <% elsif params['q'].present? %>
>     <%= link_to document.title_or_label, [document, { query: params['q'] }] %></h3>
>   <% else %>
>     <%= link_to document.title_or_label, document %></h3>
>   <% end %>
>   </h3>
```

</details>

Co-authored-by: Kirk Wang <[email protected]>
@jeremyf jeremyf force-pushed the update-query-param-passing-for-newer-hyku branch from 91dc886 to 34d8d24 Compare January 19, 2024 18:10
@jeremyf jeremyf closed this Jan 23, 2024
@jeremyf jeremyf deleted the update-query-param-passing-for-newer-hyku branch January 23, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants