Commit Graph

7896 Commits

Author SHA1 Message Date
evazion
1578841a8a Merge pull request #4445 from nonamethanks/hentai_foundry_support
Add hentai-foundry support
2020-05-11 14:01:07 -05:00
evazion
d136a12a65 Fix #4359: Allow builders to move small (artist) tags manually.
Allow builders to approve artist alias BURs. The BUR must contain only
artist aliases or mass updates and each artist must have less than 100
posts.
2020-05-11 00:37:37 -05:00
evazion
e3187e0bd0 tags: add general?, character?, copyright?, artist?, meta?, empty? helper methods. 2020-05-10 23:56:50 -05:00
evazion
49383d393a BURs: rename AliasAndImplicationImporter to BulkUpdateRequestProcessor.
The name AliasAndImplicationImporter is a holdover from the time before
bulk update requests existed. This was a bad name because it doesn't do
any actual importing, instead it's used for parsing and executing bulk
update requests.
2020-05-10 22:18:47 -05:00
evazion
54bae4017d aliases: don't complain about missing wiki pages.
Don't complain about the tags not having wiki pages when requesting tag
aliases.
2020-05-10 21:29:07 -05:00
evazion
71a3cc89fd BURs: don't try to move wikis/artists twice.
* Remove unnecessary rename_aliased_pages option. This option was always enabled.
* Don't try to rename the artist and wiki page inside AliasAndImplicationImporter
  when an alias is approved. This is already handled by TagAlias#process!.
2020-05-10 21:22:22 -05:00
evazion
d675bde187 presenters: inline UploadPresenter. 2020-05-10 19:29:12 -05:00
evazion
a2814364ee presenters: merge PostSetPresenter into PostSet.
Reduce indirection. PostSet is basically a collection of helper methods
for rendering the post index page. PostSetPresenter was a set of helper
methods for rendering the tag list on the post index page. These don't
need to be separated.
2020-05-10 19:28:45 -05:00
evazion
26d6e23377 Fix #4425: Add Danbooru Discord server prominently
* Add Discord, Twitter, and Github links to site footer.
* Remove "Desktop mode" and "Keyboard shortcuts" links from footer.
  Users can use the desktop site option in their browser to switch
  between desktop and mobile mode.
* Remove git hash from footer. Users can hover over the Github logo to
  see the hash instead.
2020-05-08 17:14:22 -05:00
evazion
d7c236b0fc Include git hash in http headers and <meta> tags.
* Add X-Git-Hash http header.
* Add `<meta name="git-hash" content="<hash>">` meta tag.
* Include full hash in development mode.
2020-05-08 17:07:45 -05:00
evazion
71ec4cc498 config: rename twitter_site to twitter_username. 2020-05-08 16:56:21 -05:00
evazion
8dedce0944 Fix #4280: Sidebar taglist is shown for status:unmoderated even when empty.
Fix the related tags sidebar to cache user-dependent searches separately
for each user.
2020-05-08 15:43:52 -05:00
evazion
2749269d5b related tags: refactor to take PostQuery instead of tag string.
Refactor RelatedTagCalculator and RelatedTagQuery to take a PostQuery
object instead of a raw tag string.

* Fixes the related tag sidebar on the post index page having to reparse
  the query and reevaluate aliases.
* Fixes related tags being affected by the current user's safe mode and
  hide deleted posts settings.
2020-05-08 15:40:28 -05:00
evazion
438186a75a search: fix user-dependent searches showing incorrect paginators.
Some searches, such as searches for private favorites or for the
status:unmoderated tag, return different results for different users.
These searches need to have their counts cached separately for each user
so that we don't return incorrect page counts when two different users
perform the same search.

This can also potentially leak private information, such as the number
of posts flagged, downvoted, or disapproved by a given user.

Partial fix for #4280.
2020-05-07 21:02:22 -05:00
evazion
41c6c882c2 search: refactor fast_count to return nil on timeout.
* Refactor fast_count to return nil instead of 1,000,000 if the exact count times out.
* Remove the estimate_post_counts and blank_tag_search_fast_count global config options.
* Replace the hardcoded post count estimates inside fast_count with a
  method that parses Postgres's estimated row count from EXPLAIN.

* /counts/posts.json:
** Remove the `raise_on_timeout` parameter.
** Add an `estimate_count=<true|false>` parameter.
** Return null instead of 1,000,000 if the exact count times out.
2020-05-07 21:02:22 -05:00
evazion
d3e4ac7c17 search: clean up safe_mode / hide_deleted_posts settings.
Change PostQueryBuilder to add rating:s and -status:deleted to the
search inside the constructor instead of inside `#build` and
`#fast_count`. This lets up clean up `#fast_count` so it doesn't have to
reparse the query after adding these tags. This caused aliases to be
evaluated more than once on the post index page.
2020-05-07 21:02:22 -05:00
evazion
67aab0236d search: apply aliases after parsing searches.
Make PostQueryBuilder apply aliases earlier, immediately after parsing
the search.

On the post index page there are multiple places where we need to apply
aliases:

* When running the search with PostQueryBuilder#build.
* When calculating the search count with PostQueryBuilder#fast_count.
* When calculating the related tags for the sidebar.
* When tracking missed searches and popular searches for Reportbooru.
* When looking up wiki excerpts.

Applying aliases after parsing ensures we only have to apply aliases
once for all of these things.

We also normalize the order of tags in searches and strip repeated tags.
This is so that we have consistent cache keys for fast_count.

* Fixes searches for aliased tags being counted as missed searches (fixes #4433).
* Fixes wiki excerpts not showing up when searching for aliased tags.
2020-05-07 13:53:35 -05:00
evazion
f38c38f26e search: split tag_match into user_tag_match / system_tag_match.
When doing a tag search, we have to be careful about which user we're
running the search as because the results depend on the current user.
Specifically, things like private favorites, private favorite groups,
post votes, saved searches, and flagger names depend on the user's
permissions, and whether non-safe or deleted posts are filtered out
depend on whether the user has safe mode on or the hide deleted posts
setting enabled.

* Refactor internal searches to explicitly state whether they're
  running as the system user (DanbooruBot) or as the current user.
* Explicitly pass in the current user to PostQueryBuilder instead of
  implicitly relying on the CurrentUser global.
* Get rid of CurrentUser.admin_mode? (used to ignore the hide deleted
  post setting) and CurrentUser.without_safe_mode (used to ignore safe
  mode).
* Change the /counts/posts.json endpoint to ignore safe mode and the
  hide deleted posts settings when counting posts.
* Fix searches not correctly overriding the hide deleted posts setting
  when multiple status: metatags were used (e.g. `status:banned status:active`)
* Fix fast_count not respecting the hide deleted posts setting when the
  status:banned metatag was used.
2020-05-07 03:29:44 -05:00
evazion
a753ebbea9 posts: move fast_count to PostQueryBuilder. 2020-05-07 03:29:38 -05:00
evazion
d3bd0a9cb5 uploads: fix stray binding.pry. 2020-05-07 03:29:38 -05:00
evazion
d81e7ef191 Fix #4446: Favgroup add menu tickbox missing. 2020-05-06 14:03:45 -05:00
evazion
a6fac80e66 gems: drop ruby-imagespec gem.
* Use libvips instead of ruby-imagespec for reading dimensions of jpeg, png, and gif files.
* Copy the code for reading the dimensions of flash files from ruby-imagespec.

Fixes an incompatibility between ruby-imagespec and the rubocop gem that
prevented us from including rubocop in the Gemfile.
2020-05-06 01:21:35 -05:00
evazion
e477232e02 uploads: factor out image dimension and filetype detection code.
* Add MediaFile abstraction. A MediaFile represents an image or video file.
* Move filetype detection and dimension parsing code from uploads to MediaFile.
2020-05-06 00:33:35 -05:00
nonamethanks
9724b206b0 Add hentai-foundry support 2020-05-05 21:54:34 +02:00
evazion
86e3bd8fbc Fix #4440: Whitespace not trimmed when searching by URL in Artists. 2020-05-04 03:39:41 -05:00
evazion
5feb29ba57 Fix #4441: BUR form: display original request in the error page. 2020-05-04 03:39:41 -05:00
evazion
12d83408ab BURs: make the reason required. 2020-05-04 03:39:41 -05:00
evazion
08fe1c453c BURs: remove "Reason: " prefix from forum posts.
Don't automatically prepend "Reason: " in front of the BUR reason since
this isn't always desirable.
2020-05-04 03:39:41 -05:00
evazion
66c8c1f53f artists: fix artist bans not being recorded in artist history.
Using update_column bypasses callbacks, so a new artist version wasn't
created when the is_banned flag was changed.
2020-05-04 03:39:41 -05:00
evazion
6937c40747 posts/index: update pending BUR notice criteria.
* Only show pending BUR notice on first page.
* Show pending BUR notice for all searches that include a single tag.
2020-05-04 02:49:48 -05:00
evazion
659c31f5cd Fix #3905: Unable to hide Mod Queue posts that were hidden in a separate tab.
Don't show "You have already hidden this post" and "Post is already
active" errors when disapproving a post. Just hide the post anyway
regardless of whether we literally created a post disapproval record.
2020-04-30 20:18:44 -05:00
evazion
8299c969fb Fix #2061: <Link> elements for pools.
Add <link rel="prev"> and <link rel="next"> tags to the forum topic show
page, the pool show page, and the favgroup show page.

This is kind of useless now since Google hasn't used these tags for SEO
for years ([1]), and userscripts can use `#paginator-next` and
`#paginator-prev` to find the next/prev pages, but whatever.

[1]: https://yoast.com/google-doesnt-use-rel-prev-next-for-pagination
2020-04-30 19:57:06 -05:00
evazion
3d3f9ce46c Fix #4343: Presence of metatags shouldn't prevent rendering of the excerpt.
On the post index page, show the wiki excerpt if the search includes a
single tag, even if the tag is negated or the search includes other
metatags.

If the search includes a single pool: or ordpool: metatag, show the pool
excerpt even if the search includes other metatags.
2020-04-30 19:36:28 -05:00
evazion
8b5763652d link_to_user: remove unused raw_name option. 2020-04-30 17:46:35 -05:00
evazion
2cbe4d3672 search: add unaliased:<tag> metatag.
* Add unaliased:<tag> metatag. This allows you to search for a tag
  without applying aliases. This is mainly useful for debugging purposes
  and for searching for large tags that are in the process of being
  aliased but haven't had all their posts moved yet.

* Remove the "raw" url param from the posts index page. The "raw" param
  also caused the search to ignore aliases, but it was undocumented and
  exploitable. It was possible to use the raw param to view private
  favorites since favorites are treated like a hidden tag.
2020-04-30 17:45:07 -05:00
evazion
986bc6e314 search: fix bug in normalize_query for negated metatags.
Forgot to account for negated metatags in normalize_query after e987f070.

Fixes a bug where wrong page counts were displayed for searches
involving negated metatags due to incorrect query normalization.
2020-04-30 01:27:38 -05:00
evazion
828347dfc5 posts/index: fix empty paginator when searching for aliased tags. 2020-04-29 19:33:13 -05:00
evazion
e978f07068 search: allow all metatags to be negated.
Fix not being able to negate the following metatags:

* id (didn't support ranges)
* md5
* width
* height
* mpixels
* ratio
* score
* favcount
* filesize
* date
* age
* tagcount
* pixiv
2020-04-29 02:31:15 -05:00
evazion
dc144f7d7d search: fix noteupdater: vs -noteupdater: mixup. 2020-04-28 01:35:34 -05:00
evazion
b1c494aa34 posts/index: fix bad call to post_search_count_js. 2020-04-28 01:04:17 -05:00
evazion
7324f53752 search: add comment:<text>, note:<text> metatags. 2020-04-27 23:54:54 -05:00
evazion
4b38092b39 search: add order:md5, order:none metatags.
These may be useful for fast pseudo-random shufflings of search results.
2020-04-27 23:47:48 -05:00
evazion
fad217fc2d search: fix -rating:x metatag. 2020-04-27 23:20:54 -05:00
evazion
8cbcec285d search: fix multiple metatag searches not working in some cases.
Bug: in some cases searching for multiple metatags would cause one
metatag to be ignored. For example, a search for {{user:1 pool:2}} would
be treated as a search for {{pool:2}}.

Cause: we used `ActiveRecord::Relation#merge` to combine two relations,
which was wrong because `merge` doesn't combine `column IN (?)` clauses
correctly. If there are two `column IN (?)` clauses on the same column,
then `#merge` takes only the second clause and ignores the first.

Fix: write our own half-baked `#and` method to work around Rails'
broken-by-design `#merge` method.

ref: https://github.com/rails/rails/issues/33501.
2020-04-27 22:29:42 -05:00
evazion
abda687345 posts/index: fix search count tracking.
* Eliminate "&ms=1" url param.
* Only track simple single-tag searches (not multi-tag searches,
  metatags, negated tags, etc).
2020-04-27 19:12:16 -05:00
evazion
2feac0de03 PostQueryBuilder#normalize_query: don't normalize aliases by default.
`normalize_query` is used in certain places on the post index page where
we don't want to pay the cost of looking up tag aliases (namely inside
fast_count, in post_search_count_js, and in tag change notices). Don't
normalize aliases by default unless we need to.
2020-04-27 19:12:16 -05:00
evazion
d5a7fafca1 posts/index: fix several "This tag is under discussion" issues.
Several fixes for the "This tag is under discussion" notice on the post
index page:

* Fix the notice appearing for BURs that aren't pending.
* Fix the notice never going away because of the cache never expiring.
* List all topics when a tag is involved in multiple BURs.
* Link to the forum post instead of the forum topic (fix #4421).
* Optimization: don't check for BURs when the search isn't a simple
  single tag search.
* Add a `tags` field to the bulk update requests table for tracking all
  tags involved in the request (excluding tags in mass updates that are
  negated/optional/wildcards). Known issue: doesn't handle tag type
  prefixes in mass updates correctly (e.g. `mass update foo -> artist:bar`
  doesn't detect the tag `bar`).
* Allow searching the /bulk_update_requests page by tags.

We don't really need to cache the notice here, but we do it anyway to
reduce queries on the post index page.
2020-04-27 19:11:47 -05:00
evazion
911ed34b76 post tooltips: use underscores instead of spaces in pool names.
Don't use pretty names (spaces instead of underscores) for pools in post
tooltips. This is for consistency with tags (which have underscores
here) and for easier copy & pasting.
2020-04-27 14:10:12 -05:00
evazion
47f233003c Fix #4424: Cross-category alias incorrectly changes destination category.
The rule now is that if one of the tags is a general tag then its
category will be changed to match the other tag.
2020-04-27 13:57:19 -05:00
evazion
182e68cfe0 Fix #4423: Series pools should display deleted posts too by default. 2020-04-27 13:22:01 -05:00