Commit 832b6989 by tady

ページング追加

parent 35a3b5a2
...@@ -129,7 +129,7 @@ gem 'draper', '~> 1.3' ...@@ -129,7 +129,7 @@ gem 'draper', '~> 1.3'
# ActiveRecord versioning # ActiveRecord versioning
gem 'paper_trail', '~> 3.0.0' gem 'paper_trail', '~> 3.0.0'
gem 'aws-sdk' gem 'aws-sdk', '1.39.0'
gem 'newrelic_rpm' gem 'newrelic_rpm'
...@@ -138,3 +138,5 @@ gem 'breadcrumble' ...@@ -138,3 +138,5 @@ gem 'breadcrumble'
gem 'slim' gem 'slim'
gem 'annotate', ">=2.6.0" gem 'annotate', ">=2.6.0"
gem 'kaminari', github: 'amatsuda/kaminari'
GIT GIT
remote: git://github.com/amatsuda/kaminari.git
revision: 754808dacaa84496faf8a79377d8076bdb3fd05c
specs:
kaminari (0.15.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
GIT
remote: git://github.com/popgiro/action-gmailer.git remote: git://github.com/popgiro/action-gmailer.git
revision: e04b69f578ead4514f6cea5ac85db16896f7e71c revision: e04b69f578ead4514f6cea5ac85db16896f7e71c
specs: specs:
...@@ -10,27 +18,27 @@ GIT ...@@ -10,27 +18,27 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actionmailer (4.1.0) actionmailer (4.1.0.rc2)
actionpack (= 4.1.0) actionpack (= 4.1.0.rc2)
actionview (= 4.1.0) actionview (= 4.1.0.rc2)
mail (~> 2.5.4) mail (~> 2.5.4)
actionpack (4.1.0) actionpack (4.1.0.rc2)
actionview (= 4.1.0) actionview (= 4.1.0.rc2)
activesupport (= 4.1.0) activesupport (= 4.1.0.rc2)
rack (~> 1.5.2) rack (~> 1.5.2)
rack-test (~> 0.6.2) rack-test (~> 0.6.2)
actionview (4.1.0) actionview (4.1.0.rc2)
activesupport (= 4.1.0) activesupport (= 4.1.0.rc2)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubis (~> 2.7.0)
activemodel (4.1.0) activemodel (4.1.0.rc2)
activesupport (= 4.1.0) activesupport (= 4.1.0.rc2)
builder (~> 3.1) builder (~> 3.1)
activerecord (4.1.0) activerecord (4.1.0.rc2)
activemodel (= 4.1.0) activemodel (= 4.1.0.rc2)
activesupport (= 4.1.0) activesupport (= 4.1.0.rc2)
arel (~> 5.0.0) arel (~> 5.0.0)
activesupport (4.1.0) activesupport (4.1.0.rc2)
i18n (~> 0.6, >= 0.6.9) i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
minitest (~> 5.1) minitest (~> 5.1)
...@@ -43,11 +51,10 @@ GEM ...@@ -43,11 +51,10 @@ GEM
activerecord (>= 2.3.0) activerecord (>= 2.3.0)
rake (>= 0.8.7) rake (>= 0.8.7)
arel (5.0.1.20140414130214) arel (5.0.1.20140414130214)
ast (1.1.0) ast (2.0.0)
aws-sdk (1.38.0) aws-sdk (1.39.0)
json (~> 1.4) json (~> 1.4)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bcrypt (3.1.7) bcrypt (3.1.7)
better_errors (1.1.0) better_errors (1.1.0)
coderay (>= 1.0.0) coderay (>= 1.0.0)
...@@ -57,7 +64,7 @@ GEM ...@@ -57,7 +64,7 @@ GEM
breadcrumble (4.0.0) breadcrumble (4.0.0)
rails (>= 4.0.0) rails (>= 4.0.0)
builder (3.2.2) builder (3.2.2)
capistrano (3.2.0) capistrano (3.2.1)
i18n i18n
rake (>= 10.0.0) rake (>= 10.0.0)
sshkit (~> 1.3) sshkit (~> 1.3)
...@@ -160,19 +167,18 @@ GEM ...@@ -160,19 +167,18 @@ GEM
i18n_generators (1.2.1) i18n_generators (1.2.1)
mechanize mechanize
rails (>= 3.0.0) rails (>= 3.0.0)
jbuilder (2.0.6) jbuilder (2.0.7)
activesupport (>= 3.0.0, < 5) activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2) multi_json (~> 1.2)
jquery-rails (3.1.0) jquery-rails (3.1.0)
railties (>= 3.0, < 5.0) railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
json (1.8.1) json (1.8.1)
jwt (0.1.11) jwt (0.1.12)
multi_json (>= 1.5)
launchy (2.4.2) launchy (2.4.2)
addressable (~> 2.3) addressable (~> 2.3)
libv8 (3.16.14.3) libv8 (3.16.14.3)
listen (2.7.1) listen (2.7.4)
celluloid (>= 0.15.2) celluloid (>= 0.15.2)
celluloid-io (>= 0.15.0) celluloid-io (>= 0.15.0)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
...@@ -194,16 +200,16 @@ GEM ...@@ -194,16 +200,16 @@ GEM
mime-types (1.25.1) mime-types (1.25.1)
mini_portile (0.5.3) mini_portile (0.5.3)
minitest (5.3.3) minitest (5.3.3)
multi_json (1.9.2) multi_json (1.10.0)
multi_xml (0.5.5) multi_xml (0.5.5)
multipart-post (2.0.0) multipart-post (2.0.0)
mysql2 (0.3.15) mysql2 (0.3.15)
net-http-digest_auth (1.4) net-http-digest_auth (1.4)
net-http-persistent (2.9.4) net-http-persistent (2.9.4)
net-scp (1.2.0) net-scp (1.2.1)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.8.0) net-ssh (2.9.0)
newrelic_rpm (3.7.3.204) newrelic_rpm (3.8.0.218)
nio4r (1.0.0) nio4r (1.0.0)
nokogiri (1.6.1) nokogiri (1.6.1)
mini_portile (~> 0.5.0) mini_portile (~> 0.5.0)
...@@ -218,7 +224,7 @@ GEM ...@@ -218,7 +224,7 @@ GEM
omniauth (1.2.1) omniauth (1.2.1)
hashie (>= 1.2, < 3) hashie (>= 1.2, < 3)
rack (~> 1.0) rack (~> 1.0)
omniauth-google-oauth2 (0.2.3) omniauth-google-oauth2 (0.2.4)
omniauth (~> 1.0) omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1) omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.1.2) omniauth-oauth2 (1.1.2)
...@@ -230,8 +236,8 @@ GEM ...@@ -230,8 +236,8 @@ GEM
paper_trail (3.0.1) paper_trail (3.0.1)
activerecord (>= 3.0, < 5.0) activerecord (>= 3.0, < 5.0)
activesupport (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.0)
parser (2.1.8) parser (2.1.9)
ast (~> 1.1) ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5) slop (~> 3.4, >= 3.4.5)
poltergeist (1.5.0) poltergeist (1.5.0)
capybara (~> 2.1) capybara (~> 2.1)
...@@ -250,29 +256,29 @@ GEM ...@@ -250,29 +256,29 @@ GEM
pry-rails (0.3.2) pry-rails (0.3.2)
pry (>= 0.9.10) pry (>= 0.9.10)
rack (1.5.2) rack (1.5.2)
rack-mini-profiler (0.9.0) rack-mini-profiler (0.9.1)
rack (>= 1.1.3) rack (>= 1.1.3)
rack-test (0.6.2) rack-test (0.6.2)
rack (>= 1.0) rack (>= 1.0)
rails (4.1.0) rails (4.1.0.rc2)
actionmailer (= 4.1.0) actionmailer (= 4.1.0.rc2)
actionpack (= 4.1.0) actionpack (= 4.1.0.rc2)
actionview (= 4.1.0) actionview (= 4.1.0.rc2)
activemodel (= 4.1.0) activemodel (= 4.1.0.rc2)
activerecord (= 4.1.0) activerecord (= 4.1.0.rc2)
activesupport (= 4.1.0) activesupport (= 4.1.0.rc2)
bundler (>= 1.3.0, < 2.0) bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0) railties (= 4.1.0.rc2)
sprockets-rails (~> 2.0) sprockets-rails (~> 2.0.0)
railties (4.1.0) railties (4.1.0.rc2)
actionpack (= 4.1.0) actionpack (= 4.1.0.rc2)
activesupport (= 4.1.0) activesupport (= 4.1.0.rc2)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (2.0.0) rainbow (2.0.0)
rake (10.3.1) rake (10.3.1)
rb-fsevent (0.9.4) rb-fsevent (0.9.4)
rb-inotify (0.9.3) rb-inotify (0.9.4)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rdoc (4.1.1) rdoc (4.1.1)
json (~> 1.4) json (~> 1.4)
...@@ -296,19 +302,18 @@ GEM ...@@ -296,19 +302,18 @@ GEM
rspec-core (~> 2.14.0) rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0) rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0) rspec-mocks (~> 2.14.0)
rubocop (0.20.1) rubocop (0.21.0)
json (>= 1.7.7, < 2) json (>= 1.7.7, < 2)
parser (~> 2.1.7) parser (~> 2.1.9)
powerpack (~> 0.0.6) powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0) rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4) ruby-progressbar (~> 1.4)
ruby-progressbar (1.4.2) ruby-progressbar (1.4.2)
sass (3.2.19) sass (3.3.7)
sass-rails (4.0.3) sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0) sass (>= 3.1.10)
sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0.0)
sprockets-rails (~> 2.0)
sdoc (0.4.0) sdoc (0.4.0)
json (~> 1.8) json (~> 1.8)
rdoc (~> 4.0, < 5.0) rdoc (~> 4.0, < 5.0)
...@@ -322,12 +327,12 @@ GEM ...@@ -322,12 +327,12 @@ GEM
temple (~> 0.6.6) temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1) tilt (>= 1.3.3, < 2.1)
slop (3.5.0) slop (3.5.0)
sprockets (2.11.0) sprockets (2.12.1)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.1.3) sprockets-rails (2.0.1)
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
sprockets (~> 2.8) sprockets (~> 2.8)
...@@ -366,12 +371,11 @@ GEM ...@@ -366,12 +371,11 @@ GEM
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.6) unf_ext (0.0.6)
uuidtools (2.1.4)
validates_email_format_of (1.5.3) validates_email_format_of (1.5.3)
warden (1.2.3) warden (1.2.3)
rack (>= 1.0) rack (>= 1.0)
webrobots (0.1.1) webrobots (0.1.1)
websocket-driver (0.3.2) websocket-driver (0.3.3)
xpath (2.0.0) xpath (2.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
...@@ -382,7 +386,7 @@ DEPENDENCIES ...@@ -382,7 +386,7 @@ DEPENDENCIES
action-gmailer! action-gmailer!
ancestry ancestry
annotate (>= 2.6.0) annotate (>= 2.6.0)
aws-sdk aws-sdk (= 1.39.0)
better_errors better_errors
binding_of_caller binding_of_caller
breadcrumble breadcrumble
...@@ -407,6 +411,7 @@ DEPENDENCIES ...@@ -407,6 +411,7 @@ DEPENDENCIES
i18n_generators i18n_generators
jbuilder jbuilder
jquery-rails jquery-rails
kaminari!
launchy launchy
mail mail
mysql2 mysql2
......
class FlowController < ApplicationController class FlowController < ApplicationController
def show def show
@posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).limit(20).decorate @posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).page(params[:page]).decorate
end end
end end
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
.list-group .list-group
- @posts.each do |_post| - @posts.each do |_post|
= render partial: 'posts/large_item', locals: { post: _post } = render partial: 'posts/large_item', locals: { post: _post }
= paginate(@posts)
.col-xs-4 .col-xs-4
/ .panel.panel-default / .panel.panel-default
......
/ Link to the "First" page
- available local variables
url : url to the first page
current_page : a page object for the currently displayed page
total_pages : total number of pages
per_page : number of items to fetch per page
remote : data-remote
li
== link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote
'
/ Non-link tag that stands for skipped pages...
- available local variables
current_page : a page object for the currently displayed page
total_pages : total number of pages
per_page : number of items to fetch per page
remote : data-remote
li
== link_to t('views.pagination.truncate').html_safe
'
/ Link to the "Last" page
- available local variables
url : url to the last page
current_page : a page object for the currently displayed page
total_pages : total number of pages
per_page : number of items to fetch per page
remote : data-remote
li
== link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote
'
/ Link to the "Next" page
- available local variables
url : url to the next page
current_page : a page object for the currently displayed page
total_pages : total number of pages
per_page : number of items to fetch per page
remote : data-remote
li
== link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote
'
/ Link showing page number
- available local variables
page : a page object for "this" page
url : url to this page
current_page : a page object for the currently displayed page
total_pages : total number of pages
per_page : number of items to fetch per page
remote : data-remote
li class="#{'active' if page.current?}"
== link_to page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
'
/ The container tag
- available local variables
current_page : a page object for the currently displayed page
total_pages : total number of pages
per_page : number of items to fetch per page
remote : data-remote
paginator : the paginator that renders the pagination tags inside
== paginator.render do
ul.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
== next_page_tag unless current_page.last?
/ == last_page_tag unless current_page.last?
/ Link to the "Previous" page
- available local variables
url : url to the previous page
current_page : a page object for the currently displayed page
total_pages : total number of pages
per_page : number of items to fetch per page
remote : data-remote
li
== link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote
'
Draper::CollectionDecorator.delegate :current_page, :total_pages, :limit_value, :total_count
Kaminari.configure do |config|
config.default_per_page = 30
# config.max_per_page = nil
config.window = 0
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
end
# Sample localization file for Kaminari. You can override these values in your app's locales file if you want.
en:
views:
pagination:
first: "&laquo; First"
last: "Last &raquo;"
previous: "&lsaquo; Prev"
next: "Next &rsaquo;"
truncate: "&hellip;"
helpers:
page_entries_info:
one_page:
display_entries:
zero: "No %{entry_name} found"
one: "Displaying <b>1</b> %{entry_name}"
other: "Displaying <b>all %{count}</b> %{entry_name}"
more_pages:
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"
ja:
views:
pagination:
first: "&laquo; First"
last: "Last &raquo;"
previous: "&lsaquo; Prev"
next: "Next &rsaquo;"
truncate: "&hellip;"
helpers:
page_entries_info:
one_page:
display_entries:
zero: "No %{entry_name} found"
one: "Displaying <b>1</b> %{entry_name}"
other: "Displaying <b>all %{count}</b> %{entry_name}"
more_pages:
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment