5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 03:06:21 +00:00

poder crear un archivo nuevo sin traducciones

This commit is contained in:
f 2018-02-26 15:58:56 -03:00
parent 11bb3273aa
commit adfe01e11f
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
3 changed files with 7 additions and 4 deletions

View file

@ -17,13 +17,13 @@ class PostsController < ApplicationController
def new def new
@lang = find_lang @lang = find_lang
@site = find_site @site = find_site
@post = Post.new(site: @site, front_matter: { date: Time.now }) @post = Post.new(site: @site, front_matter: { date: Time.now }, lang: @lang)
end end
def create def create
@lang = find_lang @lang = find_lang
@site = find_site @site = find_site
@post = Post.new(site: @site, front_matter: post_params.to_hash) @post = Post.new(site: @site, front_matter: post_params.to_hash, lang: @lang)
if @post.save if @post.save
redirect_to site_posts_path(@site, lang: @lang) redirect_to site_posts_path(@site, lang: @lang)

View file

@ -81,7 +81,10 @@ class Post
end end
def find_translations def find_translations
get_front_matter('lang').map do |lang, id| slugs = get_front_matter('lang')
return [] unless slugs.present?
slugs.map do |lang, id|
next if lang == @lang next if lang == @lang
@site.posts_for(lang).find do |p| @site.posts_for(lang).find do |p|
p.id == id p.id == id

View file

@ -121,7 +121,7 @@
= label_tag 'post_lang', t("posts.lang.#{lang}") = label_tag 'post_lang', t("posts.lang.#{lang}")
= select_tag "post[lang][#{lang}]", = select_tag "post[lang][#{lang}]",
options_for_select(@site.posts_for(lang).map { |p| [p.title, p.id] }, options_for_select(@site.posts_for(lang).map { |p| [p.title, p.id] },
@post.get_front_matter(:lang).dig(lang)), @post.get_front_matter(:lang).try(:dig, lang)),
{ class: 'form-control select2' } { class: 'form-control select2' }
%small.text-muted.form-text= t('posts.lang_help') %small.text-muted.form-text= t('posts.lang_help')
.form-group .form-group