From 5abf64d647b6f36a51f014b63f7b469b43378d3f Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 3 Dec 2016 19:30:13 +0100 Subject: [PATCH] Add "next" pagination to public profiles --- app/controllers/accounts_controller.rb | 4 ++-- app/views/accounts/show.html.haml | 4 +++- app/views/admin/accounts/index.html.haml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index b0e5a832017..46231dd9714 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -9,12 +9,12 @@ class AccountsController < ApplicationController def show respond_to do |format| format.html do - @statuses = @account.statuses.order('id desc').paginate_by_max_id(20, params[:max_id || nil]) + @statuses = @account.statuses.order('id desc').paginate_by_max_id(20, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses, Status) end format.atom do - @entries = @account.stream_entries.order('id desc').with_includes.paginate_by_max_id(20, params[:max_id] || nil) + @entries = @account.stream_entries.order('id desc').with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id]) end end end diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index c04faa32f90..db8e45e6b95 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -14,4 +14,6 @@ .activity-stream = render partial: 'stream_entries/status', collection: @statuses, as: :status -= id_paginate account_url(@account), 20, @statuses +.pagination + - if @statuses.size == 20 + = link_to safe_join([t('pagination.next'), fa_icon('chevron-right')], ' '), account_url(@account, max_id: @statuses.last.id), class: 'next_page', rel: 'next' diff --git a/app/views/admin/accounts/index.html.haml b/app/views/admin/accounts/index.html.haml index aac2f99a8a5..32474c2a4ff 100644 --- a/app/views/admin/accounts/index.html.haml +++ b/app/views/admin/accounts/index.html.haml @@ -16,4 +16,5 @@ %i.fa.fa-check - else %i.fa.fa-times + = will_paginate @accounts, pagination_options