2023-05-24 14:41:16 +00:00
|
|
|
- reorder_allowed = policy(@site).reorder?
|
2023-05-24 13:58:08 +00:00
|
|
|
- if reorder_allowed
|
|
|
|
- reorder_controller = { controller: 'reorder' }
|
|
|
|
- reorder_target = { target: 'reorder.row' }
|
|
|
|
- else
|
|
|
|
- reorder_target = reorder_controller = {}
|
|
|
|
|
2019-09-12 18:10:01 +00:00
|
|
|
%main.row
|
2023-04-20 21:23:58 +00:00
|
|
|
%aside.menu.col-lg-3
|
2024-03-21 21:12:12 +00:00
|
|
|
.mb-3
|
|
|
|
= render 'sites/header', site: @site
|
|
|
|
= render 'sites/status', site: @site
|
|
|
|
= render 'sites/build', site: @site, class: 'btn-block'
|
|
|
|
= render 'sites/moderation_queue', site: @site, class: 'btn-block'
|
2023-04-13 17:25:56 +00:00
|
|
|
|
2024-03-01 19:07:56 +00:00
|
|
|
= render 'layouts/details', summary: t('posts.filters.title') do
|
2024-05-02 13:33:50 +00:00
|
|
|
|
|
|
|
%form{method: :get}
|
|
|
|
.border.border-magenta.p-1
|
|
|
|
- @filter_params.each do |param, values|
|
|
|
|
- next if param == :layout
|
|
|
|
- [values].flatten.each do |value|
|
|
|
|
%input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value }
|
|
|
|
%legend.font-weight-bold.m-0.h6= 'Tipo de contenido'
|
|
|
|
- @site.schema_organization.each do |key, _|
|
|
|
|
.custom-control.custom-checkbox
|
|
|
|
- schema = @site.layouts[key]
|
|
|
|
%input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name, checked: @filter_params[:layout]&.include?(key.to_s) }
|
|
|
|
%label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name
|
2024-05-14 15:27:59 +00:00
|
|
|
%button.btn.btn-secondary.mt-3{ type: 'submit' }= t('posts.filters.submit')
|
2024-05-14 15:22:56 +00:00
|
|
|
= render 'layouts/details',
|
|
|
|
summary: t('posts.new'),
|
|
|
|
summary_class: "h4 magenta font-weight-bold m-0 px-2",
|
|
|
|
details_class: "d-flex border border-magenta justify-content-between align-items-center w-100 mb-3",
|
|
|
|
open: "+", closed: "+",
|
|
|
|
open_class: "h1 magenta font-weight-bold m-0",
|
|
|
|
closed_class: "h1 magenta font-weight-bold m-0" do
|
2024-03-08 16:58:10 +00:00
|
|
|
%table.table-sm.w-100
|
2024-03-04 16:12:22 +00:00
|
|
|
%tbody
|
|
|
|
- @site.schema_organization.each do |schema, _|
|
|
|
|
- schema = @site.layouts[schema]
|
|
|
|
- next if schema.hidden?
|
|
|
|
= render 'schemas/row', site: @site, schema: schema, filter: @filter_params
|
2024-03-08 16:58:10 +00:00
|
|
|
|
|
|
|
|
2022-07-15 17:17:46 +00:00
|
|
|
- if policy(@site_stat).index?
|
2024-01-12 17:11:29 +00:00
|
|
|
= link_to t('stats.index.title'), site_stats_path(@site), class: 'btn btn-secondary'
|
2022-07-15 17:17:46 +00:00
|
|
|
|
2019-09-12 18:10:01 +00:00
|
|
|
- if policy(@site).edit?
|
2024-01-12 17:11:29 +00:00
|
|
|
= link_to t('sites.edit.btn', site: @site.title), edit_site_path(@site), class: 'btn btn-secondary'
|
2020-08-23 00:04:46 +00:00
|
|
|
|
|
|
|
- if policy(@site).private?
|
2024-01-12 17:11:29 +00:00
|
|
|
= link_to t('sites.private'), '../private/' + @site.name, class: 'btn btn-secondary', target: '_blank', rel: 'noopener'
|
2019-09-12 18:10:01 +00:00
|
|
|
|
2020-11-26 18:47:41 +00:00
|
|
|
- if policy(SiteUsuarie.new(@site, current_usuarie)).index?
|
|
|
|
= render 'layouts/btn_with_tooltip',
|
|
|
|
tooltip: t('usuaries.index.help.self'),
|
|
|
|
text: t('usuaries.index.title'),
|
|
|
|
type: 'info',
|
|
|
|
link: site_usuaries_path(@site)
|
|
|
|
|
2020-08-11 21:52:53 +00:00
|
|
|
- if @site.design.credits
|
2023-03-28 21:52:42 +00:00
|
|
|
= render 'bootstrap/alert' do
|
2020-08-11 21:52:53 +00:00
|
|
|
= sanitize_markdown @site.design.credits
|
2024-01-12 17:11:29 +00:00
|
|
|
= link_to t('sites.donations.text'), t('sites.donations.url'), class: 'btn btn-secondary'
|
2020-08-11 21:52:53 +00:00
|
|
|
- if @site.design.designer_url
|
2024-01-12 17:11:29 +00:00
|
|
|
= link_to t('sites.designer_url'), @site.design.designer_url, class: 'btn btn-secondary'
|
2020-08-11 21:52:53 +00:00
|
|
|
|
2019-09-12 18:10:01 +00:00
|
|
|
%section.col
|
2021-05-07 19:17:25 +00:00
|
|
|
.d-flex.justify-content-between.align-items-center.pl-2-plus.pr-2-plus.mb-2
|
|
|
|
|
2021-05-07 20:31:50 +00:00
|
|
|
- if @site.locales.size > 1
|
2021-05-07 19:17:25 +00:00
|
|
|
%nav#locales
|
|
|
|
- @site.locales.each do |locale|
|
2021-10-21 18:02:07 +00:00
|
|
|
= link_to @site.data.dig(locale.to_s, 'locale') || locale, site_posts_path(@site, **@filter_params.merge(locale: locale)),
|
2021-05-07 19:17:25 +00:00
|
|
|
class: "mr-2 mt-2 mb-2 #{locale == @locale ? 'active font-weight-bold' : ''}"
|
2024-03-01 19:07:56 +00:00
|
|
|
|
2019-12-11 20:05:31 +00:00
|
|
|
- if @posts.empty?
|
2021-05-07 19:17:25 +00:00
|
|
|
%h2= t('posts.empty')
|
2019-12-11 20:05:31 +00:00
|
|
|
- else
|
|
|
|
= form_tag site_posts_reorder_path, method: :post do
|
2023-05-24 13:58:08 +00:00
|
|
|
%table.table{ data: reorder_controller }
|
2020-06-25 19:53:55 +00:00
|
|
|
%caption.sr-only= t('posts.caption')
|
2020-11-19 20:44:13 +00:00
|
|
|
%thead
|
2022-04-30 21:42:50 +00:00
|
|
|
%tr.sticky-top
|
2024-05-14 15:05:48 +00:00
|
|
|
%th.border-0.p-0.p-md-2-plus{ colspan: '4' }
|
2021-09-16 00:03:07 +00:00
|
|
|
.d-flex.flex-row.justify-content-between
|
|
|
|
%div
|
2023-05-24 13:58:08 +00:00
|
|
|
- if reorder_allowed
|
2024-02-22 20:29:04 +00:00
|
|
|
= submit_tag t('posts.reorder.submit'), class: 'btn btn-secondary'
|
2024-02-22 15:00:27 +00:00
|
|
|
%button.btn.btn-secondary{ data: { action: 'reorder#unselect' } }
|
2023-05-24 13:58:08 +00:00
|
|
|
= t('posts.reorder.unselect')
|
|
|
|
%span.badge{ data: { target: 'reorder.counter' } } 0
|
2024-02-22 15:00:27 +00:00
|
|
|
%button.btn.btn-secondary{ data: { action: 'reorder#up' } }= t('posts.reorder.up')
|
|
|
|
%button.btn.btn-secondary{ data: { action: 'reorder#down' } }= t('posts.reorder.down')
|
|
|
|
%button.btn.btn-secondary{ data: { action: 'reorder#top' } }= t('posts.reorder.top')
|
|
|
|
%button.btn.btn-secondary{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom')
|
2023-05-24 13:58:08 +00:00
|
|
|
%input{ type: 'hidden', name: 'post[lang]', value: @locale }
|
2021-09-16 00:03:07 +00:00
|
|
|
|
2023-05-19 17:36:42 +00:00
|
|
|
- if @site.pagination
|
|
|
|
%div
|
2024-01-12 17:11:29 +00:00
|
|
|
= link_to_prev_page @posts, t('posts.prev'), class: 'btn btn-secondary'
|
|
|
|
= link_to_next_page @posts, t('posts.next'), class: 'btn btn-secondary'
|
2019-12-11 20:05:31 +00:00
|
|
|
%tbody
|
2022-03-02 17:01:17 +00:00
|
|
|
- dir = @site.data.dig(params[:locale], 'dir')
|
2021-05-07 19:17:25 +00:00
|
|
|
- size = @posts.size
|
2019-12-11 20:05:31 +00:00
|
|
|
- @posts.each_with_index do |post, i|
|
2020-05-11 20:28:38 +00:00
|
|
|
-#
|
|
|
|
TODO: Solo les usuaries cachean porque tenemos que separar
|
|
|
|
les botones por permisos.
|
2021-04-21 17:11:11 +00:00
|
|
|
- begin
|
2022-03-07 15:06:27 +00:00
|
|
|
- cache_if @usuarie, [post, I18n.locale] do
|
2022-08-24 21:01:14 +00:00
|
|
|
- checkbox_id = "checkbox-#{post.post_id}"
|
2023-05-24 14:03:11 +00:00
|
|
|
%tr{ id: post.post_id, data: reorder_target }
|
|
|
|
- if reorder_allowed
|
|
|
|
%td
|
|
|
|
.custom-control.custom-checkbox
|
|
|
|
%input.custom-control-input{ id: checkbox_id, type: 'checkbox', autocomplete: 'off', data: { action: 'reorder#select' } }
|
|
|
|
%label.custom-control-label{ for: checkbox_id }
|
|
|
|
%span.sr-only= t('posts.reorder.select')
|
|
|
|
-# Orden más alto es mayor prioridad
|
|
|
|
= hidden_field 'post[reorder]', post.post_id,
|
|
|
|
value: size - i,
|
|
|
|
data: { reorder: true }
|
2021-04-21 17:11:11 +00:00
|
|
|
%td.w-100{ class: dir }
|
2022-03-07 15:06:27 +00:00
|
|
|
= link_to site_post_path(@site, post.path) do
|
|
|
|
%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
|
2024-05-31 13:33:45 +00:00
|
|
|
= link_to @site.layouts[post.layout].humanized_name, site_posts_path(@site, **@filter_params.merge(layout: [post.layout]))
|
2022-03-07 15:06:27 +00:00
|
|
|
- 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
|
2018-04-27 20:24:28 +00:00
|
|
|
|
2024-05-31 13:58:04 +00:00
|
|
|
%td.text-nowrap
|
|
|
|
= post.created_at.strftime('%F')
|
|
|
|
%br/
|
|
|
|
= post.order
|
|
|
|
%td.text-nowrap
|
|
|
|
.d-flex.flex-row.align-items-start
|
|
|
|
- if @usuarie || policy(post).edit?
|
|
|
|
= link_to t('posts.edit_post'), edit_site_post_path(@site, post.path), class: 'btn btn-secondary'
|
|
|
|
- if @usuarie || policy(post).destroy?
|
|
|
|
= link_to t('posts.destroy'), site_post_path(@site, post.path), class: 'btn btn-secondary', method: :delete, data: { confirm: t('posts.confirm_destroy') }
|
2021-04-21 17:11:11 +00:00
|
|
|
-#
|
|
|
|
Rescatar cualquier error en un post, notificarlo e
|
|
|
|
ignorar su renderización.
|
|
|
|
- rescue ActionView::Template::Error => e
|
|
|
|
- ExceptionNotifier.notify_exception(e.cause, data: { site: @site.name, post: @post.path.absolute, usuarie: current_usuarie.id })
|
2021-05-07 20:32:54 +00:00
|
|
|
|
|
|
|
#footnotes{ hidden: true }
|
|
|
|
- @filter_params.each do |param, value|
|
|
|
|
- if param == 'layout'
|
|
|
|
- value = @site.layouts[value.to_sym].humanized_name
|
|
|
|
%label{ id: "help-filter-#{param}" }= t('posts.remove_filter_help', filter: value)
|