comment liking

This commit is contained in:
Kyle Drake 2014-05-05 11:58:11 -07:00
parent 8210670122
commit 51a85a0b03
9 changed files with 125 additions and 29 deletions

12
app.rb
View file

@ -120,6 +120,7 @@ get '/?' do
end
get '/plan/?' do
@title = 'Supporter'
erb :'plan/index'
end
@ -233,6 +234,7 @@ get '/browse' do
end
get '/api' do
@title = 'Developers API'
erb :'api'
end
@ -896,6 +898,14 @@ post '/event/:event_id/delete' do |event_id|
return {result: 'error'}.to_json
end
post '/comment/:comment_id/toggle_like' do |comment_id|
require_login
content_type :json
comment = Comment[id: comment_id]
liked_response = comment.toggle_site_like(current_site) ? 'liked' : 'unliked'
{result: liked_response, comment_like_count: comment.comment_likes_dataset.count, liking_site_names: comment.liking_site_names}.to_json
end
post '/comment/:comment_id/delete' do |comment_id|
require_login
content_type :json
@ -1014,4 +1024,4 @@ end
def api_not_found
api_error 404, 'not_found', 'the requested api call does not exist'
end
end