This commit is contained in:
albert
2013-03-10 16:56:04 -04:00
parent 6b02826405
commit 43177cbad8
4 changed files with 14 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
module Sources
class Site
attr_reader :url, :strategy
delegate :get, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :to => :strategy
delegate :get, :referer_url, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :to => :strategy
def self.strategies
[Strategies::NicoSeiga, Strategies::Pixiv]

View File

@@ -33,6 +33,10 @@ module Sources
end
end
def referer_url(template)
template.params[:ref] || template.params[:url]
end
protected
def agent
raise NotImplementedError

View File

@@ -5,6 +5,14 @@ module Sources
url =~ /^https?:\/\/(?:\w+\.)?pixiv\.net/
end
def referer_url(template)
if template.params[:ref] =~ /pixiv\.net\/member_illust/ && template.params[:ref] !~ /mode=manga/
template.params[:ref]
else
template.params[:url]
end
end
def site_name
"Pixiv"
end

View File

@@ -4,7 +4,7 @@
<% if source.try(:available?) %>
<div id="source-info">
<p>This looks like a <%= source.site_name %> upload. <%= link_to "Fetch data", source_path(:format => "json", :url => params[:ref] || params[:url]), :id => "fetch-data" %>.</p>
<p>This looks like a <%= source.site_name %> upload. <%= link_to "Fetch data", source_path(:format => "json", :url => source.referer_url(self)), :id => "fetch-data" %>.</p>
<ul>
<li><strong>Artist</strong>: <span id="source-artist"></span></li>