Commit Graph

444 Commits

Author SHA1 Message Date
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
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
evazion
efe5111a9e js: bundle jQuery with Webpack.
Include jQuery in our Webpack bundle instead of loading it from CDNJS.
This means we no longer load any Javascript libraries from third party
sites.
2020-06-30 23:41:47 -05:00
evazion
94490eb57f Fix #4492: Switch from qtip2 to tippy.js. 2020-06-30 22:40:40 -05:00
evazion
5f05a41fbc Fix #4468: Tag edit mode on posts view applies taglist to wrong post. 2020-06-30 15:20:59 -05:00
evazion
883856d4af simple form: refactor DText form fields to use SimpleForm.
* Refactors DText form fields to use a custom SimpleForm input instead
  of manually generated html. This fixes it so that DText fields use the
  same markup as normal SimpleForm fields, which lets us apply browser
  maxlength validations to DText input fields.

* Fixes autocomplete for @-mentions only working in comments and forum posts.
  Now @-mention autocomplete works in all DText fields, including dmails.
  Known bug: it applies in artist commentary fields when it shouldn't.
2020-06-25 16:28:09 -05:00
evazion
8ef2b7772d Merge pull request #4530 from BrokenEagle/parent-child-status-search
Add ability to search on status of parent/child
2020-06-23 23:53:57 -05:00
BrokenEagle
4acd89838b Add ability to search on status of parent/child 2020-06-21 22:39:21 +00:00
evazion
213766fac9 posts: fix "view original" not working on mobile.
ref: 38f385d1ca (r40000777)
2020-06-18 12:25:45 -05:00
evazion
1ea0141ae1 Merge pull request #4499 from BrokenEagle/fix-4408
Fix notes having absolute coordinates upon creation
2020-06-09 01:36:44 -05:00
evazion
38f385d1ca js, css: fix eslint and stylelint warnings. 2020-06-09 01:35:44 -05:00
BrokenEagle
6f7530533a Fix notes having absolute coordinates upon creation
Notes are not given percent coordinates when created, however moving
or resizing would update the coordinates to percentage. This is why
it was appearing as if the type of coordinates given were random.
2020-06-05 21:53:00 +00: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
91640447c0 Fix antiproxying config options.
Don't embed config options directly in Javascript. Including them in the
Javascript forces us to recompile the Javascript whenever these options
change, which requires us to redeploy the entire site instead of just
restarting the app server.
2020-06-02 20:50:39 -05:00
evazion
a8389c74d8 uploads: fix dropzone previews being stretched. 2020-06-02 03:04:36 -05:00
evazion
8b46d00b9b Add antiproxying protection.
Try to prevent malicious sites like danbooru.me or idanbooru.com from
proxying our site and inserting ads. If we detect that we're not running
on the real site, then we redirect to the real site.
2020-06-01 13:41:15 -05:00
evazion
fb19bf06ce Merge pull request #4490 from BrokenEagle/fix-embedded-notes
Fix embedded notes not being re-editable after note creation
2020-05-29 11:29:12 -05:00
BrokenEagle
a6c64bb69a Fix embedded notes not being re-editable after note creation
The issue is that the body of the embedded notes were being set to
the value which tells the script not to read the original body after
saving a note. This was a poor system prone to issues, so instead a
DOM class is now explicitly added to the notes on note creation and
cleared whenever a note gets saved.

Additionally, the embedded note bodies were standardized to use the
same initial value as non-embedded notes as well.
2020-05-27 23:59:19 +00:00
BrokenEagle
8cab65367c Added mono font 2020-05-25 19:15:35 +00: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
e425870c17 Fix #4027: Search for posts favorited by the fav group order. 2020-04-27 13:11:07 -05:00
evazion
35824c9e45 posts: remove AddThis widget.
AddThis apparently pulls in a script from z.moatads.com now. Fuck that.
2020-04-23 13:38:24 -05:00
evazion
94180d77b4 dark mode: fix <kbd> tag colors.
Use a light background for <kbd> tags on the keyboard shortcuts page for
better contrast with the page backgorund.
2020-04-17 00:39:16 -05:00
evazion
e848011080 Fix #4406: Add "commentary:" metasearch.
Add:

* commentary:true (posts with commentary)
* commentary:false (posts without commentary)
* commentary:translated (posts with translated commentary)
* commentary:untranslated (posts with untranslated commentary)
* commentary:"text" (posts where any commentary field matches "text")

Known issues:

* There's no way to escape the true, false, translated, or
  untranslated keywords to do a literal text search for commentaries
  containing one of these keywords.

* Negated searches may be slow. Using a left outer join instead of a
  subquery would be faster in most cases, but negating it is harder.
2020-04-17 00:11:00 -05:00
evazion
9901161bbf search: rename artcomm metatag to commentaryupdater.
* Rename the artcomm:<user> metatag to commentaryupdater:<user>.
* Add support for negated -commentaryupdater:<user> searches.
2020-04-16 21:06:51 -05:00
evazion
bfdb0a4f5e notes: fix note text vertically overflowing note body.
Can happen when the translator intentionally sets a note body height
that's too small for the note and it causes the note text to overflow.

ref: https://danbooru.donmai.us/forum_topics/9127?page=301#forum_post_164787
2020-04-07 14:16:51 -05:00
evazion
b3238c5dbe dtext: fix scrunched table columns.
Fix table columns being collapsed to one character wide in certain
cases. Caused by setting `word-break: break-word` on div.prose, which
was needed to stop very long unbroken strings making columns too wide,
but has the opposite effect of making columns too narrow in other cases.

Example: https://danbooru.donmai.us/forum_topics/13868?page=28#forum_post_164950
2020-04-07 14:05:46 -05:00
evazion
8773c7e87f Merge pull request #4369 from BrokenEagle/post-version-fixes
Various post version fixes
2020-04-04 02:55:37 -05:00
evazion
dda47f15b0 Merge pull request #4350 from BrokenEagle/fix-relationship-previews
Fix relationship preview alt text overflowing
2020-04-04 02:34:03 -05:00
evazion
56ea6b9ec5 Merge pull request #4387 from BrokenEagle/embedded-note-alignment
Add additional settable attributes for embedded notes alignment
2020-04-04 02:20:24 -05:00
evazion
522c8c219f Merge pull request #4373 from BrokenEagle/note-fixes
Various note fixes
2020-04-04 01:17:32 -05:00
evazion
25cca328b2 Fix #4388: Missing newline in upload form error. 2020-04-03 23:44:02 -05:00