parse urls for comments

This commit is contained in:
Kyle Drake 2016-07-29 19:55:43 -07:00
parent 0cbbc938e9
commit 2d9e6c520e
5 changed files with 9 additions and 2 deletions

View file

@ -49,6 +49,7 @@ gem 'acme-client', {
} }
gem 'http' gem 'http'
gem 'htmlentities' gem 'htmlentities'
gem 'rinku'
platform :mri, :rbx do platform :mri, :rbx do
gem 'magic' # sudo apt-get install file, For OSX: brew install libmagic gem 'magic' # sudo apt-get install file, For OSX: brew install libmagic

View file

@ -182,6 +182,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0) mime-types (>= 1.16, < 3.0)
netrc (~> 0.7) netrc (~> 0.7)
rinku (2.0.0)
rmagick (2.15.4) rmagick (2.15.4)
ruby-progressbar (1.7.5) ruby-progressbar (1.7.5)
rye (0.9.13) rye (0.9.13)
@ -318,6 +319,7 @@ DEPENDENCIES
redis redis
redis-namespace redis-namespace
rest-client rest-client
rinku
rmagick rmagick
ruby-debug ruby-debug
rye rye

View file

@ -132,3 +132,7 @@ def email_not_validated?
current_site && current_site.parent? && !current_site.is_education && !current_site.email_confirmed && !current_site.supporter? current_site && current_site.parent? && !current_site.is_education && !current_site.email_confirmed && !current_site.supporter?
end end
def sanitize_comment(text)
Rinku.auto_link Sanitize.fragment(text), :all, 'target="_blank" rel="nofollow"'
end

View file

@ -110,7 +110,7 @@
<span class="date"> <span class="date">
<a href="/site/<%= comment_event_site.username %>?event_id=<%= event.id %>"><%= comment.created_at.ago %></a> <a href="/site/<%= comment_event_site.username %>?event_id=<%= event.id %>"><%= comment.created_at.ago %></a>
</span> </span>
<p><%= comment.message %></p> <p><%== sanitize_comment comment.message %></p>
</div> </div>
<div class="actions"> <div class="actions">
<% comment_likes_count = comment.comment_likes_dataset.count %> <% comment_likes_count = comment.comment_likes_dataset.count %>

View file

@ -22,5 +22,5 @@
</span> </span>
</div> </div>
<div class="content"> <div class="content">
<div style="margin-bottom: 10px"><%= profile_comment.message %></div> <div style="margin-bottom: 10px"><%== sanitize_comment profile_comment.message %></div>
</div> </div>