Remove artist commentary handling from download rewrite strategies.

This commit is contained in:
evazion
2017-05-01 21:20:49 -05:00
parent b49641f775
commit b2f62482a1
11 changed files with 7 additions and 50 deletions

View File

@@ -15,7 +15,6 @@ class UploadsController < ApplicationController
end
@post = find_post_by_url(@normalized_url)
extract_artist_commentary(@upload, data)
begin
@source = Sources::Site.new(params[:url], :referer_url => params[:ref])
@@ -72,17 +71,6 @@ class UploadsController < ApplicationController
end
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)
if normalized_url.nil?
Post.where(source: params[:url]).first

View File

@@ -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
url, headers = rewrite_html_pages(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
return [url, headers, data]

View File

@@ -18,8 +18,6 @@ module Downloads
url, headers = rewrite_thumbnails(url, headers)
url, headers = rewrite_old_small_manga_pages(url, headers)
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
# http://i2.pixiv.net/img-zip-ugoira/img/2014/08/05/06/01/10/44524589_ugoira1920x1080.zip

View File

@@ -9,7 +9,7 @@ module Downloads
def rewrite(url, headers, data = {})
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}
url, headers = rewrite_thumbnails(url, headers, data)
end
@@ -18,12 +18,6 @@ module Downloads
end
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)
if url =~ %r{^(https?://pbs\.twimg\.com/media/[^:]+)}
url = $1 + ":orig"

View File

@@ -6,8 +6,8 @@ module Sources
delegate :get, :get_size, :site_name, :artist_name,
:profile_url, :image_url, :tags, :artist_record, :unique_id,
:page_count, :file_url, :ugoira_frame_data, :ugoira_content_type, :image_urls,
:has_artist_commentary?, :artist_commentary_title,
:artist_commentary_desc, :rewrite_thumbnails, :illust_id_from_url, :to => :strategy
:artist_commentary_title, :artist_commentary_desc,
:rewrite_thumbnails, :illust_id_from_url, :to => :strategy
def self.strategies
[Strategies::PixivWhitecube, Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::ArtStation, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr, Strategies::Pawoo]

View File

@@ -53,11 +53,6 @@ module Sources
false
end
# Determines whether or not to automatically create an ArtistCommentary
def has_artist_commentary?
false
end
def normalize_for_artist_finder!
url
end

View File

@@ -41,10 +41,6 @@ module Sources
"http://www.pixiv.net"
end
def has_artist_commentary?
@artist_commentary_desc.present?
end
def normalized_for_artist_finder?
url =~ %r!https?://img\.pixiv\.net/img/#{MONIKER}/?$!i
end

View File

@@ -26,10 +26,6 @@ module Sources
"http://www.pixiv.net"
end
def has_artist_commentary?
@artist_commentary_desc.present?
end
def normalizable_for_artist_finder?
true
end

View File

@@ -30,10 +30,6 @@ module Sources::Strategies
@artist_commentary_desc = attrs[:text]
end
def has_artist_commentary?
@artist_commentary_desc.present?
end
def image_urls
TwitterService.new.image_urls(url)
end

View File

@@ -509,10 +509,6 @@ class Upload < ActiveRecord::Base
:original_description => artist_commentary_desc
)
end
def has_artist_commentary?
artist_commentary_desc.present?
end
end
include ConversionMethods

View File

@@ -69,15 +69,15 @@
<%= f.text_field :parent_id %>
</div>
<% if @upload.has_artist_commentary? %>
<div>
<div class="input">
<%= 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 class="input">
<%= 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 class="input">
@@ -86,7 +86,7 @@
Include Commentary
</label>
</div>
<% end %>
</div>
<% if Danbooru.config.iqdbs_server %>
<% if params[:url] %>