From ff249605103dcd5035756c5beb7ca5433e96f8ea Mon Sep 17 00:00:00 2001 From: f Date: Sat, 10 Feb 2018 13:09:42 -0300 Subject: [PATCH] tener en cuenta la direccion del texto --- app/assets/stylesheets/application.scss | 5 +++++ app/controllers/posts_controller.rb | 2 +- app/views/posts/_form.haml | 13 ++++++++++--- app/views/posts/show.haml | 4 ++-- config/locales/en.yml | 5 ++++- config/locales/es.yml | 5 ++++- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index eaabf483..806a39d8 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -48,3 +48,8 @@ textarea.post-content { font-family: monospace; font-size: 90%; } + +.rtl { + direction: rtl; + text-align: right; +} diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 69a72da5..56cb2142 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -50,7 +50,7 @@ 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, + :cover, :layout, :permalink, :objetivos, :dir, :duracion, :formato, :habilidades, :recomendaciones, conocimientos: [], sesiones_ejercicios_relacionados: [], materiales_requeridos: [], lang: {}, diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index 8bbf714a..243e06df 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -4,6 +4,8 @@ - @post.errors.each do |_,error| %li= error +-# string para configurar la clase con direccion de texto +- field_class = "form-control #{@post.get_front_matter(:dir)}" -# TODO habilitar form_for - if @post.new? - url = site_posts_path(@site) @@ -15,11 +17,11 @@ .form-group = submit_tag t('posts.save'), class: 'btn btn-success' .form-group - = text_field 'post', 'title', value: @post.title, class: 'form-control', + = text_field 'post', 'title', value: @post.title, class: field_class, placeholder: t('posts.title') - .form-group + .form-group{class: @post.get_front_matter(:dir)} = text_area_tag 'post[content]', @post.content, autofocus: true, - class: 'form-control post-content', data: { provide: 'markdown' }, + class: 'post-content', data: { provide: 'markdown' }, cols: 72, wrap: 'hard' .form-group = label_tag 'post_date', t('posts.date') @@ -110,6 +112,11 @@ = text_field 'post', "lang[#{lang}]", value: @post.get_front_matter(:lang).dig(lang), class: 'form-control' %small.text-muted.form-text= t('posts.lang_help') + .form-group + = label_tag 'post_dir', t('posts.dir') + = select_tag 'post[dir]', + options_for_select([[t('posts.ltr'), 'ltr'], [t('posts.rtl'), 'rtl']]), + { class: 'form-control' } .form-group = submit_tag t('posts.save'), class: 'btn btn-success' diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index 15aa853b..165df242 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -9,7 +9,7 @@ .row .col - %h1= @post.title + %h1{class: @post.get_front_matter(:dir)}= @post.title .row .col @@ -18,7 +18,7 @@ .row .col - .content + .content{class: @post.get_front_matter(:dir)} :markdown #{@post.content} diff --git a/config/locales/en.yml b/config/locales/en.yml index d5687f63..26c115c8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -54,10 +54,13 @@ en: materiales_requeridos: 'Needed materials' materiales_requeridos_help: 'Select all materials needed for this session' lang: - es: 'Slug for Spanish' + es: 'Slug for Castillian Spanish' en: 'Slug for English' ar: 'Slug for Arabic' lang_help: 'Complete this field with the slug for the post in another language to associate them' + rtl: 'Right to left' + ltr: 'Left to right' + dir: 'Text direction' logger: rm: 'Removed %{path}' errors: diff --git a/config/locales/es.yml b/config/locales/es.yml index 54d583e9..fc10257d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -52,10 +52,13 @@ es: duracion: 'Duración' duracion_help: '¿Cuánto dura la sesión?' lang: - es: 'Slug castellano' + es: 'Slug en castellano' en: 'Slug en inglés' ar: 'Slug en árabe' lang_help: 'El mismo artículo en otro idioma, completa con su slug para poder saltar de uno a otro' + rtl: 'Derecha a izquierda' + ltr: 'Izquierda a derecha' + dir: 'Dirección del texto' logger: rm: 'Eliminado %{path}' errors: