diff --git a/Gemfile b/Gemfile index 525d238fd..05d9ec2e9 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem 'omniauth-google-oauth2' gem 'kaminari' gem 'ancestry' gem 'acts-as-taggable-on' -gem "responders" +gem 'responders' gem 'foundation-rails' gem 'foundation_rails_helper' gem 'acts_as_votable' @@ -40,6 +40,7 @@ gem 'social-share-button' gem 'initialjs-rails', '0.2.0' gem 'unicorn' gem 'paranoia' +gem 'rinku', require: 'rails_rinku' gem 'savon' gem 'dalli' gem 'rollbar', '~> 2.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 7da5c9fe2..6dfcba2b0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -294,6 +294,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) + rinku (1.7.3) rollbar (2.2.1) rspec (3.3.0) rspec-core (~> 3.3.0) @@ -444,6 +445,7 @@ DEPENDENCIES quiet_assets rails (= 4.2.4) responders + rinku rollbar (~> 2.2.1) rspec-rails (~> 3.0) sass-rails (~> 5.0) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 36952af7d..67c347ced 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -17,4 +17,4 @@ module CommentsHelper comments.select{|c| c.parent_id == parent.id} end -end \ No newline at end of file +end diff --git a/app/helpers/text_with_links_helper.rb b/app/helpers/text_with_links_helper.rb new file mode 100644 index 000000000..55281e89e --- /dev/null +++ b/app/helpers/text_with_links_helper.rb @@ -0,0 +1,9 @@ +module TextWithLinksHelper + + def text_with_links(text) + return unless text + sanitized = sanitize text, tags: [], attributes: [] + Rinku.auto_link(sanitized, :all, 'target="_blank" rel="nofollow"').html_safe + end + +end diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index a3db690a8..15a8eb54a 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -1,4 +1,5 @@ class Mailer < ApplicationMailer + helper :text_with_links def comment(comment) @comment = comment diff --git a/app/views/admin/comments/index.html.erb b/app/views/admin/comments/index.html.erb index ec0fddc1a..ce4bfa293 100644 --- a/app/views/admin/comments/index.html.erb +++ b/app/views/admin/comments/index.html.erb @@ -9,7 +9,7 @@
<%= comment.body %>
+<%= text_with_links comment.body %>
<% elsif comment.as_moderator? %> -<%= comment.body %>
+<%= text_with_links comment.body %>
<% elsif comment.user.official? && comment.user_id == @commentable.author_id %> - + <% elsif comment.user.official? %> -<%= comment.body %>
+<%= text_with_links comment.body %>
<% elsif comment.user_id == @commentable.author_id %> - + <% else %> -<%= comment.body %>
+<%= text_with_links comment.body %>
<% end %> <%= render 'comments/votes', comment: comment %> @@ -101,4 +101,4 @@- <%= @comment.body %> + <%= text_with_links @comment.body %>
diff --git a/app/views/mailer/reply.html.erb b/app/views/mailer/reply.html.erb index 924234f02..d006e205a 100644 --- a/app/views/mailer/reply.html.erb +++ b/app/views/mailer/reply.html.erb @@ -13,6 +13,6 @@- <%= @reply.body %> + <%= text_with_links @reply.body %>
diff --git a/app/views/moderation/comments/index.html.erb b/app/views/moderation/comments/index.html.erb index ec642077b..d18dca8e8 100644 --- a/app/views/moderation/comments/index.html.erb +++ b/app/views/moderation/comments/index.html.erb @@ -23,7 +23,7 @@ <%= comment.commentable_type.constantize.model_name.human %> <%= l comment.updated_at.to_date %> -