Browse files

Finally really fixes #15

  • Loading branch information...
1 parent 890a482 commit ef765f007f7b95a2da2921a446146df0b9fb6439 Elias Haase committed Feb 5, 2012
Showing with 15 additions and 11 deletions.
  1. +2 −1 Gemfile
  2. +3 −7 Gemfile.lock
  3. +7 −0 app/helpers/application_helper.rb
  4. +2 −2 app/views/comments/_print.html.erb
  5. +1 −1 app/views/posts/_print.html.erb
View
3 Gemfile
@@ -1,4 +1,5 @@
source 'http://rubygems.org'
+source 'http://gemcutter.org'
gem 'rails', '3.1.3'
@@ -26,4 +27,4 @@ gem 'cancan'
gem 'make_voteable'
gem 'mysql2'
gem 'rails_autolink'
-gem 'formatize'
+gem 'rdiscount'
View
10 Gemfile.lock
@@ -6,8 +6,8 @@ GIT
GEM
remote: http://rubygems.org/
+ remote: http://gemcutter.org/
specs:
- RedCloth (4.2.9)
actionmailer (3.1.3)
actionpack (= 3.1.3)
mail (~> 2.3.0)
@@ -38,7 +38,6 @@ GEM
multi_json (~> 1.0)
arel (2.2.1)
bcrypt-ruby (3.0.1)
- bluecloth (2.2.0)
builder (3.0.0)
cancan (1.6.5)
capybara (1.1.2)
@@ -78,10 +77,6 @@ GEM
execjs (1.3.0)
multi_json (~> 1.0)
ffi (1.0.11)
- formatize (1.0.1)
- RedCloth (~> 4.2)
- actionpack (~> 3.0)
- bluecloth (~> 2.0)
gherkin (2.7.6)
json (>= 1.4.6)
hike (1.2.1)
@@ -130,6 +125,7 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
+ rdiscount (1.6.8)
rdoc (3.12)
json (~> 1.4)
rubyzip (0.9.5)
@@ -177,14 +173,14 @@ DEPENDENCIES
database_cleaner
devise
execjs
- formatize
jquery-rails
json
make_voteable
mysql2
nested_form!
rails (= 3.1.3)
rails_autolink
+ rdiscount
sass-rails (~> 3.1.5)
sqlite3
therubyracer
View
7 app/helpers/application_helper.rb
@@ -6,4 +6,11 @@ def comment_count(object)
end
count
end
+
+ def markdown(text, *options)
+ require 'rdiscount'
+
+ text = sanitize(text) unless text.html_safe? || options.delete(:safe)
+ (text.blank? ? "" : RDiscount.new(text, :filter_html ).to_html).html_safe
+ end
end
View
4 app/views/comments/_print.html.erb
@@ -14,7 +14,7 @@
<% end %>
</div>
<div class='text_body'>
- <%= markdown(h(comment.text)) %>
+ <%= markdown(comment.text) %>
<div class='infobar'>
<%= pluralize(comment.votes, "point") %> by <%= comment.user.name %> <%= time_ago_in_words(comment.created_at) %> ago &nbsp;
<% if can? :update, comment %>
@@ -23,7 +23,7 @@
</div>
<%= link_to('reply', "#", "onClick" => "$('#comment_form_#{comment.id.to_s}').slideToggle(); return false", class: "comment_reply") if can? :create, Comment %><br />
</div>
- <div id='comment_form_<%= comment.id.to_s %>' class='comment_form' style='display: none'>"
+ <div id='comment_form_<%= comment.id.to_s %>' class='comment_form' style='display: none'>
<%= render :partial => 'comments/form', :locals => { :commentable_type => "Comment", :commentable_id => comment.id } %>
</div>
</div>
View
2 app/views/posts/_print.html.erb
@@ -16,7 +16,7 @@
<% unless post.link.nil? or post.link.empty? %>
<span class='host'><%= link_to("("+URI.parse(post.link).host.gsub("www.","")+")", "http://"+URI.parse(post.link).host) %> </span>
<% end %>
- <p class="markup"><%= markdown(h(post.text)) %></p>
+ <p class="markup"><%= markdown(post.text) %></p>
<div class='infobar'><%= pluralize(post.votes, "point") %> by <%= (post.user.nil? ? "[Deleted]" : post.user.name) %> <%= time_ago_in_words(post.created_at) %> ago | <%= link_to(pluralize(comment_count(post), "comment"), post) %>
<% if can? :update, post %>
<%= link_to 'Edit', edit_post_path(post) %>

0 comments on commit ef765f0

Please sign in to comment.