Commit Graph

674 Commits

Author SHA1 Message Date
evazion
adc1c2c2cc autocomplete: refactor javascript to use /autocomplete endpoint.
This refactors the autocomplete Javascript to use a single dedicated
/autocomplete.json endpoint instead of a bunch of separate endpoints.

This simplifies the autocomplete Javascript by making it so that instead
of calling a different endpoint for each type of query (for users, wiki
pages, pools, artists, etc), then having to parse the results of each
call to get the data we need, we can call a single endpoint that returns
exactly what we need.

This also means we don't have to parse searches clientside in order to
autocomplete metatags. Instead we can just pass the search term to the
server and let it parse the search, which is easy to do serverside.

Finally, this makes autocomplete easier to test, and it makes it easier
to add more sophisticated autocomplete behavior, since most of the logic
lives serverside.
2020-12-13 00:45:22 -06:00
BrokenEagle
2ae912a8be Add childlike font 2020-11-14 18:00:08 +00:00
Aaron Franke
191b528ad7 Ensure files end in newlines (POSIX compliance) 2020-10-04 05:13:39 -04:00
evazion
c295e233f2 Fix #4597: <code> blocks no longer render as monospace for notes. 2020-08-21 21:14:42 -05:00
evazion
fee68b6dd9 css: fix input box size in inline forms. 2020-08-18 11:08:02 -05:00
evazion
d98dd0bb6d ugoiras: don't initialize notes on ugoiras.
Fixes note font scaling increasing the size of the ugoira playback controls.
2020-08-18 11:06:19 -05:00
evazion
d072ef98ba css: don't use monospace font for textareas.
This changes the font in text input boxes (including the tag edit box)
from monospace to Verdana.
2020-08-16 15:17:40 -05:00
evazion
44cbce9855 css: factor out fonts to css variables. 2020-08-16 15:01:28 -05:00
evazion
317cfe19b4 flags: only show current flag on flagged posts.
* Only show the current pending flag on flagged posts. Don't show old flags.

* Don't show both the "This post was flagged for review" and the "This
  post was flagged and is pending" notices.
2020-08-16 14:31:47 -05:00
evazion
7eb9f0b75e appeals: only show current appeal on appealed posts.
* Only show the current pending appeal in the "This post was appealed"
  notice. Don't show old appeals.

* Don't show both the "This post was deleted" and the "This post was
  appealed" notice on appealed posts. Only show the "This post was
  appealed" notice.

* Show "no reason" if no appeal reason was given.
2020-08-16 14:31:47 -05:00
evazion
06564b25ca autocomplete: add status:appealed to autocomplete. 2020-08-12 22:40:17 -05:00
evazion
3d3b5262cc uploads: don't show translated commentary in tag edit dialog. 2020-08-12 11:02:11 -05:00
evazion
3a17b5a13e flags/appeals: replace is_resolved flag with statuses.
Replace references to the `is_resolved` field with the `status` field.
Post flags were marked as resolved when a post was approved (but not
when the post was deleted because it went unapproved). The status field
supercedes the resolved field.
2020-08-07 19:24:57 -05:00
evazion
afc07d8adf css: fix padding beneath buttons in dialog boxes.
Fix not having any space between the Submit / Cancel buttons and the
bottom of the dialog box. For some reason this only happens in
production, not development.
2020-08-07 10:35:13 -05:00
evazion
ad2ad295af Merge pull request #4560 from BrokenEagle/fix-tooltip-initialize
Fix tooltips to allow for reinitialization
2020-08-07 10:02:32 -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
5aa7019cfe tag counter: fix clicking related tags not updating counter. 2020-08-03 23:18:11 -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
BrokenEagle
0bf5ac7374 Fix tooltips to allow for reinitialization
When Tippy is delegated to the same element more than once, that
prevents the destroy method from working, which makes it so that
users cannot change the settings and then reinitialize the tooltips.

To this end, each delegate() call is now given a different selector.
Additionally, the tooltips are given their own separate <div>'s so
that something like the second delegate() call in the UserTooltips
module can be given its own unique selector.
2020-07-28 16:37:28 +00: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
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
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
evazion
88bbd1e3f0 users: add username tooltips. 2020-07-13 17:09:03 -05:00
evazion
d7f489b68e users: get rid of the .with-style class.
Replace with `body[data-current-user-style-usernames="true"]` instead.
2020-07-13 17:08:53 -05:00
evazion
2219a96d2e pool.js: remove leftover recent pools code.
Removed in 1e3c97e4.
2020-07-08 11:33:10 -05:00
evazion
7bfea5cd19 js: drop stupidtable plugin.
This was only used on the saved search index. It let you click on column
headers to sort the table by that column. This doesn't make sense now
that saved searches are paginated.
2020-07-08 11:31:45 -05:00
evazion
7dfc783f2c Fix #4537: Forum quoting broken in topics where user has a reply. 2020-07-06 16:02:19 -05:00
evazion
b5fc8fff6e Add privacy policy (#4415). 2020-07-06 02:53:01 -05:00