Install Kaminari
This commit is contained in:
parent
153cbf1be5
commit
451370df8a
12 changed files with 116 additions and 1 deletions
4
Gemfile
4
Gemfile
|
@ -107,6 +107,10 @@ gem 'sidekiq', '~> 5.2'
|
|||
# Helpers for the reCAPTCHA API.
|
||||
gem 'recaptcha', '~> 4.13'
|
||||
|
||||
# Kaminari is a Scope & Engine based, clean, powerful, agnostic, customizable
|
||||
# and sophisticated paginator for Rails 4+.
|
||||
gem 'kaminari', '~> 1.1'
|
||||
|
||||
group :development, :test do
|
||||
# factory_bot provides a framework and DSL for defining and using factories.
|
||||
gem 'factory_bot_rails', '~> 4.10'
|
||||
|
|
15
Gemfile.lock
15
Gemfile.lock
|
@ -184,6 +184,18 @@ GEM
|
|||
thor (>= 0.14, < 2.0)
|
||||
json (2.2.0)
|
||||
jwt (2.2.1)
|
||||
kaminari (1.1.1)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.1.1)
|
||||
kaminari-activerecord (= 1.1.1)
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-actionview (1.1.1)
|
||||
actionview
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-activerecord (1.1.1)
|
||||
activerecord
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-core (1.1.1)
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
letter_opener (1.7.0)
|
||||
|
@ -450,6 +462,7 @@ DEPENDENCIES
|
|||
font-awesome-sass (~> 5.5.0)
|
||||
interactor (~> 3.1)
|
||||
jquery-rails (~> 4.3)
|
||||
kaminari (~> 1.1)
|
||||
letter_opener (~> 1.6)
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
omniauth (~> 1.9)
|
||||
|
@ -489,4 +502,4 @@ RUBY VERSION
|
|||
ruby 2.6.2p47
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.1
|
||||
2.0.2
|
||||
|
|
7
app/views/kaminari/_first_page.html.erb
Normal file
7
app/views/kaminari/_first_page.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<li class="page-item">
|
||||
<%= link_to_unless current_page.first?,
|
||||
raw(translate('pagination.first')),
|
||||
url,
|
||||
remote: remote,
|
||||
class: 'page-link' %>
|
||||
</li>
|
5
app/views/kaminari/_gap.html.erb
Normal file
5
app/views/kaminari/_gap.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<li class='page-item disabled'>
|
||||
<%= link_to raw(translate('pagination.truncate')),
|
||||
'#',
|
||||
class: 'page-link' %>
|
||||
</li>
|
7
app/views/kaminari/_last_page.html.erb
Normal file
7
app/views/kaminari/_last_page.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<li class="page-item">
|
||||
<%= link_to_unless current_page.last?,
|
||||
raw(translate('pagination.last')),
|
||||
url,
|
||||
remote: remote,
|
||||
class: 'page-link' %>
|
||||
</li>
|
8
app/views/kaminari/_next_page.html.erb
Normal file
8
app/views/kaminari/_next_page.html.erb
Normal file
|
@ -0,0 +1,8 @@
|
|||
<li class="page-item">
|
||||
<%= link_to_unless current_page.last?,
|
||||
raw(translate('pagination.next')),
|
||||
url,
|
||||
rel: 'next',
|
||||
remote: remote,
|
||||
class: 'page-link' %>
|
||||
</li>
|
17
app/views/kaminari/_page.html.erb
Normal file
17
app/views/kaminari/_page.html.erb
Normal file
|
@ -0,0 +1,17 @@
|
|||
<% if page.current? %>
|
||||
<li class="page-item active">
|
||||
<%= content_tag :a,
|
||||
page,
|
||||
data: { remote: remote },
|
||||
rel: page.rel,
|
||||
class: 'page-link' %>
|
||||
</li>
|
||||
<% else %>
|
||||
<li class="page-item">
|
||||
<%= link_to page,
|
||||
url,
|
||||
remote: remote,
|
||||
rel: page.rel,
|
||||
class: 'page-link' %>
|
||||
</li>
|
||||
<% end %>
|
19
app/views/kaminari/_paginator.html.erb
Normal file
19
app/views/kaminari/_paginator.html.erb
Normal file
|
@ -0,0 +1,19 @@
|
|||
<%= paginator.render do %>
|
||||
<nav class="d-flex justify-content-center">
|
||||
<ul class="pagination">
|
||||
<%= first_page_tag unless current_page.first? %>
|
||||
<%= prev_page_tag unless current_page.first? %>
|
||||
|
||||
<% each_page do |page| %>
|
||||
<% if page.left_outer? || page.right_outer? || page.inside_window? %>
|
||||
<%= page_tag page %>
|
||||
<% elsif !page.was_truncated? -%>
|
||||
<%= gap_tag %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= next_page_tag unless current_page.last? %>
|
||||
<%= last_page_tag unless current_page.last? %>
|
||||
</ul>
|
||||
</nav>
|
||||
<% end %>
|
8
app/views/kaminari/_prev_page.html.erb
Normal file
8
app/views/kaminari/_prev_page.html.erb
Normal file
|
@ -0,0 +1,8 @@
|
|||
<li class="page-item">
|
||||
<%= link_to_unless current_page.first?,
|
||||
raw(translate('pagination.previous')),
|
||||
url,
|
||||
rel: 'prev',
|
||||
remote: remote,
|
||||
class: 'page-link' %>
|
||||
</li>
|
13
config/initializers/kaminari_config.rb
Normal file
13
config/initializers/kaminari_config.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Kaminari.configure do |config|
|
||||
config.default_per_page = 10
|
||||
# config.max_per_page = nil
|
||||
# config.window = 4
|
||||
# config.outer_window = 0
|
||||
# config.left = 0
|
||||
# config.right = 0
|
||||
# config.page_method_name = :page
|
||||
# config.param_name = :page
|
||||
# config.params_on_first_page = false
|
||||
end
|
7
config/locales/pagination/en.yml
Normal file
7
config/locales/pagination/en.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
en:
|
||||
pagination:
|
||||
first: '« First'
|
||||
last: 'Last »'
|
||||
previous: '‹ Prev'
|
||||
next: 'Next ›'
|
||||
truncate: '…'
|
7
config/locales/pagination/ru.yml
Normal file
7
config/locales/pagination/ru.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
ru:
|
||||
pagination:
|
||||
first: '« Первая'
|
||||
last: 'Последняя »'
|
||||
previous: '‹ Пред.'
|
||||
next: 'След. ›'
|
||||
truncate: '…'
|
Reference in a new issue