5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 18:26:21 +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 'validates_hostname'
gem 'webpacker' gem 'webpacker'
gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git' gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git'
gem 'kaminari'
# database # database
gem 'hairtrigger' gem 'hairtrigger'

View file

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

View file

@ -24,7 +24,7 @@ class PostsController < ApplicationController
# más simple saber si hubo cambios. # más simple saber si hubo cambios.
if stale?([current_usuarie, site, filter_params]) if 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) @posts = site.indexed_posts.where(locale: locale).page(filter_params.delete(:page))
# 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
@ -154,7 +154,7 @@ class PostsController < ApplicationController
# #
# @return [Hash] # @return [Hash]
def filter_params 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 end
def site def site

View file

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