2019-09-04 16:50:27 +00:00
|
|
|
= render 'layouts/breadcrumb',
|
2019-09-12 16:57:25 +00:00
|
|
|
crumbs: [link_to(t('sites.index.title'), sites_path),
|
2019-09-04 16:50:27 +00:00
|
|
|
@site.name,
|
|
|
|
link_to(t('posts.index'),
|
|
|
|
site_posts_path(@site)),
|
2020-09-25 17:07:54 +00:00
|
|
|
@category_name]
|
2019-09-04 16:50:27 +00:00
|
|
|
|
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')
|
|
|
|
%ul
|
|
|
|
- @site.layouts.to_h.keys.each do |layout|
|
|
|
|
%li= link_to @site.i18n.dig('layouts', layout.to_s) || layout.to_s.humanize,
|
|
|
|
new_site_post_path(@site, layout: layout)
|
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
|
|
|
|
|
|
|
= 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'
|
2019-12-11 20:05:31 +00:00
|
|
|
- if @posts.empty?
|
|
|
|
%h2= t('posts.none')
|
|
|
|
- else
|
|
|
|
= form_tag site_posts_reorder_path, method: :post do
|
2020-05-23 15:38:03 +00:00
|
|
|
.d-flex.justify-content-between.align-items-center
|
|
|
|
-#
|
|
|
|
TODO: Pensar una interfaz mejor para cuando haya más de tres
|
|
|
|
idiomas
|
2020-05-26 19:47:16 +00:00
|
|
|
- unless @site.locales.length == 1
|
|
|
|
.locales
|
|
|
|
- @site.locales.each do |locale|
|
|
|
|
= link_to t("locales.#{locale}.name"), site_posts_path(@site, locale: locale),
|
|
|
|
class: "mr-2 mt-2 mb-2#{locale == @locale ? 'active font-weight-bold' : ''}"
|
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
|
|
|
|
%th.border-0.background-white.position-sticky{ style: 'top: 0', colspan: '4' }
|
|
|
|
= submit_tag t('posts.reorder.submit'), class: 'btn'
|
2020-11-19 20:53:11 +00:00
|
|
|
%button.btn{ data: { target: 'reorder.unselect' } }
|
|
|
|
= t('posts.reorder.unselect')
|
|
|
|
%span.badge{ data: { target: 'reorder.counter' } } 0
|
2020-11-19 20:44:13 +00:00
|
|
|
%button.btn{ data: { target: 'reorder.direction', direction: 'up' } }= t('posts.reorder.up')
|
|
|
|
%button.btn{ data: { target: 'reorder.direction', direction: 'down' } }= t('posts.reorder.down')
|
|
|
|
%button.btn{ data: { target: 'reorder.top' } }= t('posts.reorder.top')
|
|
|
|
%button.btn{ data: { target: 'reorder.bottom' } }= t('posts.reorder.bottom')
|
2019-12-11 20:05:31 +00:00
|
|
|
%tbody
|
2020-05-23 18:42:12 +00:00
|
|
|
- dir = t("locales.#{@locale}.dir")
|
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.
|
2020-05-12 13:13:38 +00:00
|
|
|
- cache_if @usuarie, post do
|
2020-11-19 20:44:13 +00:00
|
|
|
%tr{ id: post.uuid.value, data: { target: 'reorder.row' } }
|
2020-05-11 20:28:38 +00:00
|
|
|
%td
|
2020-11-19 20:44:13 +00:00
|
|
|
%input{ type: 'checkbox', autocomplete: 'off', data: { reorder: { handler: true } } }
|
2020-05-11 20:28:38 +00:00
|
|
|
-# Orden más alto es mayor prioridad
|
|
|
|
= hidden_field 'post[reorder]', post.uuid.value,
|
2020-11-19 20:44:13 +00:00
|
|
|
value: @posts.length - i,
|
|
|
|
data: { reorder: true }
|
2020-06-25 19:53:55 +00:00
|
|
|
%td.w-100{ class: dir }
|
2020-05-11 20:28:38 +00:00
|
|
|
%small
|
|
|
|
= link_to @site.i18n.dig('layouts', post.layout.name.to_s) || post.layout.name.to_s.humanize,
|
|
|
|
site_posts_path(@site, layout: post.layout.name)
|
|
|
|
%br/
|
2020-05-23 18:42:12 +00:00
|
|
|
= link_to site_post_path(@site, post.id) do
|
|
|
|
%span{ lang: post.lang.value, dir: dir }= post.title.value
|
2020-05-11 20:28:38 +00:00
|
|
|
- if post.attributes.include? :draft
|
|
|
|
- if post.draft.value
|
|
|
|
%span.badge.badge-primary
|
|
|
|
= post_label_t(:draft, post: post)
|
|
|
|
- if post.attributes.include? :categories
|
|
|
|
- unless post.categories.value.empty?
|
|
|
|
%br
|
|
|
|
%small
|
2020-09-25 17:07:54 +00:00
|
|
|
- (post.categories.respond_to?(:belongs_to) ? post.categories.belongs_to : post.categories.value).each do |c|
|
|
|
|
= link_to site_posts_path(@site, category: (c.respond_to?(:uuid) ? c.uuid.value : c)) do
|
|
|
|
%span{ lang: post.lang.value, dir: dir }= (c.respond_to?(:title) ? c.title.value : c)
|
2018-04-27 20:24:28 +00:00
|
|
|
|
2020-05-11 20:28:38 +00:00
|
|
|
%td
|
|
|
|
= post.date.value.strftime('%F')
|
|
|
|
%br/
|
2020-10-06 19:35:50 +00:00
|
|
|
- if post.attribute? :order
|
|
|
|
= post.order.value
|
2020-05-11 20:28:38 +00:00
|
|
|
%td
|
|
|
|
- if @usuarie || policy(post).edit?
|
|
|
|
= link_to t('posts.edit'),
|
|
|
|
edit_site_post_path(@site, post.id),
|
2020-06-25 19:53:55 +00:00
|
|
|
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.id),
|
2020-06-25 19:53:55 +00:00
|
|
|
class: 'btn btn-block',
|
2020-05-11 20:28:38 +00:00
|
|
|
method: :delete,
|
|
|
|
data: { confirm: t('posts.confirm_destroy') }
|