summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjomo <github@jomo.tv>2015-04-01 16:59:01 +0200
committerjomo <github@jomo.tv>2015-04-01 16:59:01 +0200
commit320cfa56f9e051d8539e50400c3b427f54e0dd10 (patch)
tree0da6fcf3bfaa2aa79c86b49e74f7f2f5320b8382
parent72503392e0873d94463366ae9c277cb5dc37986f (diff)
blog comment improvements
-rw-r--r--app/controllers/blogposts_controller.rb12
-rw-r--r--app/views/blogposts/show.html.erb2
2 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb
index 79c9e5d..e1fae78 100644
--- a/app/controllers/blogposts_controller.rb
+++ b/app/controllers/blogposts_controller.rb
@@ -10,6 +10,18 @@ class BlogpostsController < ApplicationController
def show
@comment = Comment.new(blogpost: @post)
@comments = @post.comments.page(params[:page])
+ @comments = @comments.select do |c|
+ # shadowban april fool comments
+ if c.author.is?(current_user) || !["april", "hoax", "fool", "troll", "joke", "prank", "legit"].any? { |word| c.content.downcase.include? word }
+ true
+ elsif current_user && current_user.mod?
+ c.content = "[HIDDEN] " + c.content
+ true
+ else
+ false
+ end
+ end
+ @comments = Kaminari.paginate_array(@comments).page(params[:page]).per(25)
end
def new
diff --git a/app/views/blogposts/show.html.erb b/app/views/blogposts/show.html.erb
index 71a4b07..dc60e66 100644
--- a/app/views/blogposts/show.html.erb
+++ b/app/views/blogposts/show.html.erb
@@ -20,7 +20,7 @@
</div>
</div>
<div id="comments">
- <h3><%= "#{pluralize(@post.comments.size, 'comment')}." %></h3>
+ <h3><%= "#{pluralize(@comments.size, 'comment')}." %></h3>
<% @comments.each do |c| %>
<%= render "comments/comment", c: c %>
<% end %>