5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-05-17 06:30:48 +00:00

Paginación

This commit is contained in:
f 2021-09-15 21:02:09 -03:00
parent 859b8518c0
commit 8e1f5c5558
4 changed files with 20 additions and 3 deletions

View file

@ -67,6 +67,7 @@ gem 'terminal-table'
gem 'validates_hostname'
gem 'webpacker'
gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git'
gem 'kaminari'
# database
gem 'hairtrigger'

View file

@ -309,6 +309,18 @@ GEM
jekyll-write-and-commit-changes (0.1.2)
jekyll (~> 4)
rugged (~> 1)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
kaminari-activerecord (= 1.2.1)
kaminari-core (= 1.2.1)
kaminari-actionview (1.2.1)
actionview
kaminari-core (= 1.2.1)
kaminari-activerecord (1.2.1)
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
kramdown (2.3.1)
rexml
kramdown-parser-gfm (1.1.0)
@ -345,6 +357,7 @@ GEM
mini_histogram (0.3.1)
mini_magick (4.11.0)
mini_mime (1.1.0)
mini_portile2 (2.5.3)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
@ -357,7 +370,8 @@ GEM
net-ssh (6.1.0)
netaddr (2.0.4)
nio4r (2.5.7-x86_64-linux-musl)
nokogiri (1.11.7-x86_64-linux)
nokogiri (1.11.7-x86_64-linux-musl)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.20.1)
@ -667,6 +681,7 @@ DEPENDENCIES
jekyll-data!
jekyll-images
jekyll-include-cache
kaminari
letter_opener
listen (>= 3.0.5, < 3.2)
loaf

View file

@ -24,7 +24,7 @@ class PostsController < ApplicationController
# más simple saber si hubo cambios.
if stale?([current_usuarie, site, filter_params])
# Todos los artículos de este sitio para el idioma actual
@posts = site.indexed_posts.where(locale: locale)
@posts = site.indexed_posts.where(locale: locale).page(filter_params.delete(:page))
# De este tipo
@posts = @posts.where(layout: filter_params[:layout]) if filter_params[:layout]
# Que estén dentro de la categoría
@ -154,7 +154,7 @@ class PostsController < ApplicationController
#
# @return [Hash]
def filter_params
@filter_params ||= params.permit(:q, :category, :layout).to_h.select { |_, v| v.present? }
@filter_params ||= params.permit(:q, :category, :layout, :page).to_h.select { |_, v| v.present? }
end
def site

View file

@ -60,6 +60,7 @@ Rails.application.routes.draw do
scope '(:locale)' do
post :'posts/reorder', to: 'posts#reorder'
resources :posts do
get 'p/:page', action: :index, on: :collection
get :preview, to: 'posts#preview'
end
end