5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 02:11:42 +00:00

usar los datos de la coleccion del post no del idioma por defecto

This commit is contained in:
f 2018-02-27 20:32:10 -03:00
parent 84fb6d0b67
commit d7fa03a65e
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
2 changed files with 15 additions and 14 deletions

View file

@ -101,16 +101,17 @@ class Site
end
end
def categories
everything_of :categories
def categories(lang: nil)
everything_of :categories, lang: lang
end
def tags
everything_of :tags
def tags(lang: nil)
everything_of :tags, lang: lang
end
def everything_of(attr)
posts.map do |p|
def everything_of(attr, lang: nil)
collection = lang || 'posts'
posts_for(collection).map do |p|
p.get_front_matter attr
end.flatten.uniq
end

View file

@ -42,12 +42,12 @@
= render 'layouts/help', help: t('help.autocomplete_html')
= label_tag 'post_categories', t('posts.categories')
= select_tag 'post[categories][]',
options_for_select(@site.categories, @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, @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')
@ -67,7 +67,7 @@
.form-group
= label_tag 'post_layout', t('posts.layout')
= select_tag 'post[layout]',
options_for_select(@site.everything_of(:layout), @post.get_front_matter(:layout)),
options_for_select(@site.everything_of(:layout, lang: @lang), @post.get_front_matter(:layout)),
{ class: 'form-control select2' }
%small.text-muted.form-text= t('posts.layout_help')
.form-group
@ -88,31 +88,31 @@
.form-group
= label_tag 'post_habilidades', t('posts.habilidades')
= select_tag 'post[habilidades]',
options_for_select(@site.everything_of(:habilidades), @post.get_front_matter(: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), @post.get_front_matter(: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), @post.get_front_matter(: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), @post.get_front_matter(: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), @post.get_front_matter(: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')
- I18n.available_locales.map(&:to_s).each do |lang|