Commit Graph

9712 Commits

Author SHA1 Message Date
evazion
0a0a85ee70 Fix #4568: Send appealed posts back to the mod queue
* Include appealed posts in the modqueue.

* Add `status` field to appeals. Appeals start out as `pending`, then
  become `rejected` if the post isn't approved within three days. If the
  post is approved, the appeal's status becomes `succeeded`.

* Add `status` field to flags. Flags start out as `pending` then become
  `rejected` if the post is approved within three days. If the post
  isn't approved, the flag's status becomes `succeeded`.

* Leave behind a "Unapproved in three days" dummy flag when an appeal
  goes unapproved, just like when a pending post is unapproved.

* Only allow deleted posts to be appealed. Don't allow flagged posts to be appealed.

* Add `status:appealed` metatag. `status:appealed` is separate from `status:pending`.

* Include appealed posts in `status:modqueue`. Search `status:modqueue order:modqueue`
  to view the modqueue as a normal search.

* Retroactively set old flags and appeals as succeeded or rejected. This
  may not be correct for posts that were appealed or flagged multiple
  times. This is difficult to set correctly because we don't have
  approval records for old posts, so we can't tell the actual outcome of
  old flags and appeals.

* Deprecate the `is_resolved` field on post flags. A resolved flag is a
  flag that isn't pending.

* Known bug: appealed posts have a black border instead of a blue
  border. Checking whether a post has been appealed would require either
  an extra query on the posts/index page, or an is_appealed flag on
  posts, neither of which are very desirable.

* Known bug: you can't use `status:appealed` in blacklists, for the same
  reason as above.
2020-08-06 20:55:45 -05:00
evazion
e31afd0827 tests: fix broken tests. 2020-08-05 12:41:48 -05:00
evazion
56a4e58510 uploads: fix js error when resizing window.
Fix exception when resizing the window when the preview image isn't
present.
2020-08-05 12:28:24 -05:00
evazion
1a5cda44b9 css: tweak dialog box margins.
Tweak margins around dialog boxes to fix some poorly spaced elements,
especially around buttons and forms controls.
2020-08-05 12:28:24 -05:00
evazion
ef9bc37d9e posts: show ratings in tag edit dialog box.
* Show the rating buttons in the tag edit dialog box.
* Fix the tag counter not showing up in the tag edit dialog box on the
  uploads page.
2020-08-05 12:28:24 -05:00
evazion
605b4eff2a posts: adjust tag edit dialog width.
60% of window width was too large for widescreen monitors.
2020-08-05 12:19:30 -05:00
evazion
f9aa1e9718 posts: don't reparent children when expunging posts.
If an expunged post has children, just set their parent to null instead
of reparenting them. Before we reparented them to the oldest child.
2020-08-04 12:28:20 -05:00
evazion
b57122cf7f posts: log md5 when expunging posts. 2020-08-04 12:12:16 -05:00
evazion
79077df713 posts: don't move favorites to parent when expunging.
Don't automatically move favorites to the parent when expunging a post.
This can be done manually if necessary. Posts shouldn't have their
favorites moved unless they're duplicates, which expunged posts usually
aren't.
2020-08-04 12:04:52 -05:00
evazion
3440010310 posts: allow new accounts to remove tags.
Remove the rule that new accounts can't remove tags (except for tagme
and *_request tags) until their account is a week old.
2020-08-04 12:00:13 -05:00
evazion
bfdc13a4bb Fix #4574: "unknown keyword: :tag_count" when changing tag category.
Bug: Tag#update_post_category_counts effectively called
`update_all("tag_count_general" => 123, :tag_count => 456)`, which led
to an argument error due to the :tag_count symbol being treated as a
keyword argument.

Fix: Don't mess around with `update_all`, just regenerate the tag counts
then `save!` the post. We have to do this in an after_save callback
because we need the updated category to be in the database for `set_tag_counts`
to work. Delete `fix_post_counts` because it was unused.

This is most likely a regression caused by the upgrade of the
newrelic_rpm gem to 6.12. This can only be reproduced in production when
using Newrelic and it didn't happen before the upgrade. Presumably
Newrelic is splatting the arguments when it calls `update_all`, which
causes symbol keys to be treated as keywords.
2020-08-04 10:58:42 -05:00
evazion
5aa7019cfe tag counter: fix clicking related tags not updating counter. 2020-08-03 23:18:11 -05:00
evazion
157cb96551 posts: clean up delete! method.
* Remove unused `ban` and `without_mod_action` options.

* Don't try to set the `is_banned` flag during deletion.

* Don't create modactions for automatic "unapproved in 3 days"
  deletions, only to delete them after the fact.
2020-08-03 20:21:28 -05:00
evazion
bca1f122d0 posts: rework post deletion to use dialog box.
Rework post deletion from using a separate page to using a dialog box,
like flagging.

* Add `DELETE /posts/:id` endpoint.
* Remove `POST /moderator/post/posts/:id/delete` endpoint.
2020-08-03 20:21:28 -05:00
evazion
f1b0e31923 Update ruby gems and yarn packages. 2020-08-03 01:55:44 -05:00
evazion
6b7cd7b972 posts: update tag counter icons. 2020-08-02 18:33:47 -05:00
evazion
b3a4c7aa43 posts: rewrite tag counter widget in React.
Rewrite the tag counter widget (the one above the tag edit box) to use
React. This is a trial run for using React elsewhere.

We actually use Preact instead of React because it's lighter weight.
We use Mobx for state management because it's cleaner than React's
setState or useState.

This incidentally fixes a couple bugs:

* The tag counter wasn't updated when deleting tags with backspace
* The tag counter wasn't updated when pasting in new tags.
2020-08-02 16:48:45 -05:00
evazion
baf0cf87af Fix #4571: Show banner when email verification is required.
* Show a banner if the user is restricted because they signed up from a
  proxy or VPN.

* Add an option to resend the confirmation email if your account has an
  unverified email address.
2020-08-02 16:48:45 -05:00
evazion
a8577b2b94 posts: remove data-* attributes from #image element.
These attributes can be found on the `.image-container` element instead.
2020-07-31 15:16:01 -05:00
evazion
3fe18c57d0 posts: always show "resized to X%" notice on mobile.
Always show the "Resized to X% of original" notice when viewing a sample
image on mobile.
2020-07-31 15:09:56 -05:00
evazion
1c6451b4c7 notes: don't show note bodies while dragging.
Bug: if you moused over another note while dragging a note, it would
trigger a note body popup. This would also happen when drawing out a new
note.

Also fix the drag box for new notes being drawn behind other notes.
2020-07-29 20:08:49 -05:00
evazion
2d002b3d5f notes: fix numerical instability in note positions.
Bug: loading and saving a note without moving it could change the note's
position. Moving a note with the keyboard could also cause unintended
changes to the note's size or position. This was because of floating
point errors when converting from percentage coordinates (floats) to pixel
coordinates (integers).

Fix: store note coordinates as pixel coordinates instead of as
percentage coordinates. Percentages are only used to position notes for
display.

Also fix it so you can resize rotated notes with the keyboard. This was
disabled before.
2020-07-29 19:35:27 -05:00
evazion
edbde657da notes: fix notes not being unselected on click.
Bug: clicking one note then clicking another note wouldn't unselect the
first note.
2020-07-29 16:07:27 -05:00
evazion
dcc869cb07 notes: raise notes on hover.
* Raise notes when hovering over them. This is so that when dragging
  embedded notes, they're not hidden behind other notes. Also so that if
  two notes are overlapping, you can hover over one to raise it over the
  other.

* Replace .hovering class with :hover selector.
2020-07-29 13:09:10 -05:00
evazion
0fbbc60a33 notes: show note bodies after dragging notes.
After dragging a note, show the note body again so you can see how it
looks.
2020-07-29 12:45:52 -05:00
evazion
dd7cd7c1c2 notes: hide note bodies while keyboard moving notes.
Bug: if you used they keyboard to move or resize a note, then the note
body would stay visible, which could get in the way when moving in the
down direction.
2020-07-29 10:13:14 -05:00
evazion
fd8a62ba5e notes: hide note bodies when resizing image.
Bug: if you're editing a note and click preview, then you resize the
image or press V to toggle the image size, then the note body will stay
on the screen in the wrong position.
2020-07-29 10:13:05 -05:00
evazion
5940a40a5a notes: hide note bodies when toggling notes.
Bug: if you clicked preview on a note to show the note body, then clicked
the image to hide the notes, then the note body wouldn't be hidden.
2020-07-29 10:12:51 -05:00
evazion
66ff9bd186 notes: don't mark note as unsaved when previewing.
Bug: previewing a note would mark the note as unsaved even if the note
hadn't been changed.

Fix: mark the note as unsaved when the user types something into the
note edit box, not when the note is previewed.
2020-07-29 10:12:27 -05:00
evazion
43bdb8db86 notes: allow ctrl+enter to save note.
Pressing Ctrl+Enter inside the note edit box will save the note.
2020-07-29 04:26:59 -05:00
evazion
fe557e7e85 notes: allow deleting new notes.
Allow new unsaved notes to be deleted. Before trying to delete a new
note did nothing.
2020-07-29 02:40:59 -05:00
evazion
2cbce9a525 notes: rewrite notes Javascript to object-oriented style.
Rewrite the notes Javascript from a procedural style to an
object-oriented style.

Before the notes Javascript had a lot of problems:

* There was hidden state everywhere, both locally and globally. We had
  state in global variables, in <meta> tags, in DOM data-* attributes
  (on multiple elements), and in jQuery .data() properties (which are
  different from data-* attributes, because they aren't visible in the
  DOM).

* Local state was hard to reason about. There was lots of direct DOM
  manipulation in random places. Functions had to constantly pass around
  note ids and look up elements in the DOM to get the state. State was
  invisible because it was stored as jQuery .data() properties. It was
  hard to follow where state was stored, how it was initialized, and how
  it changed.

* Global state was also a mess. There were a lot of global flags and
  variables only used in specific situations. Almost all of this state was
  unnecessary. Global state also prevented us from doing things like
  loading or unloading posts dynamically, or showing multiple posts with
  notes on the same page.

* There was a lot of duplication of code, especially for placing notes,
  and for loading or saving new notes versus saved notes.

Now the code is organized in an object-oriented fashion:

* The Note class represents a single note. A post has a list of notes,
  and each note object has a Note.Box and a Note.Body. Together these
  objects encapsulate the note's state.

* Notes have methods for doing things like placing note boxes, or showing
  and hiding note bodies, or creating, saving, or deleting notes. This
  makes the JS API cleaner.

* Global state is kept to a minimum.

This is one big patch because it was too hard to make these changes
incrementally. There are a couple minor bugfixes, but the actual
behavior of notes should remain unchanged.

Bugfixes:

* It was possible to enter translation mode, start dragging a new note,
  then press N to leave translation mode while still dragging the note.
  If you did this, then you would be stuck in translation mode and you
  couldn't stop dragging the note.

* Placement of new notes is now pixel-perfect. Before when placing a
  note, the note would shift by 1-2 pixels.

* Previewing an empty note didn't show the "Click to edit" message.

Other noteworthy changes:

* Most global state has been eliminated. There were a lot of flags and
  variables stored as global variables on `Danbooru.Note`. Most of these
  turned out to be either unnecessary or even unused.

* Notes now have an explicit minimum size of 10x10 pixels. Before this
  limit was hardcoded and undocumented.

* A lot of the note placement and note creation code has been simplified.

* `Note.add()` and `Note.create()` have been refactored into `new Note()`.
  Before `Note.add` was used to load an existing note, while `Note.create`
  was used to create a new note. These did the same thing, but had
  slightly different behavior.

* `Note.Box.scale()` and `Note.box.update_data_attributes` have been
  refactored into `Note.Box.place_note()`. Contrary to their names,
  these functions were actually both used to place notes.
2020-07-28 22:06:35 -05:00
evazion
3a3d456bd2 html: standardize font sizes and heading tags.
Standardize font sizes and heading tags (<h1>-<h6>) to be more
consistent across the site.

Changes:

* Introduce font size CSS variables and start replacing hardcoded font
  sizes with standard sizes.
* Change header tags to use only one <h1> per page. One <h1> per page is
  recommended for SEO purposes. Usually this is for the page title, like
  in forum threads or wiki pages.
* Standardize on <h2> for section headers in sidebars and <h3> for
  smaller subsection headers. Don't use <h4>-<h6>.
* In DText, make h1-h4 headers all the same size. Standard wiki style is
  to ignore h1-h3 and start at h4.
* In DText, make h4-h6 the same size as the h1-h3 tags outside of DText.
* In the tag list, change the <h1> and <h2> tag category headers to <h3>.
* Make usernames in comments and forum posts smaller. Also change the
  <h4> tag for the commenter name to <div class="author-name">.
* Make the tag list, paginator, and nav menu smaller on mobile.
* Change h1#app-name-header to a#app-name-header.
2020-07-23 17:34:17 -05:00
evazion
a59afcdf29 Merge pull request #4547 from nonamethanks/fix_4545
Uploads: Check if strategy is enabled before use
2020-07-23 17:28:36 -05:00
evazion
e4af499196 Merge pull request #4307 from BrokenEagle/mobile-mode-default-image-size
Show large image size by default on mobile devices
2020-07-23 16:33:42 -05:00
evazion
da9c2a26ce Merge branch 'master' into mobile-mode-default-image-size 2020-07-23 16:22:37 -05:00
evazion
c4fb43a5b4 Fix #4549: Export the UserTooltips module. 2020-07-16 14:24:06 -05:00
evazion
87b6f59bf0 post tooltips: fix tooltips appearing over one another.
When viewing a list of post #XXX links, like this:

* post #123
* post #456
* post #789

Then moving from bottom to top could cause multiple tooltips to appear
over one another. This was because tippy.js tries to keep tooltips
active while moving towards them, which meant it was possible to
activate a second tooltip while moving towards the first.
2020-07-16 14:23:48 -05:00
evazion
ce61202d14 post tooltips: fix long usernames causing header to overflow.
* Make tooltips wider.
* Abbreviate ratings.
* Truncate long usernames.
2020-07-16 12:53:00 -05:00
evazion
9f53c459c8 wiki: fix titles with invalid space characters.
Fix wiki pages that have titles containing space characters.
2020-07-16 11:42:59 -05:00
evazion
afef9cc9ab tests: fix tests. 2020-07-13 19:30:40 -05:00
evazion
7f2eaeb02b Fix #4541: Possible to create new user while logged in. 2020-07-13 19:25:30 -05:00
evazion
ed79b623cc Fix #4544: Show limited view of other user's uploads on the upload index.
* Show completed uploads to other users.
* Don't show failed or incomplete uploads to other users.
* Don't show tags to other users.
* Delete completed uploads after 1 hour.
* Delete incomplete uploads after 1 day.
* Delete failed uploads after 3 days.
2020-07-13 19:25:30 -05:00
evazion
85f464df83 Fix #4540: Demotion sends "You have been promoted" dmail.
Change message to "Your account has been updated". It's possible for a
user to both gain and lose permissions at the same time, so just say
their account has been updated to make it easier.
2020-07-13 19:25:29 -05:00
evazion
0b52b1622f posts: bring back uploader names. 2020-07-13 19:25:29 -05:00
evazion
45bbb71eba posts: hide ids of restricted posts. 2020-07-13 19:25:29 -05:00
evazion
b5e647dc51 posts: add file type to post info. 2020-07-13 19:25:29 -05:00
evazion
5687c67fc3 posts: autotag video instead of webm/mp4.
Automatically add the `video` tag instead of the `webm` or `mp4` tags.
2020-07-13 19:25:29 -05:00
evazion
1e2e99a941 post tooltips: fix tooltips not appearing on /comments page. 2020-07-13 19:10:15 -05:00
evazion
cf4469f902 users: add dropdown actions to username tooltips. 2020-07-13 17:09:03 -05:00