sources: remove canonical_url method.
Refactor source strategies to remove the `canonical_url` method. `canonical_url` returned the URL that should be used as the source of the post after upload. Now we simply use `Source::URL#page_url` to determine the source after upload. If the source is an image URL that is convertible to a page URL, then the image URL is used as the source. If the source is an image URL that is not convertible to a page URL, then the page URL is used as the source. This simplifies source strategies so that all they have to care about is implementing the `Source::URL#page_url` and `Sources::Strategies#page_url` methods, and the preferred source will be chosen for posts automatically.
This commit is contained in:
@@ -73,7 +73,6 @@ module Sources
|
||||
@site = Sources::Strategies.find("https://www.pixiv.net/en/artworks/64476642")
|
||||
|
||||
assert_equal(["https://i.pximg.net/img-original/img/2017/08/18/00/09/21/64476642_p0.jpg"], @site.image_urls)
|
||||
assert_equal("https://i.pximg.net/img-original/img/2017/08/18/00/09/21/64476642_p0.jpg", @site.canonical_url)
|
||||
assert_equal("https://www.pixiv.net/artworks/64476642", @site.page_url)
|
||||
|
||||
@site = Sources::Strategies.find("https://www.pixiv.net/artworks/64476642")
|
||||
@@ -152,8 +151,8 @@ module Sources
|
||||
assert_equal(["https://i.pximg.net/img-original/img/2017/08/18/00/09/21/64476642_p0.jpg"], @site.image_urls)
|
||||
end
|
||||
|
||||
should "get the full size image url for the canonical url" do
|
||||
assert_equal("https://i.pximg.net/img-original/img/2017/08/18/00/09/21/64476642_p0.jpg", @site.canonical_url)
|
||||
should "get the page url" do
|
||||
assert_equal("https://www.pixiv.net/artworks/64476642", @site.page_url)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user