diff --git a/Gemfile.lock b/Gemfile.lock index c59a47c0..896b06c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -343,7 +343,7 @@ GEM ffi-compiler (>= 0.1.2) webrick (1.8.1) websocket (1.2.10) - will_paginate (4.0.0) + will_paginate (4.0.1) xmlrpc (0.3.3) webrick xpath (3.2.0) diff --git a/app/site.rb b/app/site.rb index 78955f58..53d839fc 100644 --- a/app/site.rb +++ b/app/site.rb @@ -127,16 +127,22 @@ end get '/site/:username/follows' do |username| @title = "Sites #{username} follows" @site = Site[username: username] - not_found if @site.nil? || @site.is_banned || @site.is_deleted || (current_site && (@site.is_blocking?(current_site) || current_site.is_blocking?(@site))) - @sites = @site.followings.collect {|f| f.site} + not_found if @site.nil? || @site.is_deleted || (current_site && (@site.is_blocking?(current_site) || current_site.is_blocking?(@site))) + + params[:page] ||= "1" + + @pagination_dataset = @site.followings_dataset.paginate(params[:page].to_i, Site::FOLLOW_PAGINATION_LIMIT) erb :'site/follows' end get '/site/:username/followers' do |username| @title = "Sites that follow #{username}" @site = Site[username: username] - not_found if @site.nil? || @site.is_banned || @site.is_deleted || (current_site && (@site.is_blocking?(current_site) || current_site.is_blocking?(@site))) - @sites = @site.follows.collect {|f| f.actioning_site} + not_found if @site.nil? || @site.is_deleted || (current_site && (@site.is_blocking?(current_site) || current_site.is_blocking?(@site))) + + params[:page] ||= "1" + + @pagination_dataset = @site.follows_dataset.paginate(params[:page].to_i, Site::FOLLOW_PAGINATION_LIMIT) erb :'site/followers' end diff --git a/models/site.rb b/models/site.rb index 9eedffec..d4d4e20a 100644 --- a/models/site.rb +++ b/models/site.rb @@ -87,6 +87,8 @@ class Site < Sequel::Model BROWSE_FOLLOWER_UPDATED_AT_CUTOFF = 9.months BROWSE_FOLLOWER_MINIMUM_FOLLOWS = 0 + FOLLOW_PAGINATION_LIMIT = 100 + SCREENSHOT_DELAY_SECONDS = 30 SCREENSHOT_RESOLUTIONS = ['540x405', '210x158', '100x100', '50x50'] THUMBNAIL_RESOLUTIONS = ['210x158'] diff --git a/views/site/followers.erb b/views/site/followers.erb index 8421e672..6744927b 100644 --- a/views/site/followers.erb +++ b/views/site/followers.erb @@ -8,14 +8,14 @@
- <% if @sites.length == 0 %> + <% if @pagination_dataset.length == 0 %> <% else %> <% end %>
+ +<%== erb :'_pagination', layout: false %> \ No newline at end of file diff --git a/views/site/follows.erb b/views/site/follows.erb index c1074475..7acbb171 100644 --- a/views/site/follows.erb +++ b/views/site/follows.erb @@ -7,7 +7,7 @@
- <% if @sites.length == 0 %> + <% if @pagination_dataset.length == 0 %> <% else %> <% end %>
+ +<%== erb :'_pagination', layout: false %> \ No newline at end of file