2019-09-12 18:10:01 +00:00
|
|
|
%main.row
|
2019-11-14 17:46:59 +00:00
|
|
|
%aside.menu.col-md-3
|
2020-08-11 21:52:53 +00:00
|
|
|
%h1= link_to @site.title, @site.url
|
2020-05-30 23:50:39 +00:00
|
|
|
%p.lead= @site.description
|
2018-01-29 22:19:10 +00:00
|
|
|
|
2020-05-30 23:50:39 +00:00
|
|
|
%h3= t('posts.new')
|
2020-12-24 15:36:38 +00:00
|
|
|
%table.mb-3
|
2020-11-27 23:53:14 +00:00
|
|
|
- @site.layouts.each do |layout|
|
|
|
|
- next if layout.hidden?
|
2020-12-24 15:36:38 +00:00
|
|
|
%tr
|
|
|
|
%th= layout.humanized_name
|
2021-05-09 15:52:26 +00:00
|
|
|
%td.pl-3= link_to t('posts.add'), new_site_post_path(@site, layout: layout.value), class: 'btn btn-secondary btn-sm'
|
2021-05-07 20:54:45 +00:00
|
|
|
- if @filter_params[:layout] == layout.name.to_s
|
2021-05-07 20:31:13 +00:00
|
|
|
%td= link_to t('posts.remove_filter'), site_posts_path(@site, **@filter_params.merge(layout: nil)), class: 'btn btn-primary btn-sm'
|
2021-05-07 19:17:25 +00:00
|
|
|
- else
|
2021-05-07 20:31:13 +00:00
|
|
|
%td= link_to t('posts.filter'), site_posts_path(@site, **@filter_params.merge(layout: layout.value)), class: 'btn btn-secondary btn-sm'
|
2018-02-03 22:37:09 +00:00
|
|
|
|
2019-09-12 18:10:01 +00:00
|
|
|
- if policy(@site).edit?
|
2020-08-23 00:04:46 +00:00
|
|
|
= link_to t('sites.edit.btn', site: @site.title), edit_site_path(@site), class: 'btn'
|
|
|
|
|
|
|
|
- if policy(@site).private?
|
2020-10-30 23:40:13 +00:00
|
|
|
= link_to t('sites.private'), '../private/' + @site.name, class: 'btn', 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)
|
|
|
|
|
2019-09-12 18:10:01 +00:00
|
|
|
= render 'sites/build', site: @site
|
|
|
|
|
2020-08-11 21:52:53 +00:00
|
|
|
- if @site.design.credits
|
|
|
|
.alert.alert-primary{ role: 'alert' }
|
|
|
|
= sanitize_markdown @site.design.credits
|
|
|
|
= link_to t('sites.donations.text'), t('sites.donations.url'), class: 'btn'
|
|
|
|
- if @site.design.designer_url
|
|
|
|
= link_to t('sites.designer_url'), @site.design.designer_url, class: 'btn'
|
|
|
|
|
2019-09-12 18:10:01 +00:00
|
|
|
%section.col
|
2018-04-30 18:51:39 +00:00
|
|
|
= render 'layouts/flash'
|
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-09-16 00:03:28 +00:00
|
|
|
%form{ action: site_posts_path }
|
2021-05-07 19:17:25 +00:00
|
|
|
- @filter_params.each do |param, value|
|
|
|
|
- next if param == 'q'
|
2021-05-07 20:31:50 +00:00
|
|
|
%input{ type: 'hidden', name: param, value: value }
|
2021-05-07 19:17:25 +00:00
|
|
|
.form-group.flex-grow-0.m-0
|
2021-05-07 20:46:49 +00:00
|
|
|
%input.form-control.border.border-magenta{ type: 'search', placeholder: 'Buscar', name: 'q', value: @filter_params[:q] }
|
2021-05-07 19:17:25 +00:00
|
|
|
%input.sr-only{ type: 'submit' }
|
|
|
|
|
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|
|
|
|
|
= link_to t("locales.#{locale}.name"), site_posts_path(@site, **@filter_params.merge(locale: locale)),
|
|
|
|
class: "mr-2 mt-2 mb-2 #{locale == @locale ? 'active font-weight-bold' : ''}"
|
2021-05-07 20:32:54 +00:00
|
|
|
.pl-2-plus
|
|
|
|
- @filter_params.each do |param, value|
|
|
|
|
- if param == 'layout'
|
|
|
|
- value = @site.layouts[value.to_sym].humanized_name
|
|
|
|
= link_to site_posts_path(@site, **@filter_params.reject { |k, _| k == param }),
|
|
|
|
class: 'btn btn-secondary btn-sm',
|
|
|
|
title: t('posts.remove_filter_help', filter: value),
|
|
|
|
aria: { labelledby: "help-filter-#{param}" } do
|
|
|
|
= value
|
|
|
|
×
|
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
|
2020-11-19 20:44:13 +00:00
|
|
|
%table.table{ data: { controller: 'reorder' } }
|
2020-06-25 19:53:55 +00:00
|
|
|
%caption.sr-only= t('posts.caption')
|
2020-11-19 20:44:13 +00:00
|
|
|
%thead
|
|
|
|
%tr
|
2020-12-24 15:35:58 +00:00
|
|
|
%th.border-0.background-white.position-sticky{ style: 'top: 0; z-index: 2', colspan: '4' }
|
2021-09-16 00:03:07 +00:00
|
|
|
.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'
|
2019-12-11 20:05:31 +00:00
|
|
|
%tbody
|
2020-05-23 18:42:12 +00:00
|
|
|
- dir = t("locales.#{@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-05-10 17:27:47 +00:00
|
|
|
- cache_if @usuarie, [post, I18n.locale] do
|
2021-05-07 19:17:25 +00:00
|
|
|
- checkbox_id = "checkbox-#{post.id}"
|
|
|
|
%tr{ id: post.id, data: { target: 'reorder.row' } }
|
2020-05-11 20:28:38 +00:00
|
|
|
%td
|
2020-12-24 15:35:58 +00:00
|
|
|
.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')
|
2020-05-11 20:28:38 +00:00
|
|
|
-# Orden más alto es mayor prioridad
|
2021-05-07 19:17:25 +00:00
|
|
|
= hidden_field 'post[reorder]', post.id,
|
|
|
|
value: size - i,
|
2020-11-19 20:44:13 +00:00
|
|
|
data: { reorder: true }
|
2020-06-25 19:53:55 +00:00
|
|
|
%td.w-100{ class: dir }
|
2021-05-07 19:17:25 +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?
|
2021-05-17 18:58:37 +00:00
|
|
|
%span.badge.badge-primary= I18n.t('posts.attributes.draft.label')
|
2021-09-16 00:00:48 +00:00
|
|
|
%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
|
2018-04-27 20:24:28 +00:00
|
|
|
|
2021-09-16 00:00:10 +00:00
|
|
|
%td.text-nowrap
|
2021-05-07 19:17:25 +00:00
|
|
|
= post.created_at.strftime('%F')
|
2020-05-11 20:28:38 +00:00
|
|
|
%br/
|
2021-05-07 19:17:25 +00:00
|
|
|
= post.order
|
2021-09-16 00:00:10 +00:00
|
|
|
%td.text-nowrap
|
2020-05-11 20:28:38 +00:00
|
|
|
- if @usuarie || policy(post).edit?
|
2021-05-07 19:17:25 +00:00
|
|
|
= link_to t('posts.edit'), edit_site_post_path(@site, post.path), class: 'btn btn-block'
|
2020-05-11 20:28:38 +00:00
|
|
|
- if @usuarie || policy(post).destroy?
|
2021-05-07 19:17:25 +00:00
|
|
|
= link_to t('posts.destroy'), site_post_path(@site, post.path), class: 'btn btn-block', method: :delete, data: { confirm: t('posts.confirm_destroy') }
|
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)
|