Commit Graph

11257 Commits

Author SHA1 Message Date
evazion
28971fe103 sources: factor out site_name method. 2022-03-11 23:20:53 -06:00
evazion
b4aea72d04 sources: remove preview_urls method from base strategy.
Remove the `preview_urls` method from strategies. The only place this was used was
when doing IQDB searches, to download the thumbnail image from the source instead of
the full image.

This wasn't worth it for a few reasons:

* Thumbnails on other sites are sometimes not the size we want, which could affect
  IQDB results.
* Grabbing thumbnails is complex for some sites. You can't always just rewrite the
  image URL. Sometimes it requires extra API calls, which can be slower than just
  grabbing the full image.
* For videos and animations, thumbnails from other sites don't always match our
  thumbnails. We do smart thumbnail generation to try to avoid blank thumbnails, which
  means we don't always pick the first frame, which could affect IQDB results.

API changes:

* /iqdb_queries?search[file_url] now downloads the URL as is without any modification.
  Before it tried to change thumbnail and sample size image URLs to the full version.

* /iqdb_queries?search[url] now returns an error if the URL is for a HTML page that
  contains multiple images. Before it would grab only the first image and silently
  ignore the rest.
2022-03-11 03:22:23 -06:00
evazion
2f61486ac6 sources: remove image_url method from base strategy.
Remove the `image_url` method from source strategies. This method would
return only the first image if a source had multiple images. The
`image_urls` method should be used instead. Tests were the main place
that still used `image_url` instead of `image_urls`.

Also make post replacements return an error if replacing with a source
that contains multiple images, instead of just blindly replacing the
post with the first image in the source.
2022-03-11 01:59:21 -06:00
evazion
4701027f45 sources: remove unused methods from base strategy.
Remove unused `urls`, `parsed_urls`, and `domains` methods.
2022-03-10 23:11:00 -06:00
evazion
2460ac0927 Merge pull request #5044 from nonamethanks/modqueue-thumb-size
Modqueue: support variable size thumbnails
2022-03-10 15:32:20 -06:00
evazion
5016d9ad26 Merge pull request #5043 from nonamethanks/fantia-support
Add Fantia support
2022-03-10 15:21:03 -06:00
evazion
8bba1b0a54 weibo: add test for m.weibo.cn/detail urls. 2022-03-10 15:04:02 -06:00
evazion
29fc072cf1 Merge pull request #5042 from nonamethanks/weibo-fix-typo
weibo: fix typo in strategy
2022-03-10 15:01:12 -06:00
evazion
0252b3608c Merge pull request #5041 from NamelessContributor/fix-mode-menu
post_mode_menu: update preview link selector
2022-03-10 14:58:21 -06:00
nonamethanks
5b5f61c2ea Modqueue: support variable size thumbnails 2022-03-10 20:39:45 +01:00
nonamethanks
a6549bc6fe Add Fantia support
Also fixes a regression in 74fdeef10c
that stopped mastodon urls from being given the right priority.
2022-03-10 17:43:32 +01:00
evazion
43a665a66d sources: factor out Source::URL::NicoSeiga. 2022-03-10 04:53:51 -06:00
nonamethanks
93adba06e5 weibo: fix typo in strategy 2022-03-10 08:31:23 +01:00
evazion
34854185be sources: factor out Source::URL::DeviantArt and Source::URL::Stash. 2022-03-10 00:29:49 -06:00
NamelessContributor
3b63174525 post_mode_menu: update preview link selector
Fixes the post-score link triggering the mode menu action as well as
all three score links getting the blue border on hover.
2022-03-09 10:01:09 +01:00
evazion
28f962ccfb artists: fix Pawoo icon not showing up in artist urls. 2022-03-09 02:27:07 -06:00
evazion
9f16602930 artists: fix Fanbox icon not showing up for Fanbox urls. 2022-03-09 02:08:14 -06:00
evazion
dcbc9b3140 js: fix Alpine Warning: Unable to initialize.
Fix this Javascript warniing:

    Alpine Warning: Unable to initialize. Trying to load Alpine before
    `<body>` is available. Did you forget to add `defer` in Alpine's
    `<script>` tag?
2022-03-09 01:35:02 -06:00
evazion
80939f5e22 users: fix name changes not being validated.
Fix names not being validated when a user changes their name. Regression in 5ce724f1e.
2022-03-09 01:14:09 -06:00
evazion
d770f0bb95 tests: fix broken tests. 2022-03-09 01:14:09 -06:00
evazion
bb4b8619f5 pixiv: fix Source::URL::Pixiv not being included in Source::URL list. 2022-03-09 01:14:09 -06:00
evazion
8a50148823 pixiv: fixup bug with fetching image_urls for bad_id posts.
Fix `image_urls` returning `[nil]` when fetching data for a image URL
that was bad_id. In that case `original_urls` is empty, so we fall back
to using the deleted image URL as-is.
2022-03-09 01:14:09 -06:00
evazion
c989726313 rails: enable remove_deprecated_time_with_zone_name.
Fix this deprecation warning:

    DEPRECATION WARNING: ActiveSupport::TimeWithZone.name has been deprecated
    and from Rails 7.1 will use the default Ruby implementation. You can set
    `config.active_support.remove_deprecated_time_with_zone_name = true` to
    enable the new behavior now.

Triggered by the XML serializer in the API.
2022-03-09 01:14:09 -06:00
evazion
ec190a2d10 Update Rails to 7.0.2.3.
Fixes CVE-2022-21831 (this does not affect Danbooru).

* https://discuss.rubyonrails.org/t/cve-2022-21831-possible-code-injection-vulnerability-in-rails-active-storage/80199
* https://rubyonrails.org/2022/3/8/Rails-7-0-2-3-6-1-4-7-6-0-4-7-and-5-2-6-3-have-been-released
2022-03-09 01:14:09 -06:00
evazion
77c88fd867 Merge pull request #5038 from nonamethanks/remove-redundant-comments
sources: remove redundant comments
2022-03-08 23:28:29 -06:00
evazion
6afb2f8e3c Merge pull request #5037 from nonamethanks/tumblr-refactor
sources: factor out Source::URL::Tumblr
2022-03-08 23:26:30 -06:00
evazion
7d9790bf46 Merge pull request #5036 from NamelessContributor/issue-5006
icon_helper: inline globe_icon. fixes #5006
2022-03-08 23:22:22 -06:00
evazion
cf4b9a6114 Merge pull request #5039 from nonamethanks/simplify-lofter-tag-parsing
Lofter: simplify tag extraction logic
2022-03-08 23:21:57 -06:00
evazion
987f2985d3 Merge pull request #5040 from nonamethanks/fix-weibo-404
Weibo: fix exception for deleted url
2022-03-08 23:08:37 -06:00
evazion
52a2d3418c pixiv: fixup bugs in 1c620f805.
* Fix error when uploading non-ugoira files.
* Fix sample image URLs not being rewritten to full images correctly. We
  have to get the full image URL from the API because given an
  /img-master/ URL, we don't know what the original file extension is.
2022-03-08 23:07:24 -06:00
nonamethanks
c9be77d1f8 Weibo: fix exception for deleted url 2022-03-09 05:31:38 +01:00
evazion
1c620f8055 sources: factor out Source::URL::Pixiv.
* Drop support for preview_urls. This means that IQDB lookups may be
  slower, especially for ugoiras, since we have to download the full
  ugoira now. However, ugoira lookups should produce better results,
  since the ugoira thumbnail chosen by Pixiv wasn't necessarily the same
  as the thumbnail chosen by Danbooru.

* Drop support for uploading single manga pages:

    http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=18557054&page=2

  Previously uploading an URL like this would only upload a single image
  out of a multi-image work. Now it will upload all images in the work.
  Pixiv no longer supports URLs like this, so we don't either.

* Add support for parsing URLs like this:

    https://i.pximg.net/c/360x360_70/custom-thumb/img/2022/03/08/00/00/56/96755248_p0_custom1200.jpg

  Apparently artists can choose a custom thumbnail now (not like anyone
  will try to upload one though).
2022-03-08 22:17:38 -06:00
evazion
df0bb70486 sources: factor out Source::URL::PixivSketch.
Add upload support for Pixiv Sketch. Fetch tags, commentary, and artist,
and rewrite sample images to full images.

Authentication isn't required. R18 images are hidden in the browser but
visible in the API.
2022-03-08 18:24:12 -06:00
nonamethanks
ff6bfff311 Lofter: simplify tag extraction logic
Now that we have a separate parsing class we can just use it to properly
parse tag urls as well.
2022-03-08 17:01:50 +01:00
nonamethanks
ebd3670076 sources: remove redundant comments
These comments are already present under the parse blocks, so the huge
walls of text before the code are not needed anymore.
2022-03-08 16:56:00 +01:00
nonamethanks
b9c7e467e5 sources: factor out Source::URL::Tumblr
Also adds support for fetching source data from direct image urls when
possible.
2022-03-08 15:06:06 +01:00
NamelessContributor
28343a8e2b icon_helper: inline globe_icon. fixes #5006 2022-03-08 14:19:46 +01:00
evazion
37441d6b1a Merge pull request #5034 from NamelessContributor/fix-spinner-icon
Always add animate-spin class to spinner_icon
2022-03-08 03:30:01 -06:00
evazion
5ce724f1e2 users: remove confirmation when changing username. 2022-03-08 03:29:15 -06:00
evazion
99479dfcf2 users: waive one name change per week rule if user has invalid name. 2022-03-08 03:29:15 -06:00
evazion
f0a5936091 Fix #5035: Double flags being created in certain conditions.
Lock the post to prevent a race condition when validating that the user
hasn't already flagged the post.
2022-03-08 03:29:15 -06:00
NamelessContributor
c9e3c293a9 Always add animate-spin class to spinner_icon
This also fixes the source data and fav button spinners not spinning
after commit 77515915a4
2022-03-08 08:54:45 +01:00
evazion
0713dae49d Merge pull request #5033 from NamelessContributor/fix-hard-tabs
Replace hard tabs with spaces in .rb files
2022-03-08 00:21:23 -06:00
NamelessContributor
5cdbc1d454 Replace hard tabs with spaces in .rb files 2022-03-08 07:11:54 +01:00
evazion
de61e56161 Merge pull request #5032 from nonamethanks/factor-out-weibo
sources: factor out Source::URL::Weibo
2022-03-07 18:31:15 -06:00
evazion
8d28453f17 Merge pull request #5031 from nonamethanks/fix-foundation
Foundation: fix normalization error
2022-03-07 18:28:06 -06:00
evazion
ed98156b72 Merge pull request #5030 from nonamethanks/fix-new-installation-uploads
docker-compose: do db:seed before server start
2022-03-07 18:27:47 -06:00
nonamethanks
d8e2f2ee33 sources: factor out Source::URL::Weibo
Additionally, fixed some broken tests and changed normalization for urls
of album type to point to the mobile version instead, because they're
only visible to logged-in users.
2022-03-07 16:52:43 +01:00
evazion
125cc1d048 users: fix lockout of invalid usernames (525acd17a) 2022-03-07 04:45:37 -06:00
evazion
74d6b4e81e users: don't allow names ending with file extensions.
This is so in the future we can have URLs like https://danbooru.donmai.us/users/evazion
without problems caused by names like https://danbooru.donmai.us/users/evazion.json
2022-03-07 04:39:00 -06:00