diff --git a/app/assets/stylesheets/partials/_pagination.scss b/app/assets/stylesheets/partials/_pagination.scss index 15c5f769..488d8bce 100644 --- a/app/assets/stylesheets/partials/_pagination.scss +++ b/app/assets/stylesheets/partials/_pagination.scss @@ -1,15 +1,19 @@ .pagination-container { + clear: both; + display: flex; + flex-flow: row nowrap; + justify-content: center; margin-top: 3em; .previous { - text-align: left; - } - - .current { - text-align: center; + border-right: 1px solid black; + margin-right: 0.5em; + padding-right: 0.5em; } .next { - text-align: right; + border-left: 1px solid black; + margin-left: 0.5em; + padding-left: 0.5em; } } diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb index a7e2dbd8..05870196 100644 --- a/app/helpers/pagination_helper.rb +++ b/app/helpers/pagination_helper.rb @@ -1,15 +1,15 @@ module PaginationHelper def next_url(query_params) query_params[:page] = @pagination[:next] - link_to results_path(query_params), class: 'btn button-primary' do - "Next page #{content_tag(:span, '', class: 'fa fa-chevron-right')}".html_safe + link_to results_path(query_params), 'aria-label': 'Next page' do + 'Next »'.html_safe end end def prev_url(query_params) query_params[:page] = @pagination[:prev] - link_to results_path(query_params), class: 'btn button-primary' do - "#{content_tag(:span, '', class: 'fa fa-chevron-left')} Previous page".html_safe + link_to results_path(query_params), 'aria-label': 'Previous page' do + '« Previous'.html_safe end end end diff --git a/app/models/analyzer.rb b/app/models/analyzer.rb index 25f502a1..2e043df5 100644 --- a/app/models/analyzer.rb +++ b/app/models/analyzer.rb @@ -6,7 +6,8 @@ class Analyzer def initialize(enhanced_query, response) @pagination = {} @pagination[:hits] = hits(response) - @pagination[:page] = enhanced_query[:page] + @pagination[:start] = ((enhanced_query[:page] - 1) * RESULTS_PER_PAGE) + 1 + @pagination[:end] = [enhanced_query[:page] * RESULTS_PER_PAGE, hits(response)].min @pagination[:prev] = enhanced_query[:page] - 1 if enhanced_query[:page] > 1 @pagination[:next] = next_page(enhanced_query[:page], @pagination[:hits]) end diff --git a/app/views/search/_pagination.html.erb b/app/views/search/_pagination.html.erb index 3dd33d54..ddf13ead 100644 --- a/app/views/search/_pagination.html.erb +++ b/app/views/search/_pagination.html.erb @@ -1,19 +1,19 @@ <% return if @pagination.nil? %> -