5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-25 20:46:21 +00:00
panel/app/views/posts/index.haml

135 lines
6.4 KiB
Text
Raw Permalink Normal View History

%main.row
2019-11-14 17:46:59 +00:00
%aside.menu.col-md-3
2023-04-21 15:31:46 +00:00
= render 'sites/header', site: @site
2023-04-21 15:40:36 +00:00
= render 'sites/status', site: @site
2018-01-29 22:19:10 +00:00
2023-04-13 17:27:51 +00:00
= render 'sites/build', site: @site, class: 'btn-block'
2018-01-29 22:19:10 +00:00
%h3= t('posts.new')
%table.table.table-sm.mb-3
%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
2022-07-15 17:17:46 +00:00
- if policy(@site_stat).index?
= link_to t('stats.index.title'), site_stats_path(@site), class: 'btn'
- if policy(@site).edit?
= link_to t('sites.edit.btn', site: @site.title), edit_site_path(@site), class: 'btn'
- if policy(@site).private?
= link_to t('sites.private'), '../private/' + @site.name, class: 'btn', target: '_blank', rel: 'noopener'
- 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)
- if @site.design.credits
2023-03-28 21:52:42 +00:00
= render 'bootstrap/alert' do
= 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'
%section.col
.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 }
- @filter_params.each do |param, value|
- next if param == 'q'
%input{ type: 'hidden', name: param, value: value }
.form-group.flex-grow-0.m-0
%label.sr-only{for: 'q'}= t('.search')
2023-04-17 20:59:35 +00:00
%input#q.form-control.border.border-magenta{ type: 'search', placeholder: t('.search'), name: 'q', value: @filter_params[:q] }
%input.sr-only{ type: 'submit' }
- if @site.locales.size > 1
%nav#locales
- @site.locales.each do |locale|
= link_to @site.data.dig(locale.to_s, 'locale') || locale, site_posts_path(@site, **@filter_params.merge(locale: locale)),
class: "mr-2 mt-2 mb-2 #{locale == @locale ? 'active font-weight-bold' : ''}"
.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
×
- if @posts.empty?
%h2= t('posts.empty')
- else
= form_tag site_posts_reorder_path, method: :post do
%input{ type: 'hidden', name: 'post[lang]', value: @locale }
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.sticky-top
%th.border-0{ 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
%tbody
2022-03-02 17:01:17 +00:00
- dir = @site.data.dig(params[:locale], 'dir')
- size = @posts.size
- @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.
- cache_if @usuarie, [post, I18n.locale] do
2022-08-24 21:00:18 +00:00
- checkbox_id = "checkbox-#{post.post_id}"
%tr{ id: post.post_id, data: { target: 'reorder.row' } }
2020-05-11 20:28:38 +00:00
%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')
2020-05-11 20:28:38 +00:00
-# Orden más alto es mayor prioridad
2022-08-24 21:00:18 +00:00
= hidden_field 'post[reorder]', post.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 }
= 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')
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
= post.created_at.strftime('%F')
2020-05-11 20:28:38 +00:00
%br/
= 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?
= 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?
= link_to t('posts.destroy'), site_post_path(@site, post.path), class: 'btn btn-block', method: :delete, data: { confirm: t('posts.confirm_destroy') }
#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)