Refactor sources
This commit is contained in:
@@ -1,20 +1,12 @@
|
||||
class SourcesController < ApplicationController
|
||||
respond_to :json, :xml
|
||||
rescue_from Sources::Site::NoStrategyError, :with => :no_strategy
|
||||
|
||||
def show
|
||||
@source = Sources::Site.new(params[:url], :referer_url => params[:ref])
|
||||
@source.get
|
||||
@source = Sources::Strategies.find(params[:url], params[:ref])
|
||||
|
||||
respond_with(@source.to_h) do |format|
|
||||
format.xml { render xml: @source.to_h.to_xml(root: "source") }
|
||||
format.json { render json: @source.to_h.to_json }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def no_strategy
|
||||
render json: {message: "Unsupported site"}.to_json, status: 400
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class UploadsController < ApplicationController
|
||||
|
||||
def new
|
||||
@upload_notice_wiki = WikiPage.titled(Danbooru.config.upload_notice_wiki_page).first
|
||||
@upload, @post, @source, @normalized_url, @remote_size = UploadService::ControllerHelper.prepare(
|
||||
@upload, @post, @source, @remote_size = UploadService::ControllerHelper.prepare(
|
||||
url: params[:url], ref: params[:ref]
|
||||
)
|
||||
respond_with(@upload)
|
||||
@@ -43,7 +43,7 @@ class UploadsController < ApplicationController
|
||||
end
|
||||
|
||||
def preprocess
|
||||
@upload, @post, @source, @normalized_url, @remote_size = UploadService::ControllerHelper.prepare(
|
||||
@upload, @post, @source, @remote_size = UploadService::ControllerHelper.prepare(
|
||||
url: params[:url], file: params[:file], ref: params[:ref]
|
||||
)
|
||||
render body: nil
|
||||
|
||||
Reference in New Issue
Block a user