Skip to content

Commit

Permalink
Merge pull request #3120 from evazion/fix-gallery-warning
Browse files Browse the repository at this point in the history
Fix gallery warning for non-Pixiv galleries.
  • Loading branch information
r888888888 committed Jun 8, 2017
2 parents b3cd93a + fed23c0 commit ec27a4a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@

$("#source-record").html($("<a>").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();
Expand Down
4 changes: 2 additions & 2 deletions app/logical/sources/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Site
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
Expand Down Expand Up @@ -63,13 +63,13 @@ def to_h
: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,
Expand Down
3 changes: 1 addition & 2 deletions app/logical/sources/strategies/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -20,7 +20,6 @@ def self.url_match?(url)
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.
Expand Down
4 changes: 2 additions & 2 deletions test/unit/sources/pixiv_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_source(source)
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
Expand Down Expand Up @@ -108,7 +108,7 @@ def get_source(source)
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
Expand Down

0 comments on commit ec27a4a

Please sign in to comment.