Merge pull request #2923 from evazion/feat-source-xml
Add /sources.xml endpoint; include backtraces in json
This commit is contained in:
@@ -1,25 +1,12 @@
|
|||||||
class SourcesController < ApplicationController
|
class SourcesController < ApplicationController
|
||||||
# before_filter :member_only
|
respond_to :json, :xml
|
||||||
respond_to :json
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@source = Sources::Site.new(params[:url], :referer_url => params[:ref])
|
@source = Sources::Site.new(params[:url], :referer_url => params[:ref])
|
||||||
@source.get
|
@source.get
|
||||||
|
|
||||||
respond_with(@source) do |format|
|
respond_with(@source.to_h) do |format|
|
||||||
format.json do
|
format.xml { render xml: @source.to_h.to_xml(root: "source") }
|
||||||
render :json => @source.to_json
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def rescue_exception(exception)
|
|
||||||
respond_with do |format|
|
|
||||||
format.json do
|
|
||||||
render :json => {:message => exception.to_s, :backtrace => exception.backtrace}, :status => :error
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ module Sources
|
|||||||
WikiPage.other_names_match(untranslated_tags).map{|wiki_page| [wiki_page.title, wiki_page.category_name]}
|
WikiPage.other_names_match(untranslated_tags).map{|wiki_page| [wiki_page.title, wiki_page.category_name]}
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json
|
def to_h
|
||||||
return {
|
return {
|
||||||
:artist_name => artist_name,
|
:artist_name => artist_name,
|
||||||
:profile_url => profile_url,
|
:profile_url => profile_url,
|
||||||
@@ -71,7 +71,7 @@ module Sources
|
|||||||
:title => artist_commentary_title,
|
:title => artist_commentary_title,
|
||||||
:description => artist_commentary_desc,
|
:description => artist_commentary_desc,
|
||||||
}
|
}
|
||||||
}.to_json
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def available?
|
def available?
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<% if @error_message %>
|
<% if @error_message %>
|
||||||
{"success": false, "message": <%= raw @error_message.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>}
|
{"success": false, "message": <%= raw @error_message.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>}
|
||||||
<% else %>
|
<% else %>
|
||||||
{"success": false, "message": <%= raw @exception.to_s.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>}
|
{
|
||||||
|
"success": false,
|
||||||
|
"message": <%= raw @exception.to_s.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>,
|
||||||
|
"backtrace": <%= raw @exception.backtrace.to_json %>
|
||||||
|
}
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user