Permalink
Browse files

use redcarpet

  • Loading branch information...
1 parent 1a331ce commit 2167ccde35e7e3adf10b782d92f55f0d17cf53e5 @herestomwiththeweather herestomwiththeweather committed Dec 13, 2011
View
@@ -23,6 +23,7 @@ gem "ruby-openid", :require => "openid"
gem "oauth-plugin", :path => "#{File.expand_path(__FILE__)}/../vendor/gems/oauth-plugin-0.4.0.pre4"
gem "cancan", "1.5.1"
gem "dalli"
+gem "redcarpet", "1.17.2"
group :development, :test do
gem "rspec", "1.3.0"
View
@@ -7,7 +7,7 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- aasm (2.3.1)
+ aasm (3.0.0)
activerecord
actionmailer (2.3.14)
actionpack (= 2.3.14)
@@ -31,24 +31,25 @@ GEM
xml-simple
builder (3.0.0)
cancan (1.5.1)
- chronic (0.6.5)
- dalli (1.1.3)
+ chronic (0.6.6)
+ dalli (1.1.4)
eventmachine (0.12.10)
feed-normalizer (1.5.2)
hpricot (>= 0.6)
simple-rss (>= 1.1)
- heroku (2.14.0)
+ heroku (2.16.2)
launchy (>= 0.3.2)
rest-client (~> 1.6.1)
rubyzip
term-ansicolor (~> 1.0.5)
- hpricot (0.8.4)
- json (1.6.1)
+ hpricot (0.8.5)
+ json (1.6.3)
launchy (2.0.5)
addressable (~> 2.2.6)
mime-types (1.17.2)
oauth (0.4.5)
- pg (0.11.0)
+ pg (0.12.0)
+ rake-compiler (~> 0.7)
rack (1.1.2)
rack-openid (1.3.1)
rack (>= 1.1.0)
@@ -61,6 +62,9 @@ GEM
activesupport (= 2.3.14)
rake (>= 0.8.3)
rake (0.9.2.2)
+ rake-compiler (0.7.9)
+ rake
+ redcarpet (1.17.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rmagick (2.13.1)
@@ -69,7 +73,7 @@ GEM
rack (>= 1.0.0)
rspec (>= 1.3.0)
ruby-openid (2.1.8)
- rubyzip (0.9.4)
+ rubyzip (0.9.5)
simple-rss (1.2.3)
term-ansicolor (1.0.7)
texticle (1.0.4.20101004123327)
@@ -96,6 +100,7 @@ DEPENDENCIES
pg
rack-openid
rails (= 2.3.14)
+ redcarpet (= 1.17.2)
rmagick
rspec (= 1.3.0)
rspec-rails (= 1.3.2)
@@ -126,13 +126,10 @@ def admin?
def set_focus_to(id)
javascript_tag("jQuery('##{id}').focus()");
end
-
- # Same as Rails' simple_format helper without using paragraphs
- def simple_format_without_paragraph(text)
- text.to_s.
- gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
- gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
- gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
+
+ def markdown(text)
+ options = [:hard_wrap, :no_intraemphasis]
+ Redcarpet.new(text, *options).to_html.html_safe
end
# Display text by sanitizing and formatting.
@@ -1,7 +1,7 @@
<h2><%= h @broadcast_email.subject %></h2>
<p>
- <%=h simple_format_without_paragraph @broadcast_email.message %>
+ <%=markdown(@broadcast_email.message) %>
</p>
<%= link_to 'Edit', edit_admin_broadcast_email_path(@broadcast_email) %> |
@@ -71,7 +71,7 @@
</div>
<%- end -%>
<%- end -%>
- <%= display simple_format_without_paragraph @person.description %>
+ <%= markdown(@person.description) %>
</div>
<div id="wall_canvas">
@@ -6,7 +6,7 @@
<%= image_link full_message.sender, :class => "photo",
:image => :thumbnail %>
</div>
- <%= display simple_format_without_paragraph full_message.content %>
+ <%= markdown(full_message.content) %>
<p class="meta tools">
<%= t('messages.show.sent') %> <%= time_ago_in_words full_message.created_at %> <%= t('ago') %> |
<%= link_to t('messages.show.reply'), reply_message_path(full_message) %> |
@@ -13,7 +13,7 @@
</p>
<%= display offer.formatted_categories, :class => "meta" %>
<p>
- <%= display simple_format_without_paragraph(offer.description) %>
+ <%= markdown(offer.description) %>
</p>
<p class="meta">
<%= t('offers.partial.available_count') %>: <%= offer.available_count %>
@@ -79,7 +79,7 @@
</div>
<%- end -%>
<%- end -%>
- <%= display simple_format_without_paragraph @person.description %>
+ <%= markdown(@person.description) %>
</div>
<%= render :partial => '/shared/wall' %>
@@ -4,7 +4,7 @@
</div>
<div style="font-size:14px;color:rgb(50,50,50);border-bottom:1px #555 dotted">
<div style="background:rgb(255,255,225);padding:5px;">
- <p><%= display simple_format_without_paragraph h @forum_post.body %></p>
+ <p><%= markdown(@forum_post.body) %></p>
</div>
</div>
<%= render :partial => 'notice', :object => link_to("#{t('messages.show.reply')} ","http://#{@server}/groups/#{@forum_post.topic.forum.group.id}") + t('person_mailer.message_notification.click_to_view') %>
@@ -1,5 +1,5 @@
-<%= display simple_format_without_paragraph @forum_post.body %>
+<%= strip_tags(@forum_post.body) %>
http://<%= @server %>/groups/<%= @forum_post.topic.forum.group.id %>
@@ -3,7 +3,7 @@
</div>
<div style="font-size:14px;color:rgb(50,50,50);border-bottom:1px #555 dotted">
<div style="background:rgb(255,255,225);padding:5px;">
- <p><%= display simple_format_without_paragraph h @message.content %></p>
+ <p><%= markdown(@message.content) %></p>
</div>
</div>
<%= render :partial => 'notice', :object => link_to("#{t('messages.show.reply')} ","http://#{@server}/messages/#{@message.to_param}") + t('person_mailer.message_notification.click_to_view') %>
@@ -1,4 +1,4 @@
-<%= display simple_format_without_paragraph @message.content %>
+<%= strip_tags(@message.content) %>
--
<%= t('person_mailer.message_notification.click_to_view') %> <%= @server %>:
@@ -6,7 +6,7 @@
</div>
<div style="font-size:14px;color:rgb(50,50,50);border-bottom:1px #555 dotted">
<div style="background:rgb(255,255,225);padding:5px;">
- <p><%= display simple_format_without_paragraph h @comment.body %></p>
+ <p><%= markdown(@comment.body) %></p>
</div>
</div>
<%= render :partial => 'notice', :object => link_to("#{t('messages.show.reply')} ","http://#{@server}#{@url}") + t('person_mailer.message_notification.click_to_view') %>
@@ -10,7 +10,7 @@
</p>
<%= display req.formatted_categories, :class => "meta" %>
<p>
- <%= display simple_format_without_paragraph req.description %>
+ <%= markdown(req.description) %>
</p>
<p class="meta">
<%= render :partial => "shared/bid_message", :collection => approved_messages(req) %>
@@ -7,7 +7,7 @@
<%= person_link comment.commenter %> <%= t('said') %>
<%= time_ago_in_words(comment.created_at) %> <%= t('ago') %>
</p>
- <%= display simple_format_without_paragraph comment.body %>
+ <%= markdown(comment.body) %>
<%- if(current_person?(comment.commentable)) -%>
<%= link_to t('reply_on') + " #{comment.commenter.name}'s " + t('wall'), person_path(comment.commenter, :anchor => 'wall'), :class => "small" %>
@@ -11,6 +11,6 @@
<%- end -%>
</p>
<div class="forum">
- <%= display simple_format_without_paragraph forum_post.body %>
+ <%= markdown(forum_post.body) %>
</div>
</li>

0 comments on commit 2167ccd

Please sign in to comment.