Merge pull request #2803 from evazion/fix-comment-cleanups

Various minor comment code cleanups
This commit is contained in:
Albert Yi
2016-12-27 11:42:08 -08:00
committed by GitHub
7 changed files with 14 additions and 28 deletions

View File

@@ -13,9 +13,6 @@ Danbooru.Note = {
$inner_border.css({
opacity: opacity,
"-ms-filter": "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)",
"filter": "alpha(opacity=50)",
zoom: 1
});
var $note_box = $('<div/>');

View File

@@ -49,13 +49,6 @@ $preview_flagged_color: #F00;
text-shadow: $val;
}
@mixin transparency($value) {
opacity: $value;
-ms-filter: unqoute("progid:DXImageTransform.Microsoft.Alpha(Opacity=#{$value * 100})");
filter: unquote("alpha(opacity=#{$value * 100})");
zoom: 1;
}
@mixin inline-block {
display: -moz-inline-box;
-moz-box-orient: vertical;

View File

@@ -41,16 +41,10 @@ div.comments-for-post {
}
article.comment.below-threshold {
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=30);
filter: alpha(opacity=30);
zoom: 1;
opacity: 0.3;
}
article.comment.below-threshold:hover {
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
filter: alpha(opacity=100);
zoom: 1;
opacity: 1.0;
}
}

View File

@@ -1,6 +1,6 @@
class CommentsController < ApplicationController
respond_to :html, :xml, :json
before_filter :member_only, :only => [:update, :create, :edit, :destroy]
before_filter :member_only, :except => [:index, :search, :show]
rescue_from ActiveRecord::StatementInvalid, :with => :rescue_exception
def index
@@ -48,9 +48,7 @@ class CommentsController < ApplicationController
def show
@comment = Comment.find(params[:id])
respond_with(@comment) do |format|
format.json {render :json => @comment.to_json(:methods => [:creator_name])}
end
respond_with(@comment)
end
def destroy

View File

@@ -54,11 +54,11 @@ class Comment < ActiveRecord::Base
end
def for_creator(user_id)
where("creator_id = ?", user_id)
user_id.present? ? where("creator_id = ?", user_id) : where("false")
end
def for_creator_name(user_name)
where("creator_id = (select _.id from users _ where lower(_.name) = lower(?))", user_name.mb_chars.downcase)
for_creator(User.name_to_id(user_name))
end
def search(params)
@@ -69,8 +69,12 @@ class Comment < ActiveRecord::Base
q = q.body_matches(params[:body_matches])
end
if params[:id].present?
q = q.where("id in (?)", params[:id].split(",").map(&:to_i))
end
if params[:post_id].present?
q = q.where("post_id = ?", params[:post_id].to_i)
q = q.where("post_id in (?)", params[:post_id].split(",").map(&:to_i))
end
if params[:post_tags_match].present?
@@ -78,7 +82,7 @@ class Comment < ActiveRecord::Base
end
if params[:creator_name].present?
q = q.for_creator_name(params[:creator_name].tr(" ", "_"))
q = q.for_creator_name(params[:creator_name])
end
if params[:creator_id].present?
@@ -199,6 +203,10 @@ class Comment < ActiveRecord::Base
super + [:body_index]
end
def method_attributes
super + [:creator_name, :updater_name]
end
def delete!
update_attributes(:is_deleted => true)
end

View File

@@ -1,3 +0,0 @@
<% if post.hidden_comment_count(@current_user) > 0 %>
<span class="info" id="threshold-comments-notice-for-<%= post.id %>"><%= link_to_remote "#{pluralize post.hidden_comment_count(@current_user), 'comment'} below threshold", :url => index_all_comments_path(:post_id => post.id) %>.</span>
<% end %>

View File

@@ -102,7 +102,6 @@ Rails.application.routes.draw do
resources :votes, :controller => "comment_votes", :only => [:create, :destroy]
collection do
get :search
get :index_all
end
member do
put :unvote