mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 21:53:37 +00:00
feat: poder paginar solo algunos sitios #12714
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
068bed5c0a
commit
3540886554
3 changed files with 14 additions and 4 deletions
|
@ -23,7 +23,8 @@ class PostsController < ApplicationController
|
||||||
return unless stale?([current_usuarie, site, filter_params])
|
return unless stale?([current_usuarie, site, filter_params])
|
||||||
|
|
||||||
# Todos los artículos de este sitio para el idioma actual
|
# Todos los artículos de este sitio para el idioma actual
|
||||||
@posts = site.indexed_posts.where(locale: locale).page(filter_params.delete(:page))
|
@posts = site.indexed_posts.where(locale: locale)
|
||||||
|
@posts = @posts.page(filter_params.delete(:page)) if site.pagination
|
||||||
# De este tipo
|
# De este tipo
|
||||||
@posts = @posts.where(layout: filter_params[:layout]) if filter_params[:layout]
|
@posts = @posts.where(layout: filter_params[:layout]) if filter_params[:layout]
|
||||||
# Que estén dentro de la categoría
|
# Que estén dentro de la categoría
|
||||||
|
|
|
@ -84,9 +84,10 @@
|
||||||
%button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top')
|
%button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top')
|
||||||
%button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom')
|
%button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom')
|
||||||
|
|
||||||
%div
|
- if @site.pagination
|
||||||
= link_to_prev_page @posts, t('posts.prev'), class: 'btn'
|
%div
|
||||||
= link_to_next_page @posts, t('posts.next'), class: 'btn'
|
= link_to_prev_page @posts, t('posts.prev'), class: 'btn'
|
||||||
|
= link_to_next_page @posts, t('posts.next'), class: 'btn'
|
||||||
%tbody
|
%tbody
|
||||||
- dir = @site.data.dig(params[:locale], 'dir')
|
- dir = @site.data.dig(params[:locale], 'dir')
|
||||||
- size = @posts.size
|
- size = @posts.size
|
||||||
|
|
8
db/migrate/20230519143500_add_pagination_to_site.rb
Normal file
8
db/migrate/20230519143500_add_pagination_to_site.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Agrega la opción de paginación a los sitios
|
||||||
|
class AddPaginationToSites < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :sites, :pagination, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue