5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-02 12:56:07 +00:00

editar el frontmatter de cyberwomen

This commit is contained in:
f 2018-02-08 11:05:05 -03:00
parent a95bb4be97
commit 62a74befdc
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
7 changed files with 106 additions and 7 deletions

View file

@ -50,6 +50,10 @@ class PostsController < ApplicationController
# Solo permitir cambiar estos atributos de cada articulo
def post_params
params.require(:post).permit(:title, :date, :content, :slug,
:cover, :layout, :permalink, :objetivos,
:duracion, :formato, :habilidades,
conocimientos: [], sesiones_ejercicios_relacionados: [],
materiales_requeridos: [], lang: [],
tags: [], categories: [])
end
end

View file

@ -149,6 +149,11 @@ class Post
@post <=> other.post
end
# Obtiene metadatos asegurándose que siempre trabajamos con strings
def get_front_matter(name)
@front_matter.dig(name.to_s)
end
private
# Genera un post nuevo y lo agrega a la colección del sitio.
@ -168,11 +173,6 @@ class Post
@site.posts.sort!
end
# Obtiene metadatos asegurándose que siempre trabajamos con strings
def get_front_matter(name)
@front_matter.dig(name.to_s)
end
# Los define, asegurandose que las llaves siempre son strings, para no
# tener incompatibilidades con jekyll
def set_front_matter(name, value)

View file

@ -42,11 +42,17 @@ class Site
end
def categories
posts.map(&:categories).flatten.uniq
everything_of :categories
end
def tags
posts.map(&:tags).flatten.uniq
everything_of :tags
end
def everything_of(attr)
posts.map do |p|
p.get_front_matter attr
end.flatten.uniq
end
# El directorio donde se almacenan los sitios

View file

@ -43,6 +43,57 @@
= 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),
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.everything_of(:layout), @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: 'form-control'
%small.text-muted.form-text= t('posts.objetivos_help')
.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)),
{ 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)),
{ 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)),
{ 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)),
{ 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)),
{ class: 'form-control select2', multiple: 'multiple' }
%small.text-muted.form-text= t('posts.materiales_requeridos_help')
:javascript
$(document).on('turbolinks:load', function() {

View file

@ -66,6 +66,8 @@ Rails.application.configure do
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
config.i18n.default_locale = :es
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify

View file

@ -23,6 +23,24 @@ en:
categories_help: 'Comma separated!'
slug: 'Slug'
slug_help: 'This is the name of the article on the URL, ie. /title/. You can leave it empty.'
cover: 'Cover'
cover_help: 'Path to the cover'
layout: 'Layout'
layout_help: 'The layout of this post'
objetivos: 'Objectives'
objetivos_help: 'Objectives of this session'
permalink: 'Permanent link'
permalink_help: "If you want to access the post from a specific URL, use this field. Don\'t forget to start with a /"
habilidades: 'Skill level'
habilidades_help: 'Skills required for this session'
formato: 'Format'
formato_help: 'Format of this session'
conocimientos: 'Required knowledge'
conocimientos_help: 'Select all required knowledge for this session'
sesiones_ejercicios_relacionados: 'Related sessions/exercises'
sesiones_ejercicios_relacionados_help: 'Select all related sessions/exercises'
materiales_requeridos: 'Needed materials'
materiales_requeridos_help: 'Select all materials needed for this session'
logger:
rm: 'Removed %{path}'
errors:

View file

@ -21,6 +21,24 @@ es:
categories_help: '¡Separadas por comas!'
slug: 'Nombre la URL'
slug_help: 'Esto es el nombre del artículo en la URL, por ejemplo /título/. Puedes dejarlo vacío.'
cover: 'Portada'
cover_help: 'La dirección de la portada'
layout: 'Plantilla'
layout_help: 'El tipo de plantilla'
objetivos: 'Objetivos'
objetivos_help: 'Objetivos de esta sesión'
permalink: 'Dirección del enlace'
permalink_help: 'Si quieres que el artículo se acceda desde esta URL completa aquí, no te olvides de empezar con /'
habilidades: 'Habilidades'
habilidades_help: 'Habilidades requeridas para esta sesión'
formato: 'Formato'
formato_help: 'Formato de esta sesión'
conocimientos: 'Conocimientos'
conocimientos_help: 'Elige todos los conocimientos requeridos para abordar esta sesión'
sesiones_ejercicios_relacionados: 'Sesiones y ejercicios relacionados'
sesiones_ejercicios_relacionados_help: 'Elige todas las sesiones relacionadas con esta'
materiales_requeridos: 'Materiales requeridos'
materiales_requeridos_help: 'Materiales necesarios para esta sesión'
logger:
rm: 'Eliminado %{path}'
errors: