From e92669fb2d60e4bb331e67d9bfd17a5266152a65 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 28 Oct 2011 00:37:17 +0500 Subject: install rdiscount --- Gemfile | 3 ++- Gemfile.lock | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 60fc118c609..fc040ce08c8 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem "pygments.rb", "0.2.3" gem "thin" gem "git" gem "acts_as_list" +gem 'rdiscount' group :assets do gem 'sass-rails', " ~> 3.1.0" @@ -26,7 +27,7 @@ group :assets do gem 'uglifier' end -group :development do +group :development do gem 'rails-footnotes', '>= 3.7.5.rc4' gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git' end diff --git a/Gemfile.lock b/Gemfile.lock index 83ccebd89b0..83df35b52af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -161,6 +161,7 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2) + rdiscount (1.6.8) rdoc (3.9.4) rspec (2.6.0) rspec-core (~> 2.6.0) @@ -264,6 +265,7 @@ DEPENDENCIES pygments.rb (= 0.2.3) rails (= 3.1.0) rails-footnotes (>= 3.7.5.rc4) + rdiscount rspec-rails ruby-debug19 sass-rails (~> 3.1.0) -- cgit v1.2.1 From 6c7706eb17cff08ba0c3cccc3ebcfc969ae0f6e3 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 28 Oct 2011 00:57:10 +0500 Subject: process notes w/ rdiscount --- app/views/notes/_show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/notes/_show.html.haml b/app/views/notes/_show.html.haml index ee9f9ffaa4b..1907e9cc0af 100644 --- a/app/views/notes/_show.html.haml +++ b/app/views/notes/_show.html.haml @@ -2,7 +2,7 @@ %div.note_author = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" %div.note_content.left - = simple_format(html_escape(note.note)) + = raw RDiscount.new(note.note, :smart, :filter_html).to_html - if note.attachment.url Attachment: = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" -- cgit v1.2.1 From 1f3323f9088b897220dc4989ac8da0ef71001ce1 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Sun, 30 Oct 2011 17:41:57 +0400 Subject: use helper to markdown text --- app/helpers/application_helper.rb | 4 ++++ app/views/notes/_show.html.haml | 2 +- app/views/projects/_recent_messages.html.haml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 599d1e5c5c9..fbca5ea5d66 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -30,6 +30,10 @@ module ApplicationHelper 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 projects = current_user.projects.map{ |p| { :label => p.name, :url => project_path(p) } } default_nav = [ diff --git a/app/views/notes/_show.html.haml b/app/views/notes/_show.html.haml index 1907e9cc0af..187d0a3c47a 100644 --- a/app/views/notes/_show.html.haml +++ b/app/views/notes/_show.html.haml @@ -2,7 +2,7 @@ %div.note_author = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;" %div.note_content.left - = raw RDiscount.new(note.note, :smart, :filter_html).to_html + = markdown(note.note) - if note.attachment.url Attachment: = link_to note.attachment_identifier, note.attachment.url, :target => "_blank" diff --git a/app/views/projects/_recent_messages.html.haml b/app/views/projects/_recent_messages.html.haml index 67f3449bd9b..b38ba4831b5 100644 --- a/app/views/projects/_recent_messages.html.haml +++ b/app/views/projects/_recent_messages.html.haml @@ -40,7 +40,7 @@ %p{:style => "margin-bottom: 3px;"} %span.author = 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 %br Attachment: -- cgit v1.2.1