From 6132d5f7cda9432ed4f3ad056a5de57dadbbba6b Mon Sep 17 00:00:00 2001 From: f Date: Tue, 19 Jun 2018 14:45:04 -0300 Subject: [PATCH] puede haber datos privados --- app/models/post/template_field.rb | 14 ++++++++++++++ app/views/posts/_form.haml | 2 ++ config/locales/en.yml | 1 + config/locales/es.yml | 1 + 4 files changed, 18 insertions(+) diff --git a/app/models/post/template_field.rb b/app/models/post/template_field.rb index 890d8c2..b11f31c 100644 --- a/app/models/post/template_field.rb +++ b/app/models/post/template_field.rb @@ -107,6 +107,20 @@ class Post contents.fetch('open', value.count < 2) end + # Determina si los valores del campo serán públicos después + # + # XXX Esto es solo una indicación, el theme Jekyll tiene que + # respetarlos por su lado luego + def public? + # Todos los campos son públicos a menos que se indique lo + # contrario + simple? || contents.fetch('public', true) + end + + def private? + !public? + end + def human h = key.humanize h = h + ' *' if required? diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index de6097d..7e2b00d 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -79,6 +79,8 @@ - next unless type = template.type .form-group = label_tag "post_#{template}", template.help.present? ? template.help : template.human + - if template.private? + %small.text-muted.form-text.pull-right= t('posts.private') - name = "post[#{template}]" - value = @post.new? ? template.values : @post.get_front_matter(template) - case type diff --git a/config/locales/en.yml b/config/locales/en.yml index 0a28441..d9b9573 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -204,5 +204,6 @@ en: date: 'Post needs a valid date' invalid: 'This field is required!' open: 'Tip: You can add new options by typing them and pressing Enter' + private: 'The values of this field will remain private' select: placeholder: 'Type to filter available options' diff --git a/config/locales/es.yml b/config/locales/es.yml index cc46cdc..a82e940 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -200,5 +200,6 @@ es: date: 'Necesita una fecha' invalid: '¡Este campo es obligatorio!' open: 'Nota: Puedes agregar más opciones a medida que las escribes y presionas Entrar' + private: 'Los valores de este campo serán privados' select: placeholder: 'Empieza a escribir para filtrar las opciones disponibles'