Commit Graph
100 Commits
Author SHA1 Message Date
evazion fb926a1bd2 ai tags: replace tag_id index with (tag_id, score) index.
Index on (tag_id, score) instead of (tag_id) to allow tags to be
filtered and sorted by confidence more efficiently. This index takes up
about the same amount of space as an index on tag_id alone, so including
the score in the index is essentially free.
2022-06-27 18:29:35 -05:00
evazion ab7462a42d discord: fixup /tagme command.
Add code left out of 0435967f.
2022-06-27 03:57:09 -05:00
evazion 6a08c57cec ai tags: fix N+1 query issue. 2022-06-27 02:37:49 -05:00
evazion a2d8d19625 Fix #5215: Using the full rating name in /ai_tags shows no results 2022-06-27 01:56:45 -05:00
evazion 04359d67f4 discord: update /tagme command to use new autotagger service. 2022-06-27 01:40:44 -05:00
evazion ee57ada33b ai tags: add autotagger API client.
Add API client for https://github.com/danbooru/autotagger service.
2022-06-27 01:09:14 -05:00
evazion c199c7eab7 ai tags: adjust thumbnail layout. 2022-06-26 20:37:35 -05:00
evazion 6f24db92e5 ai tags: make ai tags accessible in api via includes.
Make these things work:

* https://danbooru.donmai.us/posts.json?only=ai_tags
* https://danbooru.donmai.us/media_assets.json?only=ai_tags
* https://danbooru.donmai.us/ai_tags.json?only=media_asset,post,tag
2022-06-26 20:37:35 -05:00
evazion efe0e8a6bd ai tags: default to showing only posts, not media assets.
Change the /ai_tags page to show only posts by default, not both posts
and unposted media assets mixed together. Showing media assets tended to
confuse users about why they couldn't add tags to these images. It also
distracted from the page's primary use case, which is gardening posts.
2022-06-26 20:37:35 -05:00
evazion 8f2774075a ai tags: disable "Add" button if user doesn't have permission to edit the post.
Disable the "Add" button on the /ai_tags page when the current user doesn't have
permission to edit the post, for example if they're not logged in.
2022-06-26 20:37:35 -05:00
evazion f35bc60e51 posts: add hidden 540px thumbnail size option.
Add a hidden option for 540px size thumbnails. This option currently
isn't listed in the thumbnail size menu, but it can be enabled with an
URL param: https://danbooru.donmai.us/posts?size=540.
2022-06-26 20:37:32 -05:00
evazion 5795a651f1 ai tags: fix add/remove button size.
Fix it so the Add/Remove button stays the same size and doesn't shift
the layout when transitioning between states.
2022-06-26 01:29:42 -05:00
evazion 54e2bbd86b posts: fix has_tag? method.
Fix a bug where `Post#has_tag?` would return false for tags that
contained colons. This caused the /ai_tags page to incorrectly say
certain tags weren't present on the post.
2022-06-26 01:07:12 -05:00
evazion 97db0e6db3 ai tags: respect the user's posts-per-page setting on the /ai_tags page. 2022-06-26 00:44:01 -05:00
evazion e5879f0def ai tags: add buttons for quickly adding and removing tags on the /ai_tags page.
Add "Add" and "Remove" buttons beneath thumbnails on the /ai_tags page.
These let you add the tag to the post if it's correct, or remove it if
it's wrong.
2022-06-26 00:43:57 -05:00
evazion 7b1f6e42c1 posts: add "Absurd" size option to thumbnail size menu.
Add option for "Absurd" (720px) size thumbnails to the thumbnail size
menu. 720px size thumbnails require .webp support so they won't work in
older browsers.
2022-06-25 21:53:27 -05:00
evazion c059b4a39a ai tags: add ability to filter by confidence in post searches.
Allow searching for e.g. `ai:solo,>=90%` to to find posts that have the
solo tag with >=90% confidence. The default confidence level is 50%. The
delimiter is a comma because it's one of the few characters not allowed
in tag names.
2022-06-25 21:51:48 -05:00
evazion 97ba21e615 ai tags: add ability to order /ai_tags page by confidence. 2022-06-25 21:51:14 -05:00
evazion d3267a5ffa user upgrades: fix button when upgrades are disabled. 2022-06-24 15:14:18 -05:00
evazion bec9e5a5d9 ai tags: fix broken "Unposted" link on /ai_tags page. 2022-06-24 08:42:40 -05:00
evazion de261bc321 ai tags: enable filtering by unposted media assets.
Enabled filtering by posted media assets on the /ai_tags page. This was
disabled in development because it was too slow, but seems to be fine in
production.
2022-06-24 08:35:39 -05:00
evazion 2adffb4f92 ai tags: fix broken links to unposted media assets.
Fix thumbnails on the /ai_tags page not linking to media assets correctly.
2022-06-24 08:33:07 -05:00
evazion 1aeb52186e Add AI tag model and UI.
Add a database model for storing AI-predicted tags, and add a UI for browsing and searching these tags.

AI tags are generated by the Danbooru Autotagger (https://github.com/danbooru/autotagger). See that
repo for details about the model.

The database schema is `ai_tags (media_asset_id integer, tag_id integer, score smallint)`. This is
designed to be as space-efficient as possible, since in production we have over 300 million
AI-generated tags (6 million images and 50 tags per post). This amounts to over 10GB in size, plus
indexes.

You can search for AI tags using e.g. `ai:scenery`. You can do `ai:scenery -scenery` to find posts
where the scenery tag is potentially missing, or `scenery -ai:scenery` to find posts that are
potentially mistagged (or more likely where the AI missed the tag).

You can browse AI tags at https://danbooru.donmai.us/ai_tags. On this page you can filter by
confidence level. You can also search unposted media assets by AI tag.

To generate tags, use the `autotag` script from the Autotagger repo, something like this:

  docker run --rm -v ~/danbooru/public/data/360x360:/images ghcr.io/danbooru/autotagger ./autotag -c -f /images | gzip > tags.csv.gz

To import tags, use the fix script in script/fixes/. Expect a Danbooru-size dataset to take
hours to days to generate tags, then 20-30 minutes to import. Currently this all has to be done by hand.
2022-06-24 04:54:26 -05:00
evazion ae9495ec7c discord: allow only rating:g posts in SFW channels. 2022-06-08 17:36:49 -05:00
evazion 06f75c39a1 footer: remove app name and 2257 link. 2022-06-06 01:00:02 -05:00
evazion 4364516f2b posts: change safe mode to only allow rating:g posts. 2022-06-06 00:56:52 -05:00
evazion ca289d869c Merge pull request #5199 from NamelessContributor/patch-1
Add back social icons to site footer.
2022-06-05 15:56:53 -05:00
evazion 7149845677 Merge pull request #5202 from nonamethanks/fix-nicoseiga-oekaki-bad-tag
Nicoseiga: normalize oekaki links
2022-06-05 15:56:37 -05:00
evazion 821b97b4e2 Merge pull request #5201 from nonamethanks/fix-deviantart
Deviantart: fix regression in 3a0a32b98a
2022-06-05 15:56:06 -05:00
evazion acc4a21687 posts: allow admins to approve the same post twice.
This is so admins can overrule flags and always have the final say in whether a
post is approved, even in the event of coordinated or sockpuppet flagging.

Fixes #4980: Way to mark flags as invalid for admins
2022-06-05 15:51:58 -05:00
evazion 907194fc6f commentaries: move search form to /artist_commentaries page.
* Move the commentary search form to the /artist_commentaries page.
* Add Order field for changing the sort order.
2022-06-05 14:28:44 -05:00
evazion 05df3a194c posts: add more free metatags.
The following metatags no longer count against the tag search limit:

* is
* id
* date
* age
* filesize
* filetype
* parent
* child
* md5
* width
* height
* duration
* mpixels
* ratio
* score
* upvotes
* downvotes
* favcount
* embedded
* tagcount
* pixiv_id
* pixiv

These are mostly metatags that have to do with properties of the post
itself. Other metatags still count because they involve things like
subqueries or joins, or they're more tag-like in function.
2022-06-05 14:28:44 -05:00
evazion ea92cbff4e user upgrades: update upgrade page text. 2022-06-02 14:40:42 -05:00
evazion fec92d765a users: change default blacklist to furry -rating:g. 2022-06-02 00:06:34 -05:00
evazion b02dbf1a43 Fix broken Docker build.
terser-webpack-plugin 5.3.2 was a bad release, which broke the Docker build.
2022-06-01 21:26:20 -05:00
evazion 2e249103e1 Update Ruby gems and Yarn packages. 2022-06-01 20:20:12 -05:00
evazion 572c58d115 Merge pull request #5187 from Hyozen1/patch-1
Allow background-clip and -webkit-background-clip properties in notes
2022-06-01 19:26:06 -05:00
evazion cc2285ed6f Merge pull request #5188 from nonamethanks/fix-deviantart
Fix deviantart strategy to get biggest available size
2022-06-01 18:39:43 -05:00
evazion 434e44ba8b Merge pull request #5197 from nonamethanks/fix-bur-links
BURs: don't allow edits to approved scripts
2022-06-01 18:37:09 -05:00
evazion 173e43b192 user upgrades: add upgrade code system.
Add a system for upgrading accounts using upgrade codes. Users purchase
an upgrade code off-site then redeem it on-site to upgrade their account
to Gold. Upgrade codes are randomly pre-generated and are one time use
only. Codes have enough randomness that guessing a code is infeasible.
2022-06-01 18:31:46 -05:00
evazion 7786fbaca6 Fix #5181: Old post versions have null ratings which causes a KeyError. 2022-05-22 23:50:45 -05:00
evazion 81bd86d202 posts: add "general" rating; rename "safe" rating to "sensitive".
* Add "general" rating.
* Rename "safe" rating to "sensitive".
* Change safe mode to include both rating:s and rating:g.
* Treat rating:safe as a synonym for rating:sensitive.
* Link "howto:rate" in the post edit form.
2022-05-22 13:38:45 -05:00
evazion d346adabc9 Revert "posts: fix rounding errors in ratio: metatag."
This reverts commit 80ced3e418.

This turned out to be intentional. Rounding the aspect ratio to 2
decimal places is so that searches for exact ratios like `ratio:16:9` or
`ratio:1.78` work even when the ratio doesn't exactly match. Rounding to
2 decimal places means that the ratio: metatag has a 1% error tolerance.
2022-05-22 12:37:26 -05:00
evazion c6b5be1c9f Update Danbooru logo. 2022-05-22 02:53:22 -05:00
evazion ed1629bc7d Update Danbooru logo. 2022-05-21 23:26:46 -05:00
evazion 276850d2b1 Update Danbooru logo. 2022-05-21 21:39:44 -05:00
evazion e7c507b7fc css: adjust spacing around header on mobile. 2022-05-21 14:57:49 -05:00
evazion 80ced3e418 posts: fix rounding errors in ratio: metatag.
Fix the ratio: metatag sometimes including wrong results due to rounding
errors. For example, searching for `ratio:>=4.0` would include post
3220414, which has an aspect ratio of 3.99879. This would get rounded up
to 2 decimal places to 4.00.
2022-05-21 14:08:50 -05:00
evazion e53e8da3a1 Fix #5171: Don't allow wide_image and tall_image to be manually tagged. 2022-05-21 14:01:31 -05:00
evazion d89db73c2f Add site logo to header. 2022-05-21 13:30:21 -05:00
evazion 1bcf93b816 Fix #5178: Add received bans to user includes. 2022-05-20 23:03:22 -05:00
evazion 9867514a78 Fix #5177: ordfav with commentary search raises exception. 2022-05-20 22:59:02 -05:00
evazion 0fe9356bf6 tests: fix broken tests. 2022-05-20 22:51:02 -05:00
evazion 1e78b97eb8 Add config options to disable comments and the forum.
Add options to disable comments, the forum, and autocomplete. This is
for personal boorus and potentially for safe mode. Note that disabling
the forum may cause difficulties with creating and approving BURs.

Disabling comments and the forum merely hides them from most areas,
rather than completely removing them.
2022-05-18 14:45:40 -05:00
evazion 2fe38c1c07 Fix #5168: Disable rate limits on testbooru/non-prod environments.
Add a `rate_limits_enabled?` config option for disabling rate limits.
2022-05-18 14:16:06 -05:00
evazion 25f0b01d50 posts: optimize has: metatag.
Use EXISTS queries instead of `id IN (?)` subqueries because they're
faster, especially when negated.
2022-05-18 13:59:04 -05:00
evazion 181639368c posts: add is: and has: metatags.
Add the following metatags:

* is:parent
* is:child
* is:safe
* is:questionable
* is:explicit
* is:sfw (same as -rating:q,e)
* is:nsfw (same as rating:q,e)
* is:active
* is:deleted
* is:pending
* is:flagged
* is:appealed
* is:banned
* is:modqueue
* is:unmoderated
* is:jpg
* is:png
* is:gif
* is:mp4
* is:webm
* is:swf
* is:zip
* has:parent
* has:children
* has:source
* has:appeals
* has:flags
* has:replacements
* has:comments
* has:commentary
* has:notes
* has:pools

All of these searches were already possible with other metatags, but these might be more convenient.
2022-05-18 13:04:15 -05:00
evazion 141044d352 posts: refactor hardcoded ratings.
Refactor ratings to not be hardcoded in various places. Make it so
all ratings are defined in Post::RATINGS.

Also make it so that you can search multiple ratings at once with `rating:q,e`.
2022-05-18 13:04:15 -05:00
evazion af8ef8b277 uploads: address "Failed to replace upload_media_assets..." error
Sometimes uploads fail with this error:

    Failed to replace upload_media_assets because one or more of the new
    records could not be saved.

Change it so that media assets are saved individually, so that if saving
any of them fails we get a better error message.
2022-05-17 18:28:13 -05:00
evazion 06b38a19af posts: don't show nsfw tags in sidebar in safe mode.
Fix the post index page to not show nsfw tags in the sidebar in safe
mode. Instead of showing the most popular tags on the front page, or the
most similar tags to the current search, show only frequent tags (the
top 25 tags from posts on the current page).
2022-05-17 04:04:09 -05:00
evazion ce18c866d9 Fix #4582: Safebooru should not block "censored" tag
* Remove the default list of blocked tags in safe mode.
* Change it so that tags that are blocked in safe mode are filtered out
  at the database level rather than at the html level.
2022-05-17 02:24:16 -05:00
evazion 8239a1b551 upgrades: fix Danbooru.config.user_upgrades_enabled? setting
* Fix it so that if upgrades are disabled, only the payment button is disabled instead of the whole page.
* Fix it so that disabling upgrades with DANBOORU_USER_UPGRADES_ENABLED="false" works.
2022-05-17 01:24:38 -05:00
evazion 3dbe6ea842 Merge pull request #5166 from NamelessContributor/notes-text-stroke
Notes: allow using -webkit-text-stroke and related
2022-05-16 15:13:15 -05:00
evazion 6b54415c47 Merge pull request #5170 from nonamethanks/fix-fc2-bad-source
Fc2: don't mark valid blog page sources as bad_source
2022-05-16 15:12:07 -05:00
evazion 1ea76624c8 Merge pull request #5172 from nonamethanks/sort-relationships
Tags: sort list of relationships alphabetically
2022-05-16 15:11:58 -05:00
evazion 1eb15da7c5 upgrades: add authorize.net integration.
Add integration for accepting payments with Authorize.net.

https://developer.authorize.net/hello_world.html
2022-05-15 01:47:45 -05:00
evazion 4b65e96abc upgrades: rename stripe_id to transaction_id
* Rename the stripe_id column to transaction_id.
* Add a new payment_processor column to identity the processor used for
  this transaction (and hence, which backend system the transaction_id is for).
2022-05-15 01:05:24 -05:00
evazion 6de527f064 upgrades: show login and create account links for anon users. 2022-05-15 01:05:21 -05:00
evazion 39a9c7efa0 Merge pull request #5164 from nonamethanks/tag-deprecation-edit-form
Tags: show better message in edit form if tag lacks wiki
2022-05-11 21:00:26 -05:00
evazion c5d906e93f Merge pull request #5163 from NamelessContributor/footer-commit-hash
Add back current commit hash to site footer.
2022-05-11 20:59:58 -05:00
evazion c73ff4fbd9 Update Ruby gems and Yarn packages. 2022-05-11 00:23:53 -05:00
evazion bb461d82b6 Fix #5162: NoMethodError in MastodonApiClient#commentary without credentials set 2022-05-11 00:17:49 -05:00
evazion 7573c6dfc9 Merge pull request #5160 from NamelessContributor/feat-data-is-deprecated
Add data-is-deprecated attribute to tags
2022-05-11 00:10:13 -05:00
evazion 4360573af0 upgrades: update text. 2022-05-10 12:20:11 -05:00
evazion 1720246cb9 Remove Twitter/Github/Discord links from site footer.
Our new payment processor demanded that we remove our social media links
from the site. Removing these for compliance. It doesn't make sense, I know.
2022-05-10 09:56:14 -05:00
evazion 32d77d57ec upgrades: update upgrade page text. 2022-05-09 14:16:58 -05:00
evazion af96f78a49 routes: change /static/contact to /contact; /user_upgrades/new to /upgrade. 2022-05-09 14:16:58 -05:00
evazion f65021fa01 config: move contact page info to a config option.
Make the info on the contact page configurable instead of hard coded.
2022-05-09 14:16:58 -05:00
evazion 80f3778616 Merge pull request #5159 from nonamethanks/fix-furaffinity-ascii-urls
Furaffinity: fix uploads for non-ascii image urls
2022-05-09 14:16:32 -05:00
evazion 638c928c8a Add 18 USC 2257 disclaimer.
Add a 2257 disclaimer and link to it in the site footer.
2022-05-09 02:26:19 -05:00
evazion 763f9aad98 Merge pull request #5156 from NamelessContributor/tooltip-non-web-source
post tooltips: add support for non-web sources
2022-05-08 23:15:13 -05:00
evazion d606b9b4c9 Merge pull request #5155 from NamelessContributor/fix-5154
related tags: fix wiki link adding "undefined" tag
2022-05-08 23:14:37 -05:00
evazion 910846163d Fix #5094: db/populate.rb is broken.
Rewrite db/populate.rb:

* Fix broken code.
* Pull random posts from Danbooru for more realistic data.
* Generate more data (wiki pages, artist commentaries, artist urls).
* Make the amount of data generated configurable with environment variables.
* Use FFaker to generate better random text and usernames.

Usage:

* docker-compose exec danbooru bin/rails runner db/populate.rb # with Docker
* bin/rails runner db/populate.rb                              # without Docker
2022-05-08 22:56:08 -05:00
evazion 067d094cc1 upgrades: add notice that upgrades are temporarily disabled. 2022-05-07 18:25:35 -05:00
evazion 449fd6c49c upgrades: factor out Stripe integration.
Factor out the Stripe code from the UserUpgrade class. Introduce a new
PaymentTransaction abstract class that represents a payment with some
payment processor, and a PaymentTransaction::Stripe class that
implements transactions with Stripe.

Note that we can't completely eliminate Stripe even though we no longer
accept payments with it because we still need to be able to look up old
payments in Stripe.
2022-05-06 22:52:33 -05:00
evazion 0d4c8baed8 upgrades: fix typos on upgrade page. 2022-05-05 20:36:20 -05:00
evazion 52edf5c3be config: don't hardcode safebooru donmain. 2022-05-05 19:09:04 -05:00
evazion 5ec5eeeebf views: add "Privacy" and "Upgrade" links to site footer. 2022-05-05 17:20:52 -05:00
evazion e03601896a upgrades: temporarily disable Gold account upgrades.
Disable upgrades while we migrate away from Stripe.
2022-05-05 17:20:52 -05:00
evazion 7232518f90 upgrades: update FAQs on account upgrade page. 2022-05-05 17:14:22 -05:00
evazion d12485f1c8 users: raise page limit for Gold users from 2000 to 5000.
Gold now has the same page limit as Platinum.
2022-05-05 16:42:17 -05:00
evazion 34038d71ae Fix #5153: Using the child metatag without an id causes unexpected behavior 2022-05-04 23:19:58 -05:00
evazion 4ba993319a media assets: add file_key, is_public columns.
`file_key` is a random 9-character base-62 string that will be used as
the image filename in the future.

`is_public` is whether the image can be viewed without authentication or not.

Users running downstream boorus must run `bin/rails db:migrate` and
`script/fixes/109_generate_media_asset_file_keys.rb` after this commit.
2022-05-04 23:19:53 -05:00
evazion d511a6b6cf posts: fix is_taken_down flag.
The second bit of the `bit_flags` field was previously used for the
`has_cropped` flag, which is still set on many posts, so it's not safe
to reuse it for the `is_taken_down flag.
2022-05-03 06:48:29 -05:00
evazion 2219a64f47 posts: show takedown page for banned artists and posts.
Show a "This page has been removed because of a takedown request" error when
an unauthorized user searches for a banned tag, or tries to view a banned post.
2022-05-03 05:56:14 -05:00
evazion 48b8daa397 posts: add is_taken_down flag.
Posts with the is_taken_down flag are "double-banned" and only visible to moderators.
2022-05-03 05:51:17 -05:00
evazion ac98c142a4 posts: move expunged image to trash folder.
When a post is expunged, move the image to a trash folder so it can be
recovered if needed.
2022-05-03 05:51:09 -05:00
evazion c07b099bf8 Fix #5152: Nicovideo video urls getting bad_source. 2022-05-03 03:59:15 -05:00
evazion 1a89071f2d posts: fix error on post index page when search count times out in safe mode
Fix a nil deference error on the post index page. This happened when
performing a single tag search in safe mode and calculating the number
of search results timed out.
2022-05-02 22:03:33 -05:00
evazion 8d9e53da2b Fix #5145: Add "Category" field to the wiki pages search. 2022-05-02 16:52:11 -05:00