Add markdown at post description

This commit is contained in:
Sergi
2016-04-29 10:30:04 +02:00
parent bf2e957e9c
commit dd602bde57
7 changed files with 17 additions and 3 deletions

View File

@ -122,4 +122,8 @@ class Post < ActiveRecord::Base
def member
@member ||= Member.find_by(user_id: user_id, organization_id: organization_id)
end
def rendered_description
RDiscount.new(description, :autolink)
end
end

View File

@ -44,8 +44,8 @@
&mdash;
= ph
.col-md-9
%p.lead.post-description= post.description
.col-md-9.lead
= post.rendered_description.to_html.html_safe
- unless current_user
.alert.alert-info

View File

@ -6,6 +6,10 @@
.form-group
= f.label :description
= f.text_area :description, rows: "10", class: "form-control"
%p.small.text-right
= t ".you_can_use"
- wiki_url = "https://#{I18n.locale}.wikipedia.org/wiki/Markdown"
%a{ href: wiki_url, title: "Markdown" } Markdown
.form-group
= f.label :category, required: true
= f.select :category_id, Category.all.sort_by{ |a| a.name.downcase }.map{ |cat| [cat.name, cat.id] }, { include_blank: true }, { class: "form-control" }

View File

@ -3,7 +3,7 @@
%h4
= link_to post do
= post.title
%p= post.description
%p= strip_tags(post.rendered_description.to_html)
%p
%small
- if post.category

View File

@ -372,3 +372,5 @@ ca:
movements:
delete_reason: Esteu segur d'esborrar aquest comentari?
movements: Moviments
post_form:
you_can_use: Pots fer servir

View File

@ -368,3 +368,5 @@ en:
movements:
delete_reason: Are you sure to delete this comment?
movements: Movements
post_form:
you_can_use: You can use

View File

@ -377,3 +377,5 @@ es:
movements:
delete_reason: ¿Está seguro de borrar este comentario?
movements: Movimientos
post_form:
you_can_use: Puedes usar