Add pagination
This commit is contained in:
parent
c4fe000861
commit
2dd9453ba5
5 changed files with 19 additions and 54 deletions
4
Gemfile
4
Gemfile
|
@ -9,8 +9,8 @@ gem 'sinatra-redirect-with-flash'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
gem 'json'
|
gem 'json'
|
||||||
gem 'mechanize'
|
gem 'mechanize'
|
||||||
gem 'padrino-helpers'
|
gem 'will_paginate', '~> 3.0.5'
|
||||||
gem 'kaminari', :require => 'kaminari/sinatra'
|
gem 'will_paginate-bootstrap'
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
|
|
50
Gemfile.lock
50
Gemfile.lock
|
@ -1,19 +1,6 @@
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actionpack (4.2.1)
|
|
||||||
actionview (= 4.2.1)
|
|
||||||
activesupport (= 4.2.1)
|
|
||||||
rack (~> 1.6)
|
|
||||||
rack-test (~> 0.6.2)
|
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
|
||||||
actionview (4.2.1)
|
|
||||||
activesupport (= 4.2.1)
|
|
||||||
builder (~> 3.1)
|
|
||||||
erubis (~> 2.7.0)
|
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
|
||||||
activemodel (4.2.1)
|
activemodel (4.2.1)
|
||||||
activesupport (= 4.2.1)
|
activesupport (= 4.2.1)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
|
@ -31,21 +18,12 @@ GEM
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
domain_name (0.5.24)
|
domain_name (0.5.24)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
erubis (2.7.0)
|
|
||||||
foreman (0.78.0)
|
foreman (0.78.0)
|
||||||
thor (~> 0.19.1)
|
thor (~> 0.19.1)
|
||||||
http-cookie (1.0.2)
|
http-cookie (1.0.2)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http_router (0.5.4)
|
|
||||||
rack (>= 1.0.0)
|
|
||||||
url_mount (~> 0.2.1)
|
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
json (1.8.2)
|
json (1.8.2)
|
||||||
kaminari (0.16.3)
|
|
||||||
actionpack (>= 3.0.0)
|
|
||||||
activesupport (>= 3.0.0)
|
|
||||||
loofah (2.0.1)
|
|
||||||
nokogiri (>= 1.5.9)
|
|
||||||
mechanize (2.7.3)
|
mechanize (2.7.3)
|
||||||
domain_name (~> 0.5, >= 0.5.1)
|
domain_name (~> 0.5, >= 0.5.1)
|
||||||
http-cookie (~> 1.0)
|
http-cookie (~> 1.0)
|
||||||
|
@ -63,29 +41,10 @@ GEM
|
||||||
nokogiri (1.6.6.2)
|
nokogiri (1.6.6.2)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
ntlm-http (0.1.1)
|
ntlm-http (0.1.1)
|
||||||
padrino-core (0.9.21)
|
|
||||||
activesupport (>= 3.0.0)
|
|
||||||
http_router (~> 0.5.4)
|
|
||||||
sinatra (>= 1.1.0)
|
|
||||||
thor (>= 0.14.3)
|
|
||||||
tzinfo
|
|
||||||
padrino-helpers (0.9.21)
|
|
||||||
i18n (>= 0.4.1)
|
|
||||||
padrino-core (= 0.9.21)
|
|
||||||
pg (0.18.1)
|
pg (0.18.1)
|
||||||
rack (1.6.0)
|
rack (1.6.0)
|
||||||
rack-protection (1.5.3)
|
rack-protection (1.5.3)
|
||||||
rack
|
rack
|
||||||
rack-test (0.6.3)
|
|
||||||
rack (>= 1.0)
|
|
||||||
rails-deprecated_sanitizer (1.0.3)
|
|
||||||
activesupport (>= 4.2.0.alpha)
|
|
||||||
rails-dom-testing (1.0.6)
|
|
||||||
activesupport (>= 4.2.0.beta, < 5.0)
|
|
||||||
nokogiri (~> 1.6.0)
|
|
||||||
rails-deprecated_sanitizer (>= 1.0.1)
|
|
||||||
rails-html-sanitizer (1.0.2)
|
|
||||||
loofah (~> 2.0)
|
|
||||||
rake (10.4.2)
|
rake (10.4.2)
|
||||||
sinatra (1.4.6)
|
sinatra (1.4.6)
|
||||||
rack (~> 1.4)
|
rack (~> 1.4)
|
||||||
|
@ -107,9 +66,10 @@ GEM
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.1)
|
unf_ext (0.0.7.1)
|
||||||
url_mount (0.2.1)
|
|
||||||
rack
|
|
||||||
webrobots (0.1.1)
|
webrobots (0.1.1)
|
||||||
|
will_paginate (3.0.7)
|
||||||
|
will_paginate-bootstrap (1.0.1)
|
||||||
|
will_paginate (>= 3.0.3)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
@ -118,9 +78,7 @@ DEPENDENCIES
|
||||||
activerecord
|
activerecord
|
||||||
foreman
|
foreman
|
||||||
json
|
json
|
||||||
kaminari
|
|
||||||
mechanize
|
mechanize
|
||||||
padrino-helpers
|
|
||||||
pg
|
pg
|
||||||
rake
|
rake
|
||||||
sinatra
|
sinatra
|
||||||
|
@ -128,3 +86,5 @@ DEPENDENCIES
|
||||||
sinatra-flash
|
sinatra-flash
|
||||||
sinatra-redirect-with-flash
|
sinatra-redirect-with-flash
|
||||||
sqlite3
|
sqlite3
|
||||||
|
will_paginate (~> 3.0.5)
|
||||||
|
will_paginate-bootstrap
|
||||||
|
|
5
app.rb
5
app.rb
|
@ -1,10 +1,5 @@
|
||||||
require './environments'
|
require './environments'
|
||||||
|
|
||||||
require './models/raid'
|
|
||||||
require './models/leader'
|
|
||||||
require './helpers/raids_helper'
|
|
||||||
require './jobs/leaders'
|
|
||||||
|
|
||||||
set :public_folder, 'public'
|
set :public_folder, 'public'
|
||||||
|
|
||||||
# CONTROLLER
|
# CONTROLLER
|
||||||
|
|
|
@ -2,7 +2,9 @@ require 'rubygems'
|
||||||
require 'bundler'
|
require 'bundler'
|
||||||
Bundler.require
|
Bundler.require
|
||||||
|
|
||||||
register Kaminari::Helpers::SinatraHelpers
|
require 'will_paginate'
|
||||||
|
require 'will_paginate/active_record'
|
||||||
|
include WillPaginate::Sinatra::Helpers
|
||||||
|
|
||||||
require './models/raid'
|
require './models/raid'
|
||||||
require './models/leader'
|
require './models/leader'
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
|
<div class="pull-right">
|
||||||
|
<%= will_paginate @raids, renderer: BootstrapPagination::Sinatra %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table class="table table-striped table-hover table-bordered table-condensed">
|
<table class="table table-striped table-hover table-bordered table-condensed">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -22,10 +26,14 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%= paginate @raids %>
|
<div>
|
||||||
|
<%= will_paginate @raids, renderer: BootstrapPagination::Sinatra %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
<h2>Top 20</h2>
|
||||||
|
<br/><br/>
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<% @top20.each do |user| %>
|
<% @top20.each do |user| %>
|
||||||
<li class="list-group-item"><%= user[:user] %><span class="pull-right"><small><%= user[:date].strftime('%H:%M on %m-%d-%Y') if user[:date] %></small></li>
|
<li class="list-group-item"><%= user[:user] %><span class="pull-right"><small><%= user[:date].strftime('%H:%M on %m-%d-%Y') if user[:date] %></small></li>
|
||||||
|
|
Loading…
Reference in a new issue