Skip to content

Commit

Permalink
Refactor SearchContextComponent to include some more extension points…
Browse files Browse the repository at this point in the history
… for downstream implementations
  • Loading branch information
cbeer committed Jul 7, 2022
1 parent b511402 commit b36372a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/components/blacklight/search_context_component.html.erb
@@ -1,10 +1,10 @@
<div class='pagination-search-widgets'>

<div class="page-links">
<%= link_to_previous_document @search_context[:prev] %> |
<%= link_to_previous_document %> |

<%= item_page_entry_info %> |

<%= link_to_next_document @search_context[:next] %>
<%= link_to_next_document %>
</div>
</div>
8 changes: 4 additions & 4 deletions app/components/blacklight/search_context_component.rb
Expand Up @@ -19,15 +19,15 @@ def item_page_entry_info
end
end

def link_to_previous_document(*args)
def link_to_previous_document(document = nil, *args, **kwargs)
Deprecation.silence(Blacklight::UrlHelperBehavior) do
helpers.link_to_previous_document(*args)
helpers.link_to_previous_document(document || @search_context[:prev], *args, **kwargs)
end
end

def link_to_next_document(*args)
def link_to_next_document(document = nil, *args, **kwargs)
Deprecation.silence(Blacklight::UrlHelperBehavior) do
helpers.link_to_next_document(*args)
helpers.link_to_next_document(document || @search_context[:next], *args, **kwargs)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/blacklight/url_helper_behavior.rb
Expand Up @@ -52,8 +52,8 @@ def document_link_params(doc, opts)
##
# Link to the previous document in the current search context
# @deprecated
def link_to_previous_document(previous_document)
link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(class: "previous", rel: 'prev')
def link_to_previous_document(previous_document, classes: 'previous', **addl_link_opts)
link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(class: classes, rel: 'prev').merge(addl_link_opts)
link_to_unless previous_document.nil?, raw(t('views.pagination.previous')), url_for_document(previous_document), link_opts do
tag.span raw(t('views.pagination.previous')), class: 'previous'
end
Expand All @@ -63,8 +63,8 @@ def link_to_previous_document(previous_document)
##
# Link to the next document in the current search context
# @deprecated
def link_to_next_document(next_document)
link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(class: "next", rel: 'next')
def link_to_next_document(next_document, classes: 'next', **addl_link_opts)
link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(class: classes, rel: 'next').merge(addl_link_opts)
link_to_unless next_document.nil?, raw(t('views.pagination.next')), url_for_document(next_document), link_opts do
tag.span raw(t('views.pagination.next')), class: 'next'
end
Expand Down

0 comments on commit b36372a

Please sign in to comment.