From 351b2d71785fb45ca3afae3b42540222fb4d47e0 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Thu, 31 Jul 2014 17:01:30 -0700 Subject: [PATCH] pagination for site profile --- app.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index 9281f86a..feba367a 100644 --- a/app.rb +++ b/app.rb @@ -89,7 +89,16 @@ get '/site/:username' do |username| end @title = site.title - @latest_events = site.latest_events + + @current_page = params[:current_page] + @current_page = @current_page.to_i + @current_page = 1 if @current_page == 0 + + latest_events_dataset = site.latest_events(@current_page, 10) + + @page_count = latest_events_dataset.page_count || 1 + @latest_events = latest_events_dataset.all + erb :'site', locals: {site: site, is_current_site: site == current_site} end