Module: Europeana::Blacklight::SearchHelper

Extended by:
ActiveSupport::Concern
Includes:
Blacklight::SearchHelper
Included in:
Catalog
Defined in:
app/controllers/concerns/europeana/blacklight/search_helper.rb

Overview

Local overrides for SearchHelper

Instance Method Summary collapse

Instance Method Details

#previous_and_next_document_params(index, window = 1) ⇒ Object

index arg counts from 0; API start param counts from 1



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/concerns/europeana/blacklight/search_helper.rb', line 10

def previous_and_next_document_params(index, window = 1)
  start = index + 1
  api_params = {}

  if start > 1
    api_params[:start] = start - window # get one before
    api_params[:rows] = 2 * window + 1 # and one after
  else
    api_params[:start] = start # there is no previous doc
    api_params[:rows] = 2 * window # but there should be one after
  end

  api_params
end