Remove artist commentary handling from download rewrite strategies.
This commit is contained in:
@@ -15,7 +15,6 @@ class UploadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@post = find_post_by_url(@normalized_url)
|
@post = find_post_by_url(@normalized_url)
|
||||||
extract_artist_commentary(@upload, data)
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@source = Sources::Site.new(params[:url], :referer_url => params[:ref])
|
@source = Sources::Site.new(params[:url], :referer_url => params[:ref])
|
||||||
@@ -72,17 +71,6 @@ class UploadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def extract_artist_commentary(upload, data)
|
|
||||||
if data[:artist_commentary_desc]
|
|
||||||
upload.artist_commentary_title = strip_tags(data[:artist_commentary_title])
|
|
||||||
upload.artist_commentary_desc = strip_tags(data[:artist_commentary_desc])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def strip_tags(s)
|
|
||||||
Rails::Html::FullSanitizer.new.sanitize(s, encode_special_chars: false)
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_post_by_url(normalized_url)
|
def find_post_by_url(normalized_url)
|
||||||
if normalized_url.nil?
|
if normalized_url.nil?
|
||||||
Post.where(source: params[:url]).first
|
Post.where(source: params[:url]).first
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ module Downloads
|
|||||||
if url =~ %r{deviantart\.com/art/} || url =~ %r{deviantart\.net/.+/[a-z0-9_]+(_by_[a-z0-9_]+)?-d([a-z0-9]+)\.}i
|
if url =~ %r{deviantart\.com/art/} || url =~ %r{deviantart\.net/.+/[a-z0-9_]+(_by_[a-z0-9_]+)?-d([a-z0-9]+)\.}i
|
||||||
url, headers = rewrite_html_pages(url, headers)
|
url, headers = rewrite_html_pages(url, headers)
|
||||||
url, headers = rewrite_thumbnails(url, headers)
|
url, headers = rewrite_thumbnails(url, headers)
|
||||||
data[:artist_commentary_title] = source.artist_commentary_title
|
|
||||||
data[:artist_commentary_desc] = source.artist_commentary_desc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return [url, headers, data]
|
return [url, headers, data]
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ module Downloads
|
|||||||
url, headers = rewrite_thumbnails(url, headers)
|
url, headers = rewrite_thumbnails(url, headers)
|
||||||
url, headers = rewrite_old_small_manga_pages(url, headers)
|
url, headers = rewrite_old_small_manga_pages(url, headers)
|
||||||
url, headers = rewrite_to_thumbnails(url, headers) if data.delete(:get_thumbnail)
|
url, headers = rewrite_to_thumbnails(url, headers) if data.delete(:get_thumbnail)
|
||||||
data[:artist_commentary_title] = source.artist_commentary_title
|
|
||||||
data[:artist_commentary_desc] = source.artist_commentary_desc
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# http://i2.pixiv.net/img-zip-ugoira/img/2014/08/05/06/01/10/44524589_ugoira1920x1080.zip
|
# http://i2.pixiv.net/img-zip-ugoira/img/2014/08/05/06/01/10/44524589_ugoira1920x1080.zip
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module Downloads
|
|||||||
|
|
||||||
def rewrite(url, headers, data = {})
|
def rewrite(url, headers, data = {})
|
||||||
if url =~ %r!^https?://(?:mobile\.)?twitter\.com!
|
if url =~ %r!^https?://(?:mobile\.)?twitter\.com!
|
||||||
url, headers = rewrite_status_page(url, headers, data)
|
url = source.image_url
|
||||||
elsif url =~ %r{^https?://pbs\.twimg\.com}
|
elsif url =~ %r{^https?://pbs\.twimg\.com}
|
||||||
url, headers = rewrite_thumbnails(url, headers, data)
|
url, headers = rewrite_thumbnails(url, headers, data)
|
||||||
end
|
end
|
||||||
@@ -18,12 +18,6 @@ module Downloads
|
|||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def rewrite_status_page(url, headers, data)
|
|
||||||
url = source.image_url
|
|
||||||
data[:artist_commentary_desc] = source.artist_commentary_desc
|
|
||||||
return [url, headers, data]
|
|
||||||
end
|
|
||||||
|
|
||||||
def rewrite_thumbnails(url, headers, data)
|
def rewrite_thumbnails(url, headers, data)
|
||||||
if url =~ %r{^(https?://pbs\.twimg\.com/media/[^:]+)}
|
if url =~ %r{^(https?://pbs\.twimg\.com/media/[^:]+)}
|
||||||
url = $1 + ":orig"
|
url = $1 + ":orig"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ module Sources
|
|||||||
delegate :get, :get_size, :site_name, :artist_name,
|
delegate :get, :get_size, :site_name, :artist_name,
|
||||||
:profile_url, :image_url, :tags, :artist_record, :unique_id,
|
:profile_url, :image_url, :tags, :artist_record, :unique_id,
|
||||||
:page_count, :file_url, :ugoira_frame_data, :ugoira_content_type, :image_urls,
|
:page_count, :file_url, :ugoira_frame_data, :ugoira_content_type, :image_urls,
|
||||||
:has_artist_commentary?, :artist_commentary_title,
|
:artist_commentary_title, :artist_commentary_desc,
|
||||||
:artist_commentary_desc, :rewrite_thumbnails, :illust_id_from_url, :to => :strategy
|
:rewrite_thumbnails, :illust_id_from_url, :to => :strategy
|
||||||
|
|
||||||
def self.strategies
|
def self.strategies
|
||||||
[Strategies::PixivWhitecube, Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::ArtStation, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr, Strategies::Pawoo]
|
[Strategies::PixivWhitecube, Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::ArtStation, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr, Strategies::Pawoo]
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ module Sources
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determines whether or not to automatically create an ArtistCommentary
|
|
||||||
def has_artist_commentary?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def normalize_for_artist_finder!
|
def normalize_for_artist_finder!
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ module Sources
|
|||||||
"http://www.pixiv.net"
|
"http://www.pixiv.net"
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_artist_commentary?
|
|
||||||
@artist_commentary_desc.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def normalized_for_artist_finder?
|
def normalized_for_artist_finder?
|
||||||
url =~ %r!https?://img\.pixiv\.net/img/#{MONIKER}/?$!i
|
url =~ %r!https?://img\.pixiv\.net/img/#{MONIKER}/?$!i
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ module Sources
|
|||||||
"http://www.pixiv.net"
|
"http://www.pixiv.net"
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_artist_commentary?
|
|
||||||
@artist_commentary_desc.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def normalizable_for_artist_finder?
|
def normalizable_for_artist_finder?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ module Sources::Strategies
|
|||||||
@artist_commentary_desc = attrs[:text]
|
@artist_commentary_desc = attrs[:text]
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_artist_commentary?
|
|
||||||
@artist_commentary_desc.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def image_urls
|
def image_urls
|
||||||
TwitterService.new.image_urls(url)
|
TwitterService.new.image_urls(url)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -509,10 +509,6 @@ class Upload < ActiveRecord::Base
|
|||||||
:original_description => artist_commentary_desc
|
:original_description => artist_commentary_desc
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_artist_commentary?
|
|
||||||
artist_commentary_desc.present?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
include ConversionMethods
|
include ConversionMethods
|
||||||
|
|||||||
@@ -69,15 +69,15 @@
|
|||||||
<%= f.text_field :parent_id %>
|
<%= f.text_field :parent_id %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if @upload.has_artist_commentary? %>
|
<div>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= f.label :artist_commentary_title, "Artist Commentary Title" %>
|
<%= f.label :artist_commentary_title, "Artist Commentary Title" %>
|
||||||
<%= f.text_field :artist_commentary_title, :value => @upload.artist_commentary_title %>
|
<%= f.text_field :artist_commentary_title %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= f.label :artist_commentary_desc, "Artist Commentary" %>
|
<%= f.label :artist_commentary_desc, "Artist Commentary" %>
|
||||||
<%= f.text_area :artist_commentary_desc, :value => @upload.artist_commentary_desc, :size => "60x5" %>
|
<%= f.text_area :artist_commentary_desc, :size => "60x5" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
Include Commentary
|
Include Commentary
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
</div>
|
||||||
|
|
||||||
<% if Danbooru.config.iqdbs_server %>
|
<% if Danbooru.config.iqdbs_server %>
|
||||||
<% if params[:url] %>
|
<% if params[:url] %>
|
||||||
|
|||||||
Reference in New Issue
Block a user