- @entries = if params[:before]
- entries.where("diary_entries.id < ?", params[:before]).order(:id => :desc)
- elsif params[:after]
- entries.where("diary_entries.id > ?", params[:after]).order(:id => :asc)
- else
- entries.order(:id => :desc)
- end
-
- @entries = @entries.limit(20)
- @entries = @entries.includes(:user, :language)
- @entries = @entries.sort.reverse
-
- @newer_entries = @entries.count.positive? && entries.exists?(["diary_entries.id > ?", @entries.first.id])
- @older_entries = @entries.count.positive? && entries.exists?(["diary_entries.id < ?", @entries.last.id])
+ @entries, @newer_entries_id, @older_entries_id = get_page_items(entries, :includes => [:user, :language])