File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 123123 slop (3.4.4 )
124124 sqlite3 (1.3.7 )
125125 thor (0.18.1 )
126- tilt (1.4.0 )
126+ tilt (1.4.1 )
127127 tzinfo (0.3.37 )
128128 unicorn (4.6.2 )
129129 kgio (~> 2.6 )
Original file line number Diff line number Diff line change 33require "sinatra/flash"
44require "sinatra/contrib/all"
55require "json"
6+ require "will_paginate"
7+ require "will_paginate/active_record"
68
79require_relative "app/helpers/authentication_helpers"
810require_relative "app/repositories/user_repository"
Original file line number Diff line number Diff line change 33
44class Stringer < Sinatra ::Base
55 get "/news" do
6- @unread_stories = StoryRepository . unread
6+ @unread_stories = StoryRepository . unread . page ( params [ :page ] ) . per_page ( 15 )
77
88 erb :index
99 end
1010
1111 get "/read" do
12- @read_stories = StoryRepository . read
13-
12+ @read_stories = StoryRepository . read . page ( params [ :page ] ) . per_page ( 15 )
13+
1414 erb :read
1515 end
1616
Original file line number Diff line number Diff line change @@ -496,4 +496,8 @@ ul.shortcut-legend li {
496496li . blank {
497497 list-style-type : none;
498498 height : 20px ;
499+ }
500+
501+ # pagination {
502+ text-align : center;
499503}
Original file line number Diff line number Diff line change 1616 <% end %>
1717 </ ul >
1818</ div >
19+ < div id ="pagination ">
20+ <% if @unread_stories . previous_page %>
21+ < a href ="?page= <%= @unread_stories . previous_page %> "> < i class ="icon-double-angle-left "> </ i > Previous</ a >
22+ <% end %>
23+ Page <%= @unread_stories . current_page %> of <%= @unread_stories . total_pages %>
24+ <% if @unread_stories . next_page %>
25+ < a href ="?page= <%= @unread_stories . next_page %> "> Next < i class ="icon-double-angle-right "> </ i > </ a >
26+ <% end %>
27+ </ div >
1928<% else %>
2029 <%= render_partial :zen %>
2130<% end %>
Original file line number Diff line number Diff line change 1010 <% end %>
1111 </ ul >
1212</ div >
13+ < div id ="pagination ">
14+ <% if @read_stories . previous_page %>
15+ < a href ="?page= <%= @read_stories . previous_page %> "> < i class ="icon-double-angle-left "> </ i > Previous</ a >
16+ <% end %>
17+ Page <%= @read_stories . current_page %> of <%= @read_stories . total_pages %>
18+ <% if @read_stories . next_page %>
19+ < a href ="?page= <%= @read_stories . next_page %> "> Next < i class ="icon-double-angle-right "> </ i > </ a >
20+ <% end %>
21+ </ div >
1322<% else %>
1423 < div id ="add-some-feeds ">
1524 < p > Sorry, you haven't read any stories yet!</ p >
You can’t perform that action at this time.
0 commit comments