diff --git a/app/models/site.rb b/app/models/site.rb index a58d776..2a1d9b3 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -45,6 +45,10 @@ class Site end end + def layouts + @layouts ||= @jekyll.layouts.keys.sort + end + # Obtener el nombre del sitio def name @name ||= @jekyll.config['source'].split('/').last diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index 543b05d..9cd442b 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -54,11 +54,6 @@ = text_field 'post', 'slug', value: @post.slug, class: 'form-control' %small.text-muted.form-text= t('posts.slug_help') - .form-group - = label_tag 'post_cover', t('posts.cover') - = text_field 'post', 'cover', value: @post.get_front_matter(:cover), - class: 'form-control' - %small.text-muted.form-text= t('posts.cover_help') .form-group = label_tag 'post_permalink', t('posts.permalink') = text_field 'post', 'permalink', value: @post.get_front_matter(:permalink), @@ -67,54 +62,9 @@ .form-group = label_tag 'post_layout', t('posts.layout') = select_tag 'post[layout]', - options_for_select(@site.everything_of(:layout, lang: @lang), @post.get_front_matter(:layout)), + options_for_select(@site.layouts, @post.get_front_matter(:layout)), { class: 'form-control select2' } %small.text-muted.form-text= t('posts.layout_help') - .form-group - = label_tag 'post_objetivos', t('posts.objetivos') - = text_area 'post', 'objetivos', value: @post.get_front_matter(:objetivos), - class: field_class - %small.text-muted.form-text= t('posts.objetivos_help') - .form-group - = label_tag 'post_recomendaciones', t('posts.recomendaciones') - = text_area 'post', 'recomendaciones', value: @post.get_front_matter(:recomendaciones), - class: field_class - %small.text-muted.form-text= t('posts.recomendaciones_help') - .form-group - = label_tag 'post_duracion', t('posts.duracion') - = text_field 'post', 'duracion', value: @post.get_front_matter(:duracion), - class: 'form-control' - %small.text-muted.form-text= t('posts.duracion_help') - .form-group - = label_tag 'post_habilidades', t('posts.habilidades') - = select_tag 'post[habilidades]', - options_for_select(@site.everything_of(:habilidades, lang: @lang), @post.get_front_matter(:habilidades)), - { class: 'form-control select2' } - %small.text-muted.form-text= t('posts.habilidades_help') - .form-group - = label_tag 'post_formato', t('posts.formato') - = select_tag 'post[formato]', - options_for_select(@site.everything_of(:formato, lang: @lang), @post.get_front_matter(:formato)), - { class: 'form-control select2' } - %small.text-muted.form-text= t('posts.formato_help') - .form-group - = label_tag 'post_conocimientos', t('posts.conocimientos') - = select_tag 'post[conocimientos][]', - options_for_select(@site.everything_of(:conocimientos, lang: @lang), @post.get_front_matter(:conocimientos)), - { class: 'form-control select2', multiple: 'multiple' } - %small.text-muted.form-text= t('posts.conocimientos_help') - .form-group - = label_tag 'post_sesiones_ejercicios_relacionados', t('posts.sesiones_ejercicios_relacionados') - = select_tag 'post[sesiones_ejercicios_relacionados][]', - options_for_select(@site.everything_of(:title, lang: @lang), @post.get_front_matter(:sesiones_ejercicios_relacionados)), - { class: 'form-control select2', multiple: 'multiple' } - %small.text-muted.form-text= t('posts.sesiones_ejercicios_relacionados_help') - .form-group - = label_tag 'post_materiales_requeridos', t('posts.materiales_requeridos') - = select_tag 'post[materiales_requeridos][]', - options_for_select(@site.everything_of(:materiales_requeridos, lang: @lang), @post.get_front_matter(:materiales_requeridos)), - { class: 'form-control select2', multiple: 'multiple' } - %small.text-muted.form-text= t('posts.materiales_requeridos_help') - if @site.i18n? - @site.translations.each do |lang| - next if lang == @lang diff --git a/test/models/site_test.rb b/test/models/site_test.rb index 49155d2..52deb29 100644 --- a/test/models/site_test.rb +++ b/test/models/site_test.rb @@ -63,4 +63,19 @@ class SiteTest < ActiveSupport::TestCase assert_equal v, @site.posts[k].order end end + + test 'Un sitio tiene traducciones' do + assert_equal %w[ar es en], @site.translations + assert @site.i18n? + end + + test 'El idioma por defecto es el idioma actual de la plataforma' do + assert_equal 'es', @site.default_lang + end + + test 'El sitio tiene layouts' do + assert_equal %w[anexo archive default feed header.ar header.en + header.es header license.ar license.en license.es license pandoc + politicas sesion simple style ].sort, @site.layouts + end end