Skip to content

Commit

Permalink
fandom: treat links to wiki pages as bad sources.
Browse files Browse the repository at this point in the history
Treat sources that link to the wiki page containing the image, rather than to the image itself, as
bad sources.

This is a good source because it identifies the actual image used:

    https://typemoon.fandom.com/wiki/Astolfo?file=Memories_of_Trifas.png

This is a bad source because it doesn't identify which of the many images on the page was used:

    https://typemoon.fandom.com/wiki/Astolfo

Wiki pages are bad sources because sometimes they can have hundreds of images and it can be hard to
tell which image the post came from. Wikis can also be edited, so the image may no longer even be on
the page. Or the image could be used on multiple pages, so it can't necessarily be tied to a single
wiki page.
  • Loading branch information
evazion committed May 23, 2024
1 parent 6823232 commit 5d96745
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/logical/source/url/fandom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ def image_url?
domain == "nocookie.net"
end

def bad_source?
!image_url? && file.blank?
end

def full_image_url
if wiki_db_name.present? && file.present?
subdir = Digest::MD5.hexdigest(file)
Expand Down
11 changes: 11 additions & 0 deletions test/unit/sources/fandom_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ class FandomTest < ActiveSupport::TestCase
assert(Source::URL.profile_url?("https://typemoon.fandom.com"))
assert(Source::URL.profile_url?("https://genshin-impact.fandom.com/pt-br"))
end

should "identify bad sources correctly" do
assert_not(Source::URL.parse("https://vignette.wikia.nocookie.net/valkyriecrusade/images/c/c5/Crimson_Hatsune_H.png/revision/latest?cb=20180702031954").bad_source?)
assert_not(Source::URL.parse("https://typemoon.fandom.com/wiki/Tamamo-no-Mae?file=Caster_Extra_Takeuchi_design_1.png").bad_source?)
assert_not(Source::URL.parse("https://typemoon.fandom.com/wiki/File:Memories_of_Trifas.png").bad_source?)

assert(Source::URL.parse("https://typemoon.fandom.com").bad_source?)
assert(Source::URL.parse("https://typemoon.fandom.com/wiki/User:Lemostr00").bad_source?)
assert(Source::URL.parse("https://typemoon.fandom.com/f/p/4400000000000077950").bad_source?)
assert(Source::URL.parse("https://genshin-impact.fandom.com/wiki/Ningguang/Gallery").bad_source?)
end
end
end
end

0 comments on commit 5d96745

Please sign in to comment.