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.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.update = function(post_id, params) {
Danbooru.Post.notice_update("inc"); Danbooru.Post.notice_update("inc");

View File

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

View File

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

View File

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

View File

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

View File

@@ -35,7 +35,7 @@
<% end %> <% 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-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-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 %> <% end %>
</menu> </menu>
<% if comment.editable_by?(CurrentUser.user) %> <% 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

@@ -16,7 +16,7 @@
</li> </li>
<li>Source: <%= post_source_tag(post) %></li> <li>Source: <%= post_source_tag(post) %></li>
<li>Rating: <%= post.pretty_rating %></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> <li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
<% if CurrentUser.is_gold? %> <% if CurrentUser.is_gold? %>
<%= link_to "Show &raquo;".html_safe, "#", :id => "show-favlist-link" %> <%= link_to "Show &raquo;".html_safe, "#", :id => "show-favlist-link" %>

View File

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