mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
pagination for follow/follower lists
This commit is contained in:
parent
a67588a1c0
commit
2625e1328a
5 changed files with 21 additions and 9 deletions
|
@ -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)
|
||||
|
|
14
app/site.rb
14
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
|
||||
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
<div class="browse-page">
|
||||
|
||||
<% if @sites.length == 0 %>
|
||||
<% if @pagination_dataset.length == 0 %>
|
||||
<div class="row website-Gallery content int-Gall" style="padding-left: 30px;">
|
||||
<h3>No followers yet.</h3>
|
||||
<p>Try another search, or <a href="/browse">browse all sites</a>!</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<ul class="row website-Gallery content int-Gall">
|
||||
<% @sites.each_with_index do |site| %>
|
||||
<% @pagination_dataset.collect {|f| f.actioning_site}.each_with_index do |site| %>
|
||||
<li>
|
||||
<a href="<%= site.uri %>" class="neo-Screen-Shot" title="<%= site.title %>">
|
||||
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '540x405') %>) no-repeat;">
|
||||
|
@ -73,3 +73,5 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%== erb :'_pagination', layout: false %>
|
|
@ -7,7 +7,7 @@
|
|||
</div>
|
||||
|
||||
<div class="browse-page">
|
||||
<% if @sites.length == 0 %>
|
||||
<% if @pagination_dataset.length == 0 %>
|
||||
<div class="row website-Gallery content int-Gall" style="padding-left: 30px;">
|
||||
<h3>No follows yet.</h3>
|
||||
<% if current_site == @site %>
|
||||
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
<% else %>
|
||||
<ul class="row website-Gallery content int-Gall">
|
||||
<% @sites.each_with_index do |site| %>
|
||||
<% @pagination_dataset.collect {|f| f.site}.each_with_index do |site| %>
|
||||
<li>
|
||||
<a href="<%= site.uri %>" class="neo-Screen-Shot" title="<%= site.title %>">
|
||||
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '540x405') %>) no-repeat;">
|
||||
|
@ -74,3 +74,5 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%== erb :'_pagination', layout: false %>
|
Loading…
Add table
Reference in a new issue