[Groonga-commit] ranguba/ranguba-server at 518161d [master] Support pagination

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Feb 22 00:21:25 JST 2017


Kouhei Sutou	2017-02-22 00:21:25 +0900 (Wed, 22 Feb 2017)

  New Revision: 518161d4713df3a30f49bc6ca0a2aa0e8df6b691
  https://github.com/ranguba/ranguba-server/commit/518161d4713df3a30f49bc6ca0a2aa0e8df6b691

  Message:
    Support pagination

  Added files:
    app/views/kaminari/_first_page.html.erb
    app/views/kaminari/_last_page.html.erb
    app/views/kaminari/_next_page.html.erb
    app/views/kaminari/_page.html.erb
    app/views/kaminari/_paginator.html.erb
    app/views/kaminari/_prev_page.html.erb
  Modified files:
    Gemfile
    Gemfile.lock
    app/controllers/entries_controller.rb
    app/views/entries/index.html.erb

  Modified: Gemfile (+1 -0)
===================================================================
--- Gemfile    2017-02-22 00:09:09 +0900 (54d93ae)
+++ Gemfile    2017-02-22 00:21:25 +0900 (451a337)
@@ -54,6 +54,7 @@ gem 'groonga-client-model'
 gem 'chupa-text', path: '../chupa-text'
 gem 'chupa-text-decomposer-html', path: '../chupa-text-decomposer-html'
 gem 'chupa-text-decomposer-mail', path: '../chupa-text-decomposer-mail'
+gem 'kaminari'
 
 gem 'bootstrap'
 source 'https://rails-assets.org' do

  Modified: Gemfile.lock (+13 -0)
===================================================================
--- Gemfile.lock    2017-02-22 00:09:09 +0900 (fd73ded)
+++ Gemfile.lock    2017-02-22 00:21:25 +0900 (99cc03a)
@@ -120,6 +120,18 @@ GEM
       thor (>= 0.14, < 2.0)
     json (2.0.3)
     json-stream (0.2.1)
+    kaminari (1.0.1)
+      activesupport (>= 4.1.0)
+      kaminari-actionview (= 1.0.1)
+      kaminari-activerecord (= 1.0.1)
+      kaminari-core (= 1.0.1)
+    kaminari-actionview (1.0.1)
+      actionview
+      kaminari-core (= 1.0.1)
+    kaminari-activerecord (1.0.1)
+      activerecord
+      kaminari-core (= 1.0.1)
+    kaminari-core (1.0.1)
     listen (3.0.8)
       rb-fsevent (~> 0.9, >= 0.9.4)
       rb-inotify (~> 0.9, >= 0.9.7)
@@ -244,6 +256,7 @@ DEPENDENCIES
   groonga-client-model
   jbuilder (~> 2.5)
   jquery-rails
+  kaminari
   listen (~> 3.0.5)
   puma (~> 3.0)
   rails (~> 5.0.1)

  Modified: app/controllers/entries_controller.rb (+2 -1)
===================================================================
--- app/controllers/entries_controller.rb    2017-02-22 00:09:09 +0900 (d3e00db)
+++ app/controllers/entries_controller.rb    2017-02-22 00:21:25 +0900 (e4f0bab)
@@ -4,7 +4,8 @@ class EntriesController < ApplicationController
   # GET /entries
   # GET /entries.json
   def index
-    @entries = Entry.all
+    @request = Entry.all.
+      paginate(params[:page], per_page: params[:per_page])
   end
 
   # GET /entries/1

  Modified: app/views/entries/index.html.erb (+7 -1)
===================================================================
--- app/views/entries/index.html.erb    2017-02-22 00:09:09 +0900 (86cbac9)
+++ app/views/entries/index.html.erb    2017-02-22 00:21:25 +0900 (200b00d)
@@ -1,9 +1,13 @@
 <p id="notice"><%= notice %></p>
 
+<div class="page-info">
+  <%= page_entries_info(@request.response) %>
+</div>
+
 <section class="entries">
   <h1>Entries</h1>
 
-  <% @entries.each do |entry| %>
+  <% @request.response.entries.each do |entry| %>
   <section class="entry">
     <h2><%= link_to(entry.title, entry) %></h2>
     <p class="url"><%= entry._key %></p>
@@ -13,3 +17,5 @@
   </section>
   <% end %>
 </section>
+
+<%= paginate(@request.response) %>

  Added: app/views/kaminari/_first_page.html.erb (+3 -0) 100644
===================================================================
--- /dev/null
+++ app/views/kaminari/_first_page.html.erb    2017-02-22 00:21:25 +0900 (cc107ec)
@@ -0,0 +1,3 @@
+<li class="page-item">
+  <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %>
+</li>

  Added: app/views/kaminari/_last_page.html.erb (+3 -0) 100644
===================================================================
--- /dev/null
+++ app/views/kaminari/_last_page.html.erb    2017-02-22 00:21:25 +0900 (9a7584e)
@@ -0,0 +1,3 @@
+<li class="page-item">
+  <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %>
+</li>

  Added: app/views/kaminari/_next_page.html.erb (+3 -0) 100644
===================================================================
--- /dev/null
+++ app/views/kaminari/_next_page.html.erb    2017-02-22 00:21:25 +0900 (7ca72a8)
@@ -0,0 +1,3 @@
+<li class="page-item">
+  <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %>
+</li>

  Added: app/views/kaminari/_page.html.erb (+9 -0) 100644
===================================================================
--- /dev/null
+++ app/views/kaminari/_page.html.erb    2017-02-22 00:21:25 +0900 (57bc591)
@@ -0,0 +1,9 @@
+<% if page.current? %>
+  <li class="page-item active">
+    <%= content_tag :a, page, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %>
+  </li>
+<% else %>
+  <li class="page-item">
+    <%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %>
+  </li>
+<% end %>

  Added: app/views/kaminari/_paginator.html.erb (+15 -0) 100644
===================================================================
--- /dev/null
+++ app/views/kaminari/_paginator.html.erb    2017-02-22 00:21:25 +0900 (b60a3f3)
@@ -0,0 +1,15 @@
+<%= paginator.render do %>
+  <nav>
+    <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 %>
+        <% end %>
+      <% end %>
+      <%= next_page_tag unless current_page.last? %>
+      <%= last_page_tag unless current_page.last? %>
+    </ul>
+  </nav>
+<% end %>

  Added: app/views/kaminari/_prev_page.html.erb (+3 -0) 100644
===================================================================
--- /dev/null
+++ app/views/kaminari/_prev_page.html.erb    2017-02-22 00:21:25 +0900 (c7803fa)
@@ -0,0 +1,3 @@
+<li class="page-item">
+  <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link' %>
+</li>
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index