Commit Graph

455 Commits

Author SHA1 Message Date
evazion
82c09858f2 Remove unused data attributes from <body> tag.
Fixup for 647556761.
2020-06-03 11:51:21 -05:00
evazion
647556761b Fix antiproxying (again).
Fuck it, just hardcode it. They rewrite certain parts of our markup so
we can't rely on anything in the html.
2020-06-02 23:30:15 -05:00
evazion
63f675b7d6 config: remove enable_post_search_counts option.
Enable by default if reportbooru is configured, otherwise disable.
2020-06-02 14:41:06 -05:00
evazion
20f8a26709 tests: fix rails 2.7 keyword parameter deprecation warnings. 2020-05-25 01:48:46 -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
8b5763652d link_to_user: remove unused raw_name option. 2020-04-30 17:46:35 -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
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
dd0d9dff4a search: move misc search parsing helpers to PostQueryBuilder.
* Move various search parser helper methods (`has_metatag?`,
  `is_single_tag?` et al) from PostSets and the Tag model to
  PostQueryBuilder.

* Fix various minor bugs stemming from trying to check if a search query
  contains certain metatags using regexes or other adhoc techniques.
2020-04-23 01:51:30 -05:00
evazion
3dab648d0e search: refactor PostQueryBuilder class methods into instance methods.
* Make scan_query, parse_query, normalize_query into instance methods
  instead of class methods. This is to a) clean up the API and b)
  prepare for moving certain tag utility methods into PostQueryBuilder.

* Fix a few cases where a caller used scan_query when they should have
  used split_query or parse_tag_edit.
2020-04-22 19:38:17 -05:00
evazion
a93a902982 posts/index: only show tag change notices for members.
This is to reduce Redis calls per second.
2020-04-21 15:06:25 -05:00
evazion
7726563733 search: refactor scan_query callers to use split_query.
Refactor to use split_query instead of scan_query to split a query on
spaces. Preparation for refactoring scan_query into something smarter.
2020-04-19 02:54:44 -05:00
evazion
ab4d596ac2 Fix #4405: Post version table css doesn't keep ratio at smaller resolutions.
Bug: extremely long sources cause the Tags column to become extremely
wide. Caused by the source link not having the word-break property set.

Fix: use post_source_tag, which lets the `a[rel=external] { word-break: break-word; }`
rule take effect.

Example: https://danbooru.donmai.us/post_versions?search%5Bpost_id%5D=3809742
2020-04-17 01:46:14 -05:00
evazion
b2ee1f0766 ip bans: add hit counter, deleted flag, new ban type.
* Make IP bans soft deletable.
* Add a hit counter to track how many times an IP ban has blocked someone.
* Add a last hit timestamp to track when the IP ban last blocked someone.
* Add a new type of IP ban, the signup ban. Signup bans restrict new
  signups from editing anything until they've verified their email
  address.
2020-04-06 14:13:22 -05:00
BrokenEagle
6aa0adb738 Make the post versions more like the old format
- "Current" is now most like the old format
-- It is therefore now the default for post versions
- Only show the actual edits in their own column
- Show the current state at that version in another column
- On the "previous" view, don't double-show full list of tags for
  the first post versions, so leave edits blank
2020-03-28 06:29:41 +00:00
evazion
1af6850c7c posts: add "view original" sidebar option.
* Add a "View original" sidebar option.
* Rename the "View large" sidebar option to "View smaller".
* Remove the "Loading..." message when switching image sizes.
* Fix the V hotkey not working after using it once.
* Change #image-resize-link to .image-view-original link (note that
  there are two of these links now, one in the notice bar and one in the
  sidebar).
* Add a `data-post-current-image-size` attribute on the <body> element
  and use it to control visibility of links and notices.
2020-03-26 22:03:47 -05:00
evazion
50b0b79891 comments: adjust link to howto:comment.
Replace the giant banner about reading the comment guidelines with a
smaller link to howto:comment beneath the comment text box.
2020-03-24 18:32:30 -05:00
evazion
f23df47c09 ip addresses: add ip address show page.
* Add IP address show page at /ip_addresses/1.2.3.4.
* Add "Details", "Ban IP", "Ban User" options to the /ip_addresses listing.
2020-03-23 01:48:59 -05:00
evazion
50fa674a3e pundit: convert emails to pundit. 2020-03-20 18:03:01 -05:00
BrokenEagle
e23ee170f5 Add alternate comparison types to versions
- The types are:
-- Previous: The default and the previously used type
-- Subsequent: Compares against the next version
-- Current: Compares against the current version
- Allow switching between comparison types in index and diff views
-- Have links vary depending upon current comparison type
2020-03-17 18:31:20 +00:00
BrokenEagle
a95e57d938 Move more logic to the helper modules
- Diff view changes
-- Only show pool description changes in diff view
-- Conditionally render diff link when applicable values are changed
-- Conditionally show diff view sections when values are changed
- Show renames on index view
-- There is plenty of space
-- This wasn't shown at all for wikis
-- Having to navigate to an alternate page is unwieldy for pools
- Show "posts" as a status on pools
-- This is so all changes among versions are quantified as a status
- Standardize diff/index titles
2020-03-17 18:31:20 +00:00
evazion
41304d6add forum: fix topics with no BURs being marked as approved. 2020-03-11 21:54:17 -05:00
evazion
6504d44223 forum: change BUR counts to status labels.
Use pending / approved / rejected status labels in front of the topic
title instead of a BUR count column. This is to make the forum listing
easier to visually scan for resolved vs unresolved topics.

Labels are only added for topics in the Tags category. This is a hack to
avoid labels on megathreads that have had BURs mistakenly attached to them.

[APPROVED] and [REJECTED] labels are stripped from thread titles to make
the titles cleaner. This is a hack until these titles can be fixed.
2020-03-10 20:13:11 -05:00
evazion
5625458f69 users: refactor password reset flow.
The old password reset flow:

* User requests a password reset.
* Danbooru generates a password reset nonce.
* Danbooru emails user a password reset confirmation link.
* User follows link to password reset confirmation page.
* The link contains a nonce authenticating the user.
* User confirms password reset.
* Danbooru resets user's password to a random string.
* Danbooru emails user their new password in plaintext.

The new password reset flow:

* User requests a password reset.
* Danbooru emails user a password reset link.
* User follows link to password edit page.
* The link contains a signed_user_id param authenticating the user.
* User changes their own password.
2020-03-08 23:18:15 -05:00
evazion
f2d7e42d89 Merge pull request #4301 from BrokenEagle/forum-topic-bur-indicators
Add BUR counters to forum topics index
2020-03-07 23:04:19 -06:00
evazion
967d398c8e search: move query parsing code from tag model to post query builder. 2020-03-06 23:23:38 -06:00
evazion
c0376ebb51 tags/index: don't show aliases when search matches primary tag.
When searching e.g. "*mask*", don't show "surgical_mask <- medical_mask"
because "*mask*" already matches the primary tag.
2020-03-03 03:34:34 -06:00
evazion
cded0f763b approvers: remove "you haven't moderated in awhile" notice.
Remove the nag message when an approver hasn't approved anything
recently. Also remove the modqueue random posts page. As of 3d410398a,
inactive approvers are now warned via dmails.
2020-02-28 14:28:08 -06:00
evazion
984768fcee aliases/implications: share secondary links with tags index. 2020-02-27 20:18:18 -06:00
evazion
ce11485fe0 Remove super voters. 2020-02-23 17:52:38 -06:00
evazion
463b1b734e Add curated posts page.
Add a curated posts page at /explore/posts/curated. Curated posts are
the most favorited posts by contributor-level users (users with
unlimited upload permissions).

Also add an order:curated tag using for use in regular searches.
2020-02-23 17:52:38 -06:00
evazion
e8590afa6d popular posts: fix date range handling.
* Fix the next button for the weekly timescale to jump to the next week,
  not the next day.
* Show the start and end dates for the weekly timescale.
* Use `Time.zone.today` instead of `Date.today` to respect the user's
  timezone setting.
2020-02-23 17:26:08 -06:00
evazion
c53e4e7155 Merge pull request #4300 from BrokenEagle/fix-note-version-dimension-columns
Only show dimension transitions on relevant changes
2020-02-23 01:02:03 -06:00
evazion
d915009407 aliases/implications: remove dead approving/updating code.
Remove the edit, update, and approve endpoints for tag aliases and
implications. These have been useless since individual alias and
implication requests were removed. Aliases and implications could only
be edited or approved if they were in the pending state, which is no
longer possible.

Also remove unused new alias/implication request forms.
2020-02-22 01:20:23 -06:00
BrokenEagle
24ae35aa96 Add BUR counters to forum topics index 2020-02-21 07:14:19 +00:00
BrokenEagle
878a3badd1 Only show dimension transitions on relevent changes 2020-02-20 19:27:38 +00:00
evazion
c4521acb54 burs/index: format update scripts as dtext, same as forum.
Format scripts on the BUR index page as dtext, the same way they're
formatted in forum posts. This means that tags have colors and underlines,
but they don't have post counts. Gathering post counts was too slow.
2020-02-16 19:20:48 -06:00
evazion
ed702b8854 Fix deprecated keyword argument warnings in Ruby 2.7.
Fix this warning:

    warning: Using the last argument as keyword parameters is
    deprecated; maybe ** should be added to the call.

ref: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/#delegation
2020-02-16 18:48:41 -06:00
evazion
7e67d3dd9c views: replace .category-N css classes with .tag-type-N
* Replace the .category-N CSS classes on tags with .tag-type-N. Before
  we were inconsistent about whether tag colors were indicated with
  .category-N or .tag-type-N. Now it's always .tag-type-N.

* Fix various places to not use Tag.category_for. Tag.category_for does
  one Redis call per tag lookup, which leads to N Redis calls on many
  pages. This was inefficient because usually we either already had the
  tags from the database, or we could fetch them easily.
2020-02-16 04:35:37 -06:00
evazion
3ef4d9c7ac artists/summary: link other names to artist searches.
* Link other names to artist searches instead of to the new artist page.
* Remove the asterisk next to other names indicating the name isn't used
  as the primary name of another artist. This is almost always the case.
2020-02-10 17:11:38 -06:00
BrokenEagle
8ff00cfc7d Rework post version view
- Added a changes column explicitly listing all of the changes
-- This makes it more in line with the other views now
2020-02-08 22:57:30 +00:00
BrokenEagle
7b1efd1204 Rework artist versions index view
- Added a changes column explicitly listing all of the changes
-- This makes it more in line with the other version views now
- Does a symmetric difference on the array fields to detect changes
2020-02-08 22:57:29 +00:00
BrokenEagle
de1324098d Rework wiki page versions index/diff views
- Changed to using the diff-body CSS class
-- Removed unnecessary elements from the CSS style file
- Does a symmetric difference on the array fields to detect differences
- Add more descriptors to the status/changes column
- Specifically add <br> to statuses to cause line breaks
2020-02-08 22:57:29 +00:00
BrokenEagle
ede7167bb8 Rework pool versions index/diff views
- Changed to using the diff-body CSS class
-- Removed unneeded CSS style file
- Removed trailing whitespace after the >>> link
-- It was causing artifact line-throughs to appear after the link
- Changed the diff link to only render when a text field has changed
-- Because the post changes are already shown on the index view
- Specifically add <br> to statuses to cause line breaks
2020-02-08 22:57:29 +00:00
BrokenEagle
d62f7e786e Revise display on artist commentary versions index
- All text fields are now shown in their non-rendered form
-- This allows changes to be highlighted with the diff builder
-- The different fields were labeled and separated for easier discernment
-- Fields are only shown if they have text in either the current or previous versions
- Various changes are also verbalized for easier discovery
- The date and the user columns were combined
-- This is more in line with other indexes, plus it saves on space
- The revert listing was changed to use a thumbnail instead of post ID links
-- This makes it more in line with the post versions index
2020-02-08 22:57:28 +00:00
BrokenEagle
d8fd1c212e Revise display on note versions index
- Body now uses the diff builder to highlight changes
-- A generalized diff-body class was added instead of something specific
- The status changes are now verbalized instead of being shown with styles
- The position and sizes are now split up
-- Changes directly reference the previous version
- The date and user columns were combined
-- This is more in line with other indexes, plus it saves space
2020-02-08 22:57:27 +00:00
BrokenEagle
434e031faa Add additional helper methods 2020-02-08 22:49:07 +00:00
evazion
ccb87e13b1 Fix #4282: Related tag search no longer allows the JSON/XML formats. 2020-02-05 14:38:32 -06:00
evazion
6a3a04f6ec dmails: fix unread dmail notice when unread_dmail_count is inconsistent.
Fix an exception when the user's unread_dmail_count is nonzero but they
don't have any unread dmails. This normally shouldn't happen unless the
unread_dmail_count is inconsistent.
2020-02-04 03:45:27 -06:00
evazion
6468df6d44 dmails: allow marking dmails as unread.
* Add ability to mark dmails as unread.
* Fix users.unread_dmail_count to not count deleted dmails.
* Fix show action so that API calls don't mark dmails as read.
* Don't show the unread dmail notice on the /dmails page itself.
* Stop using users.has_mail flag.
2020-02-01 15:49:33 -06:00