mirror of
https://github.com/neocities/neocities.git
synced 2025-06-05 03:57:25 +02:00
comment liking
This commit is contained in:
parent
8210670122
commit
51a85a0b03
9 changed files with 125 additions and 29 deletions
12
app.rb
12
app.rb
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue