From fed23c0baa61a11617e9257a4ff48290e8b36bbb Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 6 Jun 2017 13:07:44 -0500 Subject: [PATCH] fetch source data: fix gallery warning for non-pixiv galleries. --- app/assets/javascripts/uploads.js | 2 +- app/logical/sources/site.rb | 4 ++-- app/logical/sources/strategies/base.rb | 3 +-- test/unit/sources/pixiv_test.rb | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/uploads.js b/app/assets/javascripts/uploads.js index 24f34307e..6b7adf0c3 100644 --- a/app/assets/javascripts/uploads.js +++ b/app/assets/javascripts/uploads.js @@ -102,7 +102,7 @@ $("#source-record").html($("").attr("href", new_artist_href).text("Create New")); - if (data.page_count > 1) { + if (data.image_urls.length > 1) { $("#gallery-warning").show(); } else { $("#gallery-warning").hide(); diff --git a/app/logical/sources/site.rb b/app/logical/sources/site.rb index 6ff87d8c6..6dc883601 100644 --- a/app/logical/sources/site.rb +++ b/app/logical/sources/site.rb @@ -5,7 +5,7 @@ module Sources attr_reader :url, :strategy 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, + :file_url, :ugoira_frame_data, :ugoira_content_type, :image_urls, :artist_commentary_title, :artist_commentary_desc, :dtext_artist_commentary_title, :dtext_artist_commentary_desc, :rewrite_thumbnails, :illust_id_from_url, :to => :strategy @@ -63,13 +63,13 @@ module Sources :artist_name => artist_name, :profile_url => profile_url, :image_url => image_url, + :image_urls => image_urls, :normalized_for_artist_finder_url => normalize_for_artist_finder!, :tags => tags, :translated_tags => translated_tags, :danbooru_name => artist_record.try(:first).try(:name), :danbooru_id => artist_record.try(:first).try(:id), :unique_id => unique_id, - :page_count => page_count, :artist_commentary => { :title => artist_commentary_title, :description => artist_commentary_desc, diff --git a/app/logical/sources/strategies/base.rb b/app/logical/sources/strategies/base.rb index f1f4909c9..31f8e3df2 100644 --- a/app/logical/sources/strategies/base.rb +++ b/app/logical/sources/strategies/base.rb @@ -10,7 +10,7 @@ module Sources module Strategies class Base attr_reader :url, :referer_url - attr_reader :artist_name, :profile_url, :image_url, :tags, :page_count + attr_reader :artist_name, :profile_url, :image_url, :tags attr_reader :artist_commentary_title, :artist_commentary_desc def self.url_match?(url) @@ -20,7 +20,6 @@ module Sources def initialize(url, referer_url = nil) @url = url @referer_url = referer_url - @page_count = 1 end # No remote calls are made until this method is called. diff --git a/test/unit/sources/pixiv_test.rb b/test/unit/sources/pixiv_test.rb index 836040c99..c803a0c78 100644 --- a/test/unit/sources/pixiv_test.rb +++ b/test/unit/sources/pixiv_test.rb @@ -77,7 +77,7 @@ module Sources end should "get the page count" do - assert_equal(3, @site.page_count) + assert_equal(3, @site.image_urls.size) end should "get the tags" do @@ -108,7 +108,7 @@ module Sources end should "get the page count" do - assert_equal(1, @site.page_count) + assert_equal(1, @site.image_urls.size) end should "get the full size image url" do