This commit is contained in:
Albert Yi 2017-01-16 12:57:37 -08:00
parent a49394e6cd
commit bdac591266
10 changed files with 10 additions and 41 deletions

View File

@ -480,14 +480,6 @@
Danbooru.Post.initialize_title_for($post);
}
Danbooru.Post.vote = function(score, id) {
Danbooru.notice("Voting...");
$.post("/posts/" + id + "/votes.js", {
score: score
});
}
Danbooru.Post.update = function(post_id, params) {
Danbooru.Post.notice_update("inc");

View File

@ -13,7 +13,7 @@ class CommentVotesController < ApplicationController
def destroy
@comment = Comment.find(params[:comment_id])
@comment.unvote!(params[:score])
@comment.unvote!
rescue CommentVote::Error => x
@error = x
render status: 500

View File

@ -70,13 +70,6 @@ class CommentsController < ApplicationController
end
end
def unvote
@comment = Comment.find(params[:id])
@comment.unvote!
rescue CommentVote::Error => x
@error = x
end
private
def index_for_post
@post = Post.find(params[:post_id])

View File

@ -83,13 +83,6 @@ class PostsController < ApplicationController
end
end
def unvote
@post = Post.find(params[:id])
@post.unvote!
rescue PostVote::Error => x
@error = x
end
def home
if CurrentUser.user.is_anonymous?
redirect_to intro_explore_posts_path

View File

@ -1,7 +1,7 @@
<% if @error %>
Danbooru.error("<%= j @error.to_s %>");
<% else %>
<% if @comment_vote.is_negative? %>
$(".comment[data-comment-id=<%= @comment.id %>]").remove();
<% end %>
<% end %>
$("#comment-vote-up-link-for-<%= @comment.id %>").show();
$("#comment-vote-down-link-for-<%= @comment.id %>").show();
$("#comment-unvote-link-for-<%= @comment.id %>").hide();
<% end %>

View File

@ -35,7 +35,7 @@
<% end %>
<li id="comment-vote-up-link-for-<%= comment.id %>"><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
<li id="comment-vote-down-link-for-<%= comment.id %>"><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
<li id="comment-unvote-link-for-<%= comment.id %>" class="unvote-comment-link"><%= link_to "Unvote", unvote_comment_path(comment.id), :method => :put, :remote => true %></li>
<li id="comment-unvote-link-for-<%= comment.id %>" class="unvote-comment-link"><%= link_to "Unvote", comment_votes_path(:comment_id => comment.id), :method => :delete, :remote => true %></li>
<% end %>
</menu>
<% if comment.editable_by?(CurrentUser.user) %>

View File

@ -1,7 +0,0 @@
<% if @error %>
Danbooru.error("<%= j @error.to_s %>");
<% else %>
$("#comment-vote-up-link-for-<%= @comment.id %>").show();
$("#comment-vote-down-link-for-<%= @comment.id %>").show();
$("#comment-unvote-link-for-<%= @comment.id %>").hide();
<% end %>

View File

@ -5,4 +5,4 @@
$("#score-for-post-<%= @post.id %>").html(<%= @post.score %>);
<% end %>
$("#vote-links-for-post-<%= @post.id %>").show();
$("#unvote-link-for-post-<%= @post.id %>").hide();
$("#unvote-link-for-post-<%= @post.id %>").hide();

View File

@ -16,7 +16,7 @@
</li>
<li>Source: <%= post_source_tag(post) %></li>
<li>Rating: <%= post.pretty_rating %></li>
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_voter? %>(<span id="vote-links-for-post-<%= post.id %>">vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %></span><%= link_to "undo vote", unvote_post_path(post), :remote => true, :method => :put, :id => "unvote-link-for-post-#{post.id}", :class => "unvote-post-link" %>)<% end %></li>
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_voter? %>(<span id="vote-links-for-post-<%= post.id %>">vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %></span><%= link_to "undo vote", post_votes_path(post), :remote => true, :method => :delete, :id => "unvote-link-for-post-#{post.id}", :class => "unvote-post-link" %>)<% end %></li>
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
<% if CurrentUser.is_gold? %>
<%= link_to "Show &raquo;".html_safe, "#", :id => "show-favlist-link" %>

View File

@ -99,12 +99,11 @@ Rails.application.routes.draw do
end
end
resources :comments do
resources :votes, :controller => "comment_votes", :only => [:create, :destroy]
resource :votes, :controller => "comment_votes", :only => [:create, :destroy]
collection do
get :search
end
member do
put :unvote
post :undelete
end
end
@ -196,7 +195,7 @@ Rails.application.routes.draw do
collection { put :create_or_update }
member { put :revert }
end
resources :votes, :controller => "post_votes", :only => [:create, :destroy]
resource :votes, :controller => "post_votes", :only => [:create, :destroy]
collection do
get :home
get :random
@ -205,7 +204,6 @@ Rails.application.routes.draw do
put :revert
put :copy_notes
get :show_seq
put :unvote
put :mark_as_translated
end
end