5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 20:46:22 +00:00

parsear la fecha / mostrar mensajes

This commit is contained in:
f 2017-10-10 11:52:27 -03:00
parent 9573776b61
commit bfe781ff87
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
4 changed files with 17 additions and 5 deletions

View file

@ -51,18 +51,20 @@ module Sutty
tags: params[:post][:tags].split(',').map(&:strip), tags: params[:post][:tags].split(',').map(&:strip),
categories: params[:post][:categories].split(',').map(&:strip), categories: params[:post][:categories].split(',').map(&:strip),
title: params[:post][:title], title: params[:post][:title],
date: Time.new(params[:post][:date]) date: Time.parse(params[:post][:date])
} }
post = Sutty::Models::Post.new(@site, @post, front_matter) post = Sutty::Models::Post.new(@site, @post, front_matter)
post.content = params[:post][:content] post.content = params[:post][:content]
if post.save if post.save
@post = post.post
flash[:success] = 'Artículo guardado con éxito' flash[:success] = 'Artículo guardado con éxito'
redirect to("/sites/#{@site.name}/posts/#{post.post.basename}") # XXX por alguna razon el flash no sobrevive la redirección
haml :'posts/show'
else else
flash[:error] = 'Hubo un error al guardar el artículo' flash[:warning] = post.errors
redirect back haml :'posts/edit'
end end
end end
end end

9
views/_flash.haml Normal file
View file

@ -0,0 +1,9 @@
- [ :warning, :success ].each do |type|
- if flash[type]
.alert{class: "alert-#{type.to_s}", role: 'alert'}
- if flash[type].respond_to? :each
%ul
- flash[type].each do |msg|
%li= msg
- else
= flash[type]

View file

@ -7,6 +7,7 @@
%link{rel: 'stylesheet', type: 'text/css', href: '/stylesheets/sutty.css'} %link{rel: 'stylesheet', type: 'text/css', href: '/stylesheets/sutty.css'}
%body{class: @has_cover ? 'background-cover' : ''} %body{class: @has_cover ? 'background-cover' : ''}
.container-fluid .container-fluid
= haml :_flash
= yield = yield
%footer.footer %footer.footer
%p{style: @has_cover ? 'color: white' : ''} %p{style: @has_cover ? 'color: white' : ''}

View file

@ -6,7 +6,7 @@
= @post.content = @post.content
.form-group .form-group
%label{for: 'date'} Fecha de publicación %label{for: 'date'} Fecha de publicación
%input.form-control{type: 'text', name: 'post[date]', id: 'date', value: @post.data['date']} %input.form-control{type: 'text', name: 'post[date]', id: 'date', value: @post.data['date'].strftime('%F')}
.form-group .form-group
%label{for: 'title'} Título %label{for: 'title'} Título
%input.form-control{type: 'text', name: 'post[title]', id: 'title', value: @post.data['title']} %input.form-control{type: 'text', name: 'post[title]', id: 'title', value: @post.data['title']}