Commit Graph

10128 Commits

Author SHA1 Message Date
evazion
0713751e3c tests: fix user upgrades not being tested in CI. 2021-01-27 16:55:46 -06:00
evazion
716cdb0126 tests: fix broken tests.
* Fix a broken Twitter profile image upload test.
* Skip a broken DeviantArt flash file upload test (flash no longer
  supported by DeviantArt?)
* Skip user upgrade tests when Stripe is not configured.
2021-01-27 00:40:53 -06:00
evazion
3137284292 Update ruby gems and yarn packages. 2021-01-27 00:02:35 -06:00
evazion
0919acb861 unicorn: increase workers, reduce timeout. 2021-01-26 19:52:43 -06:00
evazion
78892e6239 posts: add index on rating column.
Should improve performance for rating:e and rating:q searches. Rating:s
isn't isn't indexed because Postgres is unlikely to use the index for
rating:s searches (the selectivity is too low, ~77% of all posts are
rating:s).
2021-01-26 19:24:18 -06:00
evazion
f7ea4917e5 db: sync production schema with declared schema.
Fix various minor inconsistencies between the production database schema
and the declared schema in db/structure.sql.

* tags.category was a smallint instead of an integer in production.
* The unique_schema_migrations index didn't exist outside production.
* The index_posts_on_tag_index index was called index_posts_on_tags_index
  outside production.
* The posts.tag_index column didn't have a statistics target defined
  outside production.
* ID sequences didn't have `AS integer` defined in production.
2021-01-26 19:19:20 -06:00
evazion
dca53fb0ee /login: fix missing </section> tag. 2021-01-24 21:01:54 -06:00
evazion
019bcc4ed2 uploads: direct anon users to login page.
When an anonymous users tries to go to the new upload page, direct them
to the login page instead of showing them an "Access Denied" error.
Fixes complaints from SEO tools about linking to pages that return a 403
error.
2021-01-24 20:46:01 -06:00
evazion
2c06766c9e gems: workaround meta_request failure in Rails 6.1.
meta_request fails in Rails 6.1 with a `SystemStackError: stack level
too deep` error. Switch to a patched fork until the mainline gem is
fixed.

* hxxps://www.github.com/dejan/rails_panel/pull/177
* hxxps://www.github.com/dejan/rails_panel/issues/178
2021-01-24 19:26:25 -06:00
evazion
7ed4523152 Update ruby gems and yarn packages. 2021-01-24 19:18:04 -06:00
evazion
ab0df8b042 Update CHANGELOG.md 2021-01-23 18:31:48 -06:00
evazion
9a9fbcc398 sessions: fix error when an anonymous user tried to logout.
Fix an exception when a user who was already logged out tried to logout
again.
2021-01-23 18:22:43 -06:00
evazion
b6e06ee6fc Fix #4676: Series pool shown as blue unless hovered.
Broken in 49bc2364 by the use of @extend.

Here's what happened. There are two CSS rules that both apply to pool links:

* a:link { color: var(--link-color); }
* .pool-category-series a { color: var(--series-pool-color); }

These rules have equal specificity (0-1-1). This means the rule that is
defined last takes priority. This means the order in which CSS files are
included matters. 49bc2364 used the @extend directive in a rule for
popup menus, which required an @import, which changed the order of the
CSS files, which made the a:link rule suddenly take priority over the
series pool rule.

The proper fix would be to use Sass's new @use directive instead of
@import, but that requires the latest version of Sass, which requires
the latest version of Webpacker, which we can't upgrade to yet because
of breaking changes.

The real moral of the story is: our CSS is very fragile because of
specificity rules. It's very important that rules are defined in a
certain order, otherwise our CSS will break.

* https://sass-lang.com/documentation/at-rules/use
* https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
2021-01-23 16:01:08 -06:00
evazion
b689c9cbed comments: add uniqueness constraint on votes. 2021-01-23 14:44:11 -06:00
evazion
5061b0a013 comments: change 'Shortlink' to 'Copy ID'. 2021-01-23 14:34:53 -06:00
evazion
5fd33ad545 posts: fix favorite icon.
Fix the favorite button using the outlined heart icon instead of the
solid heart icon.
2021-01-23 14:33:45 -06:00
evazion
7629a99030 Fix #4675: Comment tooltip doesn't show properly on phone.
Possible fix for #4675. This is still wonky; tapping the menu icon now
opens the menu, but doesn't close it. You have to tap outside the menu
to hide it.
2021-01-23 01:16:46 -06:00
evazion
b5670898fe posts: fix mis-sized upvote icon in advanced tooltips.
Passing a class to svg_icon_tag accidentally overrode the other classes
we tried to set.
2021-01-23 00:45:13 -06:00
evazion
e14bc77249 comments: rename "Post as moderator" to "Sticky" 2021-01-23 00:27:40 -06:00
evazion
3ef1e1bb60 tag relationships: remove redundant tag_matches method.
Already handled by `search_attributes`.
2021-01-22 05:22:53 -06:00
evazion
9d71ece55d comments: remove 2 comments per hour limit.
Remove the rule that Members could only post 2 bumping comments per
hour.

This was frequently misunderstood as meaning that Members could only
post 2 comments per hour. In fact, Members could post an unlimited
number of comments per hour, but the rest of their comments had to be
non-bumping. The error message we showed to users was misleading. Even
our own code misunderstood what this did when describing the config
option.

Gold users also weren't subject to this limit, which was unfair since
Gold users aren't any better at commenting than regular users. The fact
that a large number of users already ignored bump limits and nobody
really noticed indicates that the limit was unnecessary.
2021-01-22 05:16:45 -06:00
evazion
2eecf4d695 comments: let mods click score to see votes. 2021-01-22 04:26:55 -06:00
evazion
bed5fdafb8 comments: add dtext shortlink option to comment menu.
Add a Shortlink menu option to the comment menu. Clicking this will copy
a DText comment shortlink (e.g. `comment #12345`) to the clipboard. You
can middle-click or right-click the menu option to get the full URL.

The menu option is called Shortlink instead of `comment #1234` because
show the full comment ID in the menu makes the menu look too unbalanced.

Note that the `navigator.clipboard` API can only be used in a https://
environment. It won't work in non-HTTPS development environments. ngrok
can help with this.
2021-01-22 03:55:48 -06:00
evazion
2beac62fc3 comments: move Javascript into component.
This is a minor breaking changing for userscripts that may have tried to
hook into our comment Javascript.
2021-01-21 20:08:14 -06:00
evazion
c718667d46 comments: remove unused <a name="comment-#{id}"> element. 2021-01-21 15:41:26 -06:00
evazion
25bf78f9eb comments: fix incorrect comment links in mentions.
Fix mentions incorrectly linking to comments like this:

    https://danbooru.donmai.us/posts/1234#comment-5678

when it should have been this

    https://danbooru.donmai.us/posts/1234#comment_5678

Change comment links to this to ensure they're permanent:

    https://danbooru.donmai.us/comments/5678

The comment show action will redirect from there to the post with the
comment in context.
2021-01-21 15:36:49 -06:00
evazion
168db63807 comments: raise limit to 20 posts per page on /comments index. 2021-01-21 07:58:50 -06:00
evazion
49bc2364bd comments: tweak styling of vote buttons.
* Tweak hover colors for vote buttons.
* Tweak sizes to avoid the vote buttons shifting when the score changes.
2021-01-21 07:58:50 -06:00
evazion
f4216b323f views: change upvote/downvote icons to arrows.
Change the upvote and downvote icons for posts, comments, and BURs from
thumbs-up / thumbs-down icons to up-arrow / down-arrow icons.
2021-01-21 07:58:50 -06:00
evazion
63e3b4b447 views: factor out FontAwesome icons.
Factor out FontAwesome icons into a set of helpers. This is so that it's
easier to keep track of which icons we're using and easier to change
icons globally.
2021-01-21 07:58:50 -06:00
evazion
748fcdddcf forum: fixup forum vote layout issue.
Fix problem with forum votes being laid out in a vertical list instead
of a horizontal list. Broken in 5780ed57.
2021-01-21 07:58:50 -06:00
evazion
c9570e698b comments: add fix script to remove duplicate votes.
There are about 100 duplicate comment votes. This is because there
wasn't a uniqueness constraint in the database to prevent duplicate
votes. This adds a script to remove duplicate votes so that a constraint
can be added later.
2021-01-21 07:58:50 -06:00
evazion
9f313c94d1 comments: remove rule that you can't upvote your own comments.
Remove this rule for several reasons:

* A single upvote usually isn't enough to matter, especially with the
  new comment threshold.
* It felt weird that trying to vote on a comment could fail.
* Disabling the upvote button on your own comments feels weird.
* Most other sites allow you to upvote your own comments.
* You're allowed to upvote your own uploads, so it doesn't make sense
  that you can't upvote your own comments.
2021-01-21 07:58:50 -06:00
evazion
9efb374ae5 comments: allow swapping votes.
Allow users to upvote a comment, then downvote it, without raising an
error or having to manually remove the upvote first. The upvote is
automatically removed and replaced by the downvote.

Changes to the /comment_votes API:

* `POST /comment_votes` and `DELETE /comment_votes` now return a comment
  vote instead of a comment.
* The `score` param in `POST /comment_votes` is now 1 or -1, not
  `up` or `down.`
2021-01-21 07:58:50 -06:00
evazion
c31f2003d9 dtext: change [quote] styling.
Change [quote] styling to Reddit/Github style (greyed out, with a bar on
the left side) instead of traditional forum style (big grey box around
the quote).

Reasons for this change:

* Box style is bulkier, especially for short quotes in comments.
* Box style works poorly for deeply nested quotes.
* Box style looks bad on widescreen monitors, since the quote stretches
  across the full width of the screen.
2021-01-20 04:41:21 -06:00
evazion
5780ed5768 comments: add scores, rework comment menu.
* Add comment scores.
* Rework voting buttons so that you can click the upvote/downvote
  buttons to toggle votes.
* Hide the edit, delete, undelete, and report buttons behind a popup menu.
* Show the upvote/downvote/reply buttons to logged out users. Redirect
  them to the login page instead.
2021-01-20 04:41:21 -06:00
evazion
ccae422961 Factor out popup menu component.
Factor out the popup menu inside user tooltips into a reusable
component.
2021-01-19 20:22:41 -06:00
evazion
90567bfc61 routes: remove unused commentary index route. 2021-01-19 14:07:28 -06:00
evazion
027359a2c1 comments: fix modreport notices being visible to Members.
Fix the "This comment has been reported" notice being visible for
Members.
2021-01-19 06:05:51 -06:00
evazion
40bf74220c comments: add score to search form. 2021-01-19 05:48:41 -06:00
evazion
9af407c94b comments: set default comment threshold to -8.
* Set the default comment threshold to -8. This means that comments are
  hidden at -8 or lower and greyed out at -4 or lower.

* Reset the comment threshold to -8 for anyone with a threshold greater
  than -8. For reference, only about ~3100 users had a non-default
  threshold. About 1600 of those had their threshold reset to -8.

* Change the comment threshold to a less-than-or-equal comparison
  instead of a less-than comparsion. This means that a threshold of 0
  before is the same as a threshold of -1 now. Since everyone's
  thresholds were reset, this only affects people whose thresholds were
  already less than -8, which is so low that the difference shouldn't
  matter much.

* Set the maximum comment threshold to 5. For reference, less than 1% of
  comments have a score greater than 5.

* Set the minimum comment threshold to -100. For reference, the most
  downvoted comment has a score of -60.
2021-01-19 05:48:25 -06:00
evazion
e1e3604f46 comments: rework deleted comments.
Let users see when a post has deleted comments. Show normal users a
'[deleted]' placeholder when a comment is deleted. Show the full comment
to moderators.

Also fix it so that the comment creator can't edit or undelete deleted
comments, and users can't vote on or report deleted comments.

Finally, hide the creator_id, updater_id, and body of deleted comments
in the API.
2021-01-19 04:34:51 -06:00
evazion
07bdc6eab0 comments: rework thresholded comments.
Previously thresholded comments were hidden completely. You had to click
the "Show X hidden comments" button to unhide all hidden comments in a
thread. Now it works like this:

* When a comment is below your threshold, the comment text is hidden and
  replaced by a `[hidden]` link, which you can click to unhide the comment.

* When a comment is at half your threshold (for example, your threshold
  is -8 but the comment is at -4), then the comment is greyed out.

This means that comments aren't completely hidden, they're just
collapsed, so you can see the commenter and the score without unhiding
the comment. It also means you don't have to scroll back up to unhide a
comment, and threads aren't disrupted by comments being secretly
hidden (which is confusing when people are replying to hidden comments,
which forces you to go back up and unhide to find).
2021-01-19 04:07:33 -06:00
evazion
b6008b02b4 Update ruby gems and yarn packages. 2021-01-17 23:28:45 -06:00
evazion
054ac51d47 policies: remove current request from context.
This refactors Pundit policies to only rely on the current user, not on
the current user and the current HTTP request. In retrospect, it was a
bad idea to include the current request in the Pundit context. It bleeds
out everywhere and there are many contexts (in tests and models) where
we only have the current user, not the current request. The previous
commit got rid of the only two places where we used it.
2021-01-17 00:57:59 -06:00
evazion
6671711784 dmails, emails: refactor to use Rails signed_id.
Refactor email verification links and Dmail share links to use the new
Rails signed_id mechanism, rather than our own handrolled mechanism.

For Dmail share links, we have to override some Rails internal methods
so that our old links still work. For email verification links, this
will invalidate existing links, but this isn't a huge deal since these
links are short-lived anyway.

https://api.rubyonrails.org/classes/ActiveRecord/SignedId.html
https://api.rubyonrails.org/classes/ActiveRecord/SignedId/ClassMethods.html
2021-01-17 00:24:02 -06:00
evazion
6ca007ee1f Fix #4670: Replace RequestStore with AS::CurrentAttributes.
This also requires replacing CurrentUser.name with CurrentUser.user.name
because the `name` method had a conflict with CurrentAttributes.
2021-01-16 12:43:20 -06:00
evazion
6f6ec6592d Fix #4668: Add running commit to /status page. 2021-01-16 12:13:14 -06:00
evazion
32dd14f461 Remove /admin/dashboard page.
This page was just a combination of the forum listing and the bulk
update requests listing. It got zero hits in the last week.
2021-01-16 03:32:11 -06:00
evazion
0306cc16b9 modreports: add search form to /moderation_reports. 2021-01-16 02:19:29 -06:00