use helper to markdown text

This commit is contained in:
Nihad Abbasov 2011-10-30 17:41:57 +04:00
parent 6c7706eb17
commit 1f3323f908
3 changed files with 6 additions and 2 deletions

View file

@ -30,6 +30,10 @@ module ApplicationHelper
end end
end end
def markdown(text)
RDiscount.new(text, :autolink, :no_pseudo_protocols, :safelink, :smart, :filter_html).to_html.html_safe
end
def search_autocomplete_source def search_autocomplete_source
projects = current_user.projects.map{ |p| { :label => p.name, :url => project_path(p) } } projects = current_user.projects.map{ |p| { :label => p.name, :url => project_path(p) } }
default_nav = [ default_nav = [

View file

@ -2,7 +2,7 @@
%div.note_author %div.note_author
= image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;"
%div.note_content.left %div.note_content.left
= raw RDiscount.new(note.note, :smart, :filter_html).to_html = markdown(note.note)
- if note.attachment.url - if note.attachment.url
Attachment: Attachment:
= link_to note.attachment_identifier, note.attachment.url, :target => "_blank" = link_to note.attachment_identifier, note.attachment.url, :target => "_blank"

View file

@ -40,7 +40,7 @@
%p{:style => "margin-bottom: 3px;"} %p{:style => "margin-bottom: 3px;"}
%span.author %span.author
= note.author.name = note.author.name
= link_to truncate(note.note, :length => 200), link_to_item + "#note_#{note.id}" = link_to truncate(markdown(note.note), :length => 200), link_to_item + "#note_#{note.id}"
- if note.attachment.url - if note.attachment.url
%br %br
Attachment: Attachment: