- unless @post.errors.empty? .alert.alert-danger %ul - @post.errors.each do |_,error| %li= error -# TODO seleccionar la dirección por defecto según el idioma actual - direction = @post.get_front_matter(:dir) || 'ltr' -# string para configurar la clase con direccion de texto - field_class = "form-control #{direction}" -# TODO habilitar form_for - if @post.new? - url = site_posts_path(@site, lang: @lang) - method = :post - else - url = site_post_path(@site, @post, lang: @lang) - method = :patch = form_tag url, method: method, class: 'form', novalidate: true do .form-group = submit_tag t('posts.save'), class: 'btn btn-success' .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') .form-group = label_tag 'post_title', t('posts.title') = text_field 'post', 'title', value: @post.title, class: field_class .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' .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') .form-group = render 'layouts/help', help: t('help.autocomplete_html') = 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' } .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' } .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') .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') .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') - 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] }, @post.get_front_matter(:lang).try(:dig, lang)), { class: 'form-control select2' } %small.text-muted.form-text= t('posts.lang_help') - @post.template_fields.each do |template| - next unless type = template.type .form-group = label_tag "post_#{template}", template.to_s.humanize - name = "post[#{template}]" - value = @post.new? ? template.values : @post.get_front_matter(template) - case type - when 'text' = text_field 'post', template, value: value, class: 'form-control', required: template.required? - when 'text_area' = text_area_tag name, value, class: 'form-control', required: template.required? - when 'check_box' = hidden_field 'post', template, value: 'false' = check_box_tag name, 'true', value == 'true', class: 'form-control' - when 'select' = select_tag name, options_for_select(template.values, @post.get_front_matter(template)), { class: 'form-control select2', multiple: template.multiple?, data: { tags: template.open?, placeholder: t('posts.select.placeholder')}} - if template.open? %small.text-muted.form-text= t('posts.open') .invalid-feedback= t('posts.invalid') .form-group = submit_tag t('posts.save'), class: 'btn btn-success', id: 'submit-post'