Bad pagination that will fail very quickly after launch

This commit is contained in:
Kyle Drake 2013-06-20 20:43:20 -07:00
parent 466e49c16d
commit 712371101e
2 changed files with 19 additions and 1 deletions

8
app.rb
View file

@ -35,7 +35,13 @@ get '/?' do
end
get '/browse' do
@sites = Site.order(:id.desc).filter(~{updated_at: nil}).all
@current_page = params[:current_page] || 1
@current_page = @current_page.to_i
site_dataset = Site.order(:id.desc).filter(~{updated_at: nil}).paginate(@current_page, 100)
@page_count = site_dataset.page_count
@sites = site_dataset.all
slim :browse
end

View file

@ -15,3 +15,15 @@
.span3.text-right
p style="margin-right: 20px; margin-top: 10px" #{site.hits} hits<br>last updated #{site.updated_at.ago}
a href="http://#{site.username}.neocities.org" target="_blank": img src="/site_screenshots/#{ENV['RACK_ENV'] == 'development' ? 'victoria' : site.username}.jpg"
- if @page_count > 1
.pagination.pagination-large.text-center
ul
- if @current_page != 1
li: a href="/browse?current_page=#{@current_page - 1}": i.icon-arrow-left style="font-size: 12pt"
- 1.upto(@page_count) do |num|
li class="#{"active" if num == @current_page}": a href="/browse?current_page=#{num}" #{num}
- if @current_page != @page_count
li: a href="/browse?current_page=#{@current_page + 1}": i.icon-arrow-right style="font-size: 12pt"