add legacy artist json api
This commit is contained in:
@@ -284,6 +284,18 @@ class Artist < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def legacy_api_hash
|
||||||
|
return {
|
||||||
|
:id => id,
|
||||||
|
:name => name,
|
||||||
|
:other_names => other_names,
|
||||||
|
:group_name => group_name,
|
||||||
|
:urls => artist_urls.map {|x| x.url},
|
||||||
|
:is_active => is_active?,
|
||||||
|
:updater_id => 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.user.id
|
self.creator_id = CurrentUser.user.id
|
||||||
end
|
end
|
||||||
|
|||||||
1
app/views/legacy/artists.json.erb
Normal file
1
app/views/legacy/artists.json.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[<%= raw @artists.map(&:to_json).join(",") %>]
|
||||||
@@ -201,7 +201,8 @@ Danbooru::Application.routes.draw do
|
|||||||
|
|
||||||
# legacy aliases
|
# legacy aliases
|
||||||
match "/artist" => redirect {|params, req| "/artists?page=#{req.params[:page]}"}
|
match "/artist" => redirect {|params, req| "/artists?page=#{req.params[:page]}"}
|
||||||
match "/artist/index.xml", :controller => "legacy", :action => "artists"
|
match "/artist/index.xml", :controller => "legacy", :action => "artists", :format => "xml"
|
||||||
|
match "/artist/index.json", :controller => "legacy", :action => "artists", :format => "json"
|
||||||
match "/artist/index" => redirect {|params, req| "/artists?page=#{req.params[:page]}"}
|
match "/artist/index" => redirect {|params, req| "/artists?page=#{req.params[:page]}"}
|
||||||
match "/artist/show/:id" => redirect("/artists/%{id}")
|
match "/artist/show/:id" => redirect("/artists/%{id}")
|
||||||
match "/artist/show" => redirect {|params, req| "/artists?name=#{CGI::escape(req.params[:name])}"}
|
match "/artist/show" => redirect {|params, req| "/artists?name=#{CGI::escape(req.params[:name])}"}
|
||||||
|
|||||||
Reference in New Issue
Block a user