Add warning when Pixiv post is a gallery of multiple images
This commit is contained in:
@@ -85,6 +85,12 @@
|
||||
|
||||
$("#source-record").html(new_artist_link);
|
||||
|
||||
if (data.page_count > 1) {
|
||||
$("#gallery-warning").show();
|
||||
} else {
|
||||
$("#gallery-warning").hide();
|
||||
}
|
||||
|
||||
$("#source-info span#loading-data").hide();
|
||||
$("#source-info ul").show();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ div#c-uploads {
|
||||
margin: 1em 0;
|
||||
padding: 1em;
|
||||
border: 1px solid gray;
|
||||
min-height: 4em;
|
||||
min-height: 5em;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Sources
|
||||
class Site
|
||||
attr_reader :url, :strategy
|
||||
delegate :get, :referer_url, :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, :page_count, :to => :strategy
|
||||
|
||||
def self.strategies
|
||||
[Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::Nijie]
|
||||
@@ -31,7 +31,8 @@ module Sources
|
||||
:translated_tags => translated_tags,
|
||||
:danbooru_name => artist_record.try(:first).try(:name),
|
||||
:danbooru_id => artist_record.try(:first).try(:id),
|
||||
:unique_id => unique_id
|
||||
:unique_id => unique_id,
|
||||
:page_count => page_count
|
||||
}.to_json
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ module Sources
|
||||
module Strategies
|
||||
class Base
|
||||
attr_reader :url
|
||||
attr_reader :artist_name, :profile_url, :image_url, :tags
|
||||
attr_reader :artist_name, :profile_url, :image_url, :tags, :page_count
|
||||
|
||||
def self.url_match?(url)
|
||||
false
|
||||
@@ -10,6 +10,7 @@ module Sources
|
||||
|
||||
def initialize(url)
|
||||
@url = url
|
||||
@page_count = 1
|
||||
end
|
||||
|
||||
# No remote calls are made until this method is called.
|
||||
|
||||
@@ -29,6 +29,7 @@ module Sources
|
||||
@artist_name, @profile_url = get_profile_from_page(page)
|
||||
@image_url = get_image_url_from_page(page)
|
||||
@tags = get_tags_from_page(page)
|
||||
@page_count = get_page_count_from_page(page)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,6 +82,19 @@ module Sources
|
||||
end
|
||||
end
|
||||
|
||||
def get_page_count_from_page(page)
|
||||
elements = page.search("ul.meta li").find_all do |node|
|
||||
node.text =~ /Manga/
|
||||
end
|
||||
|
||||
if elements.any?
|
||||
elements[0].text =~ /Manga (\d+)P/
|
||||
$1.to_i
|
||||
else
|
||||
1
|
||||
end
|
||||
end
|
||||
|
||||
def normalized_url
|
||||
@normalized_url ||= begin
|
||||
if url =~ /\/(\d+)(?:_big)?(?:_m|_p\d+)?\.(?:jpg|jpeg|png|gif)/i
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<p><%= link_to "Fetch source data", source_path(:format => "json"), :id => "fetch-data-manual" %></p>
|
||||
<p><%= content_tag "span", "Loading source data...", :id => "loading-data", :style => "display: none;" %></p>
|
||||
<% end %>
|
||||
<p><%= content_tag "span", "Gallery. Tags may not apply to all images.", :id => "gallery-warning", :style => "display: none;" %></p>
|
||||
|
||||
<ul>
|
||||
<li><strong>Artist</strong>: <span id="source-artist"></span></li>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<div id="source-info">
|
||||
<p><%= link_to "Fetch source data", source_path(:format => "json"), :id => "fetch-data-manual" %></p>
|
||||
<p><%= content_tag "span", "Loading source data...", :id => "loading-data", :style => "display: none;" %></p>
|
||||
<p><%= content_tag "span", "Gallery. Tags may not apply to all images.", :id => "gallery-warning", :style => "display: none;" %></p>
|
||||
|
||||
<ul>
|
||||
<li><strong>Artist</strong>: <span id="source-artist"></span></li>
|
||||
|
||||
Reference in New Issue
Block a user