5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-25 04:56:23 +00:00

Revert "Merge branch 'paginacion' into rails"

This reverts commit ba7d0c2e00, reversing
changes made to 56cb11dc49.
This commit is contained in:
f 2021-10-21 14:39:33 -03:00
parent 69ef571bdb
commit 71eb2436ef
8 changed files with 40 additions and 72 deletions

View file

@ -67,7 +67,6 @@ 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,18 +309,6 @@ 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)
@ -357,7 +345,6 @@ 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)
@ -370,8 +357,7 @@ 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-musl)
mini_portile2 (~> 2.5.0)
nokogiri (1.11.7-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.20.1)
@ -681,7 +667,6 @@ DEPENDENCIES
jekyll-data!
jekyll-images
jekyll-include-cache
kaminari
letter_opener
listen (>= 3.0.5, < 3.2)
loaf

View file

@ -25,7 +25,7 @@ class PostsController < ApplicationController
return unless stale?([current_usuarie, site, filter_params])
# 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)
# 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, :page).to_hash.select do |_, v|
@filter_params ||= params.permit(:q, :category, :layout).to_hash.select do |_, v|
v.present?
end.transform_keys(&:to_sym)
end

View file

@ -65,6 +65,9 @@ class Site < ApplicationRecord
accepts_nested_attributes_for :deploys, allow_destroy: true
# El sitio en Jekyll
attr_reader :jekyll
# XXX: Es importante incluir luego de los callbacks de :load_jekyll
include Site::Index
@ -177,28 +180,29 @@ class Site < ApplicationRecord
# Trae los datos del directorio _data dentro del sitio
def data
unless jekyll.data.present?
run_in_path do
jekyll.reader.read_data
jekyll.data['layouts'] ||= {}
unless @jekyll.data.present?
@jekyll.reader.read_data
# Define los valores por defecto según la llave buscada
@jekyll.data.default_proc = proc do |data, key|
data[key] = case key
when 'layout' then {}
end
end
end
jekyll.data
@jekyll.data
end
# Traer las colecciones. Todos los artículos van a estar dentro de
# colecciones.
def collections
unless @read
run_in_path do
jekyll.reader.read_collections
end
@jekyll.reader.read_collections
@read = true
end
jekyll.collections
@jekyll.collections
end
# Traer la configuración de forma modificable
@ -286,9 +290,7 @@ class Site < ApplicationRecord
#
# @return [Hash]
def theme_layouts
run_in_path do
jekyll.reader.read_layouts
end
@jekyll.reader.read_layouts
end
# Trae todos los valores disponibles para un campo
@ -330,12 +332,6 @@ class Site < ApplicationRecord
status == 'building'
end
def jekyll
run_in_path do
@jekyll ||= Jekyll::Site.new(configuration)
end
end
# Cargar el sitio Jekyll
#
# TODO: En lugar de leer todo junto de una vez, extraer la carga de
@ -349,7 +345,10 @@ class Site < ApplicationRecord
def reload_jekyll!
reset
jekyll
Dir.chdir(path) do
@jekyll = Jekyll::Site.new(configuration)
end
end
def reload
@ -527,8 +526,4 @@ class Site < ApplicationRecord
errors.add(:design_id,
I18n.t('activerecord.errors.models.site.attributes.design_id.layout_incompatible.error'))
end
def run_in_path(&block)
Dir.chdir path, &block
end
end

View file

@ -40,7 +40,7 @@
%section.col
= render 'layouts/flash'
.d-flex.justify-content-between.align-items-center.pl-2-plus.pr-2-plus.mb-2
%form{ action: site_posts_path }
%form
- @filter_params.each do |param, value|
- next if param == 'q'
%input{ type: 'hidden', name: param, value: value }
@ -72,20 +72,14 @@
%thead
%tr
%th.border-0.background-white.position-sticky{ style: 'top: 0; z-index: 2', colspan: '4' }
.d-flex.flex-row.justify-content-between
%div
= submit_tag t('posts.reorder.submit'), class: 'btn'
%button.btn{ data: { action: 'reorder#unselect' } }
= t('posts.reorder.unselect')
%span.badge{ data: { target: 'reorder.counter' } } 0
%button.btn{ data: { action: 'reorder#up' } }= t('posts.reorder.up')
%button.btn{ data: { action: 'reorder#down' } }= t('posts.reorder.down')
%button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top')
%button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom')
%div
= link_to_prev_page @posts, t('posts.prev'), class: 'btn'
= link_to_next_page @posts, t('posts.next'), class: 'btn'
= submit_tag t('posts.reorder.submit'), class: 'btn'
%button.btn{ data: { action: 'reorder#unselect' } }
= t('posts.reorder.unselect')
%span.badge{ data: { target: 'reorder.counter' } } 0
%button.btn{ data: { action: 'reorder#up' } }= t('posts.reorder.up')
%button.btn{ data: { action: 'reorder#down' } }= t('posts.reorder.down')
%button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top')
%button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom')
%tbody
- dir = t("locales.#{@locale}.dir")
- size = @posts.size
@ -110,19 +104,19 @@
%span{ lang: post.locale, dir: dir }= post.title
- if post.front_matter['draft'].present?
%span.badge.badge-primary= I18n.t('posts.attributes.draft.label')
%br
%small
= link_to @site.layouts[post.layout].humanized_name, site_posts_path(@site, **@filter_params.merge(layout: post.layout))
- post.front_matter['categories']&.each do |category|
= link_to site_posts_path(@site, **@filter_params.merge(category: category)) do
%span{ lang: post.locale, dir: dir }= category
= '/' unless post.front_matter['categories'].last == category
- if post.front_matter['categories'].present?
%br
%small
- post.front_matter['categories'].each do |category|
= link_to site_posts_path(@site, **@filter_params.merge(category: category)) do
%span{ lang: post.locale, dir: dir }= category
= '/' unless post.front_matter['categories'].last == category
%td.text-nowrap
%td
= post.created_at.strftime('%F')
%br/
= post.order
%td.text-nowrap
%td
- if @usuarie || policy(post).edit?
= link_to t('posts.edit'), edit_site_post_path(@site, post.path), class: 'btn btn-block'
- if @usuarie || policy(post).destroy?

View file

@ -376,8 +376,6 @@ en:
en: 'English'
ar: 'Arabic'
posts:
prev: Previous page
next: Next page
empty: "There are no results for those search parameters."
caption: Post list
attribute_ro:

View file

@ -384,8 +384,6 @@ es:
en: 'inglés'
ar: 'árabe'
posts:
prev: Página anterior
next: Página siguiente
empty: No hay artículos con estos parámetros de búsqueda.
caption: Lista de artículos
attribute_ro:

View file

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