2018-02-02 22:20:31 +00:00
|
|
|
- unless @post.errors.empty?
|
|
|
|
.alert.alert-danger
|
|
|
|
%ul
|
2018-10-31 21:55:50 +00:00
|
|
|
- @post.errors.each do |key, error|
|
|
|
|
%li
|
|
|
|
%strong= @post.template_fields.find { |tf| tf.key == key.to_s }.try(:label) || key
|
|
|
|
= [error].flatten.join("\n")
|
2018-02-02 22:20:31 +00:00
|
|
|
|
2018-02-10 23:45:11 +00:00
|
|
|
-# TODO seleccionar la dirección por defecto según el idioma actual
|
2018-07-20 16:41:59 +00:00
|
|
|
- direction = @post.get_front_matter('dir') || 'ltr'
|
2018-02-10 16:09:42 +00:00
|
|
|
-# string para configurar la clase con direccion de texto
|
2018-02-10 23:45:11 +00:00
|
|
|
- field_class = "form-control #{direction}"
|
2018-02-03 22:37:09 +00:00
|
|
|
-# TODO habilitar form_for
|
|
|
|
- if @post.new?
|
2018-02-23 19:20:51 +00:00
|
|
|
- url = site_posts_path(@site, lang: @lang)
|
2018-02-03 22:37:09 +00:00
|
|
|
- method = :post
|
|
|
|
- else
|
2018-02-23 19:20:51 +00:00
|
|
|
- url = site_post_path(@site, @post, lang: @lang)
|
2018-02-03 22:37:09 +00:00
|
|
|
- method = :patch
|
2018-12-11 17:20:13 +00:00
|
|
|
- if pre = @post.template.get_front_matter('pre')
|
|
|
|
= render 'layouts/help', help: CommonMarker.render_doc(pre).to_html
|
2018-07-02 20:45:32 +00:00
|
|
|
= form_tag url, method: method, class: 'form', novalidate: true, multipart: true do
|
2018-06-21 17:35:14 +00:00
|
|
|
= hidden_field_tag 'template', params[:template]
|
2018-01-31 20:29:27 +00:00
|
|
|
.form-group
|
2018-07-23 14:26:40 +00:00
|
|
|
= submit_tag t('posts.save'), class: 'btn btn-success submit-post'
|
2018-12-14 13:32:35 +00:00
|
|
|
.invalid_help.alert.alert-danger.d-none= @site.config.dig('invalid_help') || t('posts.invalid_help')
|
2018-12-14 13:38:50 +00:00
|
|
|
.sending_help.alert.alert-success.d-none= @site.config.dig('sending_help') || t('posts.sending_help')
|
2018-09-28 17:35:40 +00:00
|
|
|
- if current_user.is_a? Usuaria
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_author', t('posts.author')
|
2018-10-20 12:25:03 +00:00
|
|
|
- todxs = (@site.usuarias + @site.invitadxs).compact.uniq.map(&:username)
|
2018-09-28 17:35:40 +00:00
|
|
|
= select_tag 'post[author]',
|
2018-09-28 18:10:10 +00:00
|
|
|
options_for_select(todxs, @post.author || current_user.email),
|
2018-09-28 17:35:40 +00:00
|
|
|
{ class: 'form-control select2',
|
|
|
|
data: { tags: true,
|
|
|
|
placeholder: t('posts.select.placeholder'),
|
|
|
|
'allow-clear': true } }
|
|
|
|
%small.text-muted.form-text= t('posts.author_help')
|
2018-07-24 18:43:30 +00:00
|
|
|
- if @post.has_field? :dir
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_dir', t('posts.dir')
|
|
|
|
= select_tag 'post[dir]',
|
|
|
|
options_for_select([[t('posts.ltr'), 'ltr'], [t('posts.rtl'), 'rtl']], direction),
|
|
|
|
{ class: 'form-control' }
|
|
|
|
%small.text-muted.form-text= t('posts.dir_help')
|
2018-01-31 20:29:27 +00:00
|
|
|
.form-group
|
2018-02-25 01:10:37 +00:00
|
|
|
= label_tag 'post_title', t('posts.title')
|
2018-06-22 17:52:35 +00:00
|
|
|
= text_field 'post', 'title', value: @post.title, class: field_class, required: true
|
2018-06-25 20:44:47 +00:00
|
|
|
- if @post.content?
|
|
|
|
.form-group{class: direction}
|
|
|
|
= render 'layouts/help', help: [ t('help.markdown.intro'),
|
|
|
|
t('help.distraction_free_html'),
|
|
|
|
t('help.preview_html') ]
|
|
|
|
= text_area_tag 'post[content]', @post.content, autofocus: true,
|
|
|
|
class: 'post-content'
|
2018-07-23 19:48:34 +00:00
|
|
|
- if @post.has_field? :date
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_date', t('posts.date')
|
|
|
|
= date_field 'post', 'date', value: @post.date.try(:strftime, '%F'),
|
|
|
|
class: 'form-control'
|
|
|
|
%small.text-muted.form-text= t('posts.date_help')
|
|
|
|
= render 'layouts/help', help: t('help.autocomplete_html')
|
|
|
|
- if @post.has_field? :categories
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_categories', t('posts.categories')
|
|
|
|
= select_tag 'post[categories][]',
|
|
|
|
options_for_select(@site.categories(lang: @lang), @post.categories),
|
|
|
|
{ class: 'form-control select2', multiple: 'multiple',
|
|
|
|
data: { tags: true,
|
|
|
|
placeholder: t('posts.select.placeholder'),
|
|
|
|
'allow-clear': true } }
|
|
|
|
- if @post.has_field? :tags
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_tags', t('posts.tags')
|
|
|
|
= select_tag 'post[tags][]',
|
|
|
|
options_for_select(@site.tags(lang: @lang), @post.tags),
|
|
|
|
{ class: 'form-control select2', multiple: 'multiple',
|
|
|
|
data: { tags: true,
|
|
|
|
placeholder: t('posts.select.placeholder'),
|
|
|
|
'allow-clear': true } }
|
|
|
|
- if @post.has_field? :slug
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_slug', t('posts.slug')
|
|
|
|
= text_field 'post', 'slug', value: @post.slug,
|
|
|
|
class: 'form-control'
|
|
|
|
%small.text-muted.form-text= t('posts.slug_help')
|
|
|
|
- if @post.has_field? :permalink
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_permalink', t('posts.permalink')
|
|
|
|
= text_field 'post', 'permalink', value: @post.get_front_matter('permalink'),
|
|
|
|
class: 'form-control'
|
|
|
|
%small.text-muted.form-text= t('posts.permalink_help')
|
|
|
|
- if @post.has_field? :layout
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_layout', t('posts.layout')
|
|
|
|
= select_tag 'post[layout]',
|
|
|
|
options_for_select(@site.layouts, @post.get_front_matter('layout')),
|
|
|
|
{ class: 'form-control select2' }
|
|
|
|
%small.text-muted.form-text= t('posts.layout_help')
|
2018-05-08 21:14:00 +00:00
|
|
|
- if @site.i18n?
|
|
|
|
- @site.translations.each do |lang|
|
|
|
|
- next if lang == @lang
|
|
|
|
.form-group
|
|
|
|
= label_tag 'post_lang', t("posts.lang.#{lang}")
|
|
|
|
= select_tag "post[lang][#{lang}]",
|
|
|
|
options_for_select(@site.posts_for(lang).map { |p| [p.title, p.id] },
|
2018-07-20 16:41:59 +00:00
|
|
|
@post.get_front_matter('lang').try(:dig, lang)),
|
2018-05-08 21:14:00 +00:00
|
|
|
{ class: 'form-control select2' }
|
|
|
|
%small.text-muted.form-text= t('posts.lang_help')
|
2018-06-25 20:28:09 +00:00
|
|
|
-# Genera todos los campos de la plantilla
|
2018-05-11 20:00:45 +00:00
|
|
|
- @post.template_fields.each do |template|
|
2018-06-15 21:34:33 +00:00
|
|
|
- next unless type = template.type
|
2018-09-05 19:18:09 +00:00
|
|
|
- if template.title.present?
|
|
|
|
%h1= template.title
|
2018-07-20 18:57:14 +00:00
|
|
|
- value = @post.new? ? template.values : @post.get_front_matter(template.key)
|
2018-05-11 20:00:45 +00:00
|
|
|
.form-group
|
2018-06-19 20:38:43 +00:00
|
|
|
= label_tag "post_#{template}", id: template do
|
2018-06-22 19:06:58 +00:00
|
|
|
= link_to '#' + template.key, class: 'text-muted',
|
|
|
|
data: { turbolinks: 'false' } do
|
|
|
|
= fa_icon 'link', title: t('posts.anchor')
|
2018-06-19 17:50:53 +00:00
|
|
|
- if template.private?
|
2018-06-19 18:12:29 +00:00
|
|
|
= fa_icon 'lock', title: t('posts.private')
|
2018-07-23 19:23:53 +00:00
|
|
|
= template.label
|
|
|
|
- if template.help
|
|
|
|
%small.text-muted.form-text= template.help
|
2018-06-19 20:38:43 +00:00
|
|
|
= render "posts/template_field/#{type}", template: template, name: template.key, value: value
|
2018-06-15 22:13:18 +00:00
|
|
|
.invalid-feedback= t('posts.invalid')
|
2018-02-08 20:54:34 +00:00
|
|
|
.form-group
|
2018-07-23 14:26:40 +00:00
|
|
|
= submit_tag t('posts.save'), class: 'btn btn-success submit-post'
|
2018-12-14 13:32:35 +00:00
|
|
|
.invalid_help.alert.alert-danger.d-none= @site.config.dig('invalid_help') || t('posts.invalid_help')
|
2018-12-14 13:38:50 +00:00
|
|
|
.sending_help.alert.alert-success.d-none= @site.config.dig('sending_help') || t('posts.sending_help')
|
2018-12-11 17:20:13 +00:00
|
|
|
- if post = @post.template.get_front_matter('post')
|
|
|
|
= render 'layouts/help', help: CommonMarker.render_doc(post).to_html
|