Commit Graph

710 Commits

Author SHA1 Message Date
evazion
b8356c97c1 Add Danbooru Winter Sale. 2021-12-28 14:41:37 -06:00
evazion
0e778f0972 Update Ruby gems and Yarn packages. 2021-12-28 09:47:34 -06:00
evazion
c0610cb809 posts: reduce sidebar width on laptops/tablets.
This allows fitting one more medium-size thumbnail per row on
laptop and tablet size screens.
2021-12-13 05:24:05 -06:00
evazion
487b51efe4 related tags: fix related tag section being hidden.
Fix the related tags section being completely hidden when it was
collapsed. The `.hidden` CSS class that was used by related tags
conflicted with the `.hidden` utility class added in 8841de68ac.
2021-12-10 06:02:46 -06:00
evazion
7976d12cd0 Fix #4930: "Show scores" setting should be preserved
Make "show scores" setting persistent.

The setting is stored in a `post_preview_show_votes` cookie. This means
it's remembered on a per-device basis, but not on a per-account basis.
This is so users without an account can use the setting, and so you can
use different settings on desktop and mobile.

The `view=score` URL param has been replaced by `show_votes=true`. The
`show_votes` URL param overrides the `post_preview_show_votes` cookie.
2021-12-09 15:47:10 -06:00
evazion
3de93f556e posts: make thumbnail size setting persistent.
Make setting the thumbnail size persistent.

The setting is stored in a `post_preview_size` cookie. This cookie can
be overridden by the `size` URL param, like so:

  https://danbooru.donmai.us/posts?tags=touhou&size=180

The `size` param is mainly for testing different sizes without setting a cookie.
2021-12-09 15:46:08 -06:00
evazion
16216070e0 posts: fix tag scripts not working.
If the `size` URL param wasn't present, then `size=null` would be passed
to `/posts/:id.js`, which would fail because `null` wasn't a valid size.

Regression in 8841de68ac.
2021-12-08 23:22:56 -06:00
evazion
aafe250220 posts: make tooltips taller and narrower. 2021-12-08 18:02:55 -06:00
evazion
45dbc7582c Update Ruby gems and Yarn packages. 2021-12-08 03:01:54 -06:00
evazion
8841de68ac posts: add adjustable thumbnail sizes (#4932).
Add a menu in the top right of the post index page that lets you select
the thumbnail size.

This menu is currently hidden until the new thumbnails have been generated.

On desktop, there are five thumbnail sizes:

* Small:    150x150 (https://danbooru.donmai.us/posts?size=150)
* Medium:   180x180 (https://danbooru.donmai.us/posts?size=180)
* Large:    225x225 (https://danbooru.donmai.us/posts?size=225)
* Huge:     270x270 (https://danbooru.donmai.us/posts?size=270)
* Gigantic: 360x360 (https://danbooru.donmai.us/posts?size=360)

On mobile, there are four sizes:

* Small:  150x150 / 3 posts per row (https://danbooru.donmai.us/posts?size=150)
* Medium: 180x180 / 2 posts per row (https://danbooru.donmai.us/posts?size=180)
* Large:  225x225 / 2 posts per row (https://danbooru.donmai.us/posts?size=225)
* Huge:   360x360 / 1 posts per row (https://danbooru.donmai.us/posts?size=360)

There are two extra sizes that aren't listed in the menu:

* 225x360 (https://danbooru.donmai.us/posts?size=225w)
* 270x360 (https://danbooru.donmai.us/posts?size=270w)

These sizes are good for tall thumbnails, but not so much for wide
thumbnails. They aren't listed because in practice they're a bit too big.

The 225x225 and 270x270 sizes are really just 360x360 thumbnails scaled
down in HTML. This means 225x225 and 360x360 thumbnails both use the
same amount of bandwidth.

Thumbnail size is currently a per-search option, not a persistent
account-level setting.

This changes the HTML structure of thumbnails somewhat, so this may
break userscripts and custom CSS.
2021-12-04 06:30:29 -06:00
evazion
e8f9e3ab28 posts: show 2 posts per row on mobile instead of 3.
Three thumbnails per row was pretty tight for most phones since the most
common phone resolution is 360x640. Two thumbnails per row lets us have
thumbnails up to 180x180 in size.
2021-12-02 23:32:17 -06:00
evazion
74e28e14b8 posts: factor out post gallery component.
Factor out thumbnail galleries into a PostGallery component.

This changes the html structure so that post galleries on all pages are
always wrapped in a `.posts-container` class. This fixes an issue with
thumbnails on the pool show page not being aligned correctly on mobile,
like they are on the post index page. This also affected thumbnail
galleries on other pages, like wiki pages and user profiles.
2021-12-02 22:18:00 -06:00
evazion
59f8320d91 votes: fix bug with tag scripting in show score mode.
Fix a bug where scores would disappear when applying tag scripts in show
scores mode.
2021-11-28 01:26:09 -06:00
evazion
5ba6014a4e votes: fix username tooltips not appearing inside other tooltips.
Fix a bug where, when hovering over a username inside a tooltip, the
username tooltip wouldn't appear.

May break 0bf5ac73?
2021-11-25 00:02:25 -06:00
evazion
a45e6b5cfe Fix #4931: Add popup voter list for comments.
Show the comment's upvote and downvote count when you hover over a
comment's score. For mods, show the list of voters as well.
2021-11-24 22:18:48 -06:00
evazion
35c97d0836 mode menu: remove upvote/downvote mode.
Remove the upvote and downvote modes from the post mode menu. These are
unnecessary now since you can use the vote buttons beneath the thumbnails.
2021-11-21 02:36:22 -06:00
evazion
eda23c719a votes: fixup various minor issues.
* Add a gap between thumbnails on mobile.
* Adjust CSS for scores and vote buttons.
* Include "Private favorites" as an incentive on the user upgrade page.
* Fix vote buttons not being visible beneath thumbnails on mobile.
* Fix the "Show scores" link not preserving the current page number.
* Fix vote buttons being unintentionally enabled for all thumbnails by default.
* Fix banned and restricted users being able to favorite posts by
  tagging them with `fav:self`.
* Fix search engines being able to crawl /posts?view=score pages.
* Fix broken tests.
2021-11-20 02:40:18 -06:00
evazion
3ae62d08eb favorites: show favlist when hovering over favcount.
Changes:

* Make it so you can click or hover over a post's favorite count to see
  the list of public favorites.
* Remove the "Show »" button next to the favorite count.
* Make the favorites list visible to all users. Before favorites were
  only visible to Gold users.
* Make the /favorites page show the list of all public favorites,
  instead of redirecting to the current user's favorites.
* Add /posts/:id/favorites endpoint.
* Add /users/:id/favorites endpoint.

This is for several reasons:

* To make viewing favorites work the same way as viewing upvotes.
* To make posts load faster for Gold users. Before, we loaded all the
  favorites when viewing a post, even when the user didn't look at them.
  This made pageloads slower for posts that had hundreds or thousands of
  favorites. Now we only load the favlist if the user hovers over the favcount.
* To make the favorite list visible to all users. Before, it wasn't
  visible to non-Gold users, because of the performance issue listed above.
* To make it more obvious that favorites are public by default. Before,
  since regular users could only see the favcount, they may have
  mistakenly believed other users couldn't see their favorites.
2021-11-20 02:40:18 -06:00
evazion
bd8672681f votes: add vote buttons beneath thumbnails.
Add upvote and downvote buttons beneath thumbnails on the post index page.

This is disabled by default. To enable it, click the "..." menu in the top
right of the page, then click "Show scores".

This is currently a per-search setting, not an account setting. If you
enable it in one tab, it won't be enabled in other tabs.
2021-11-18 04:15:20 -06:00
evazion
5585d1f7d6 votes: show votes when hovering over post score.
Make it so you can hover over a post's score to see the list of public
upvotes. Also show the upvote count, the downvote count, and the upvote
ratio.
2021-11-18 04:15:20 -06:00
evazion
d8a55bd62b comments: fix video duration not being shown on thumbnails
Fix the video duration not being shown on thumbnails on the
https://danbooru.donmai.us/comments page.

BUG: this introduces duplicate HTML ids on the comments page. Post
thumbnails and post comment containers both have the same html ID.
2021-11-02 03:46:48 -05:00
evazion
af5cd83cd7 posts: adjust css of thumbnail video length indicator.
Switch the font to 11px bold Arial. This is more compact and more
readable than 9px Tahoma. Also add a slight border radius and margins
around the indicator to make it stand out from the edge of the image.
2021-10-25 21:17:39 -05:00
evazion
094ed4c11d css: standardize font sizes.
Fix various elements to use standard font sizes instead of ad-hoc sizes.

Noticeable changes:

* Tags in autocomplete are slightly smaller.
* The favorite heart icon on posts is slightly smaller.
* Pool titles on thumbnails in the pool gallery page are slightly bigger.
* The page footer is slightly smaller.
* Timestamps on comments and forum posts are very slightly smaller.
* "Pending"/"approved"/"rejected" labels on forum posts are very slightly smaller.
2021-10-25 05:59:40 -05:00
evazion
7034872132 css: use rem instead of em units instead for font sizes.
Use rem units for font sizes so that font sizes are relative to the root
<html> element, not the parent element.

Fixes an issue where the video duration indicator would be too small on
parent/child thumbnails in post show pages. This was because of nesting
issues with em units. Em units are relative to their parent element, so
if you had a parent element with a font size of 0.8em, and a child
element with a font size of 0.8em, then the final computed font size
would be 0.8*0.8 = 0.64em.
2021-10-25 05:16:59 -05:00
evazion
f1b5c34b4d posts: show length of videos and animations in thumbnails.
Show the length of videos and animated posts in the thumbnail. The
length is shown the top left corner in MM:SS format. This replaces the
play button icon.

Show a speaker icon instead of a music note icon for posts with sound.

Doing this requires doing `.includes(:media_asset)` in a bunch of
places to avoid N+1 queries when we access the post's duration.
2021-10-25 02:56:55 -05:00
evazion
a58aa8efa7 Update Ruby gems and Yarn packages. 2021-10-21 03:27:59 -05:00
evazion
d771f6f41b autocomplete: remove old enter key workaround.
Remove an old workaround designed to prevent pressing the Enter key in
autocomplete from submitting the upload or tag edit.
2021-10-13 03:52:41 -05:00
evazion
206a4b5de5 docker: avoid rebuilding CSS/JS assets on every commit.
Restructure the Dockerfile and the CSS/JS files so that we only rebuild
the CSS and JS when they change, not on every commit.

Before it took several minutes to rebuild the Docker image after every
commit, even when the JS/CSS files didn't change. This also made pulling
images slower.

This requires refactoring the CSS and JS to not use embedded Ruby (ERB)
templates, since this made the CSS and JS dependent on the Ruby
codebase, which is why we had to rebuild the assets after every Ruby
change.
2021-10-13 02:48:30 -05:00
evazion
587a9d0c8f tags: move tag category definitions out of the config file.
Move all the code for defining tag categories from the config file to
TagCategory. It didn't belong in the config because it's not possible to
add new tag categories purely in the config without editing other things
like the CSS.

Also change it so that tag colors are hardcoded in the CSS instead of
generated using ERB. Generating the CSS in ERB meant that the Docker
build had to recompile the CSS on every commit, even when it didn't
change, because it relied on Ruby code outside the CSS that we couldn't
guarantee didn't change.
2021-10-12 21:17:17 -05:00
evazion
4b15e56909 Update Ruby gems and Yarn packages. 2021-10-12 03:00:24 -05:00
evazion
33f3a12dd1 Update Ruby gems and Yarn packages. 2021-09-30 08:24:51 -05:00
evazion
c99d0523bb /media_assets: add basic index and show pages.
* Add a basic index page at https://danbooru.donmai.us/media_assets.
* Add a basic show page at https://danbooru.donmai.us/media_assets/1.
* Add ability to search /media_assets.json by metadata. Example:
** https://danbooru.donmai.us/media_assets.json?search[metadata][File:ColorComponents]=3
* Add a "»" link next to the filesize on posts linking to the metadata page.

Known issues:

* Sometimes the MD5 links on the /media_assets page return "That record
  was not found" errors. These are unfinished uploads that haven't been
  made into posts yet.
* No good way to search for custom metadata fields in the search form.
* Design is ugly.
2021-09-29 07:46:11 -05:00
evazion
95fc3a207c /status: fix formatting of table cells.
Make the table cells on the /status page centered instead of
top-aligned, and make the labels fit on one line.
2021-09-29 06:36:10 -05:00
evazion
04cd6d0d3f newrelic: log screen resolution and pixel density.
Log the user's screen resolution and pixel density so we can make better
decisions about which screen sizes to support.
2021-09-25 06:46:25 -05:00
evazion
e8a09bc400 js: fix eslint warnings. 2021-09-24 08:40:33 -05:00
evazion
b378785582 Fix #3692: Rotate pictures based on metadata
Rotate the image based on the EXIF orientation flag when generating
thumbnails and samples.

Also fix the width and height to be calculated correctly for rotated
images. Vips gives us the unrotated width and height of the image; we
have to detect whether the image is rotated and swap the width and
height manually to correct them. For example, if an image with the
"Rotate 90 CW" flag is 100x500 before rotation, then after rotation it's
500x100. This should fix #4883 (Exif rotation breaks Javascript fit-to-window)

We also have to fix it so that regenerating a post updates the width and
height of the post, in the event that it's a rotated image.

Finally we set `image-orientation: from-image;` even though it's
probably not necessary.
2021-09-22 11:12:50 -05:00
evazion
9552b41c0a Update Ruby gems and Yarn packages. 2021-09-14 05:39:18 -05:00
nonamethanks
7b817b0a30 Uploads: prevent submission of unfinished uploads 2021-09-08 20:26:53 -05:00
evazion
440d2c807f posts: fix JS errors on non-flash posts when using Ruffle extension.
Fix https://github.com/danbooru/danbooru/issues/4783#issuecomment-912426739:

    Spoke too soon. It works in flash posts, but not in non-flash posts.

    Here's the full trace that happens by trying the Shift-E shortcut
    (tested on https://danbooru.donmai.us/posts/4749304 with the latest
    ruffle for chrome at https://ruffle.rs/#downloads):

    4749304:7 Uncaught TypeError: Cannot read properties of undefined (reading 'appendChild')
        at Object.initialize_ruffle_player (application-237cebbe071cb34ce095.js:1)
        at Object.initialize_all (application-237cebbe071cb34ce095.js:1)
        at HTMLDocument.<anonymous> (application-237cebbe071cb34ce095.js:1)
        at f (857-ff5115a2d6ceb23b4291.js:2)
        at p (857-ff5115a2d6ceb23b4291.js:2)
        at nrWrapper (4749304?q=status%3Aany:7)

Caused by trying to initialize the Ruffle player on non-Flash posts,
because we checked for the existence of the `window.RufflePlayer` object
to tell if we were on a Flash post, but when using the Ruffle browser
extension the RufflePlayer object will always exist.
2021-09-03 05:33:11 -05:00
evazion
34861678cb Fix #4661: Change shortcut for submitting uploads from Enter to Ctrl+Enter
Also fix #4734.
2021-08-28 04:53:33 -05:00
evazion
1f02e1b0e7 Merge pull request #4865 from nonamethanks/fix-url-form-length
Fix url fields in forms not having the same length as other text inputs
2021-08-28 02:04:39 -05:00
nonamethanks
08234c496d Fix url fields in forms not having the same length as other text inputs 2021-08-26 13:32:16 +02:00
evazion
c8d7f94d7e Update Ruffle version. 2021-08-21 04:01:24 -05:00
nonamethanks
89c14717ec Upload page: disallow swf uploads in javascript too 2021-06-21 03:32:16 +02:00
evazion
c7fda2772f posts: fix rare bug with first post.
Fix a rare bug that occurs once per year that causes post 1 to appear
insufficiently festive.
2021-05-23 06:33:29 -05:00
evazion
a2f3ba695c Revert "fix vote buttons."
This reverts commit a0b6047d00.
2021-04-02 03:58:14 -05:00
evazion
a0b6047d00 fix vote buttons. 2021-03-31 23:20:49 -05:00
evazion
fff68e1d16 ruffle: fix issue with ruffle falsely triggering keyboard shortcuts.
Fix issue mentioned in 55980c6fb with Javascript spazzing out on Flash
posts and randomly triggering keyboard shortcuts.

The bug was calling `javascript_pack_tag` twice. This caused the
runtime Javascript chunk to be loaded twice, caused a lot of Javascript
errors that somehow resulted in keyboard shortcuts being triggered.

The fix is to combine both calls into `javascript_pack_tag "application", "flash"`.

hxxps://github.com.rails.webpacker.issues.2932
2021-03-31 22:10:04 -05:00
evazion
55980c6fbf Add Ruffle support for Flash files.
Allow viewing Flash posts with the Ruffle emulator.

Known issues:

* Many flash files aren't fully supported.
* In development it sometimes spazzes out and starts triggering random
  keyboard shortcuts when you press any key. This doesn't happen with
  the browser extension.
* We have to put the .wasm file in the public/packs/js directory because
  Ruffle is hardcoded to search for it there.
* If you're running Nginx, you need to make sure you're serving the
  right MIME type for .wasm files or it won't work.
* We're using Some Random Guy's unofficial NPM package for Ruffle, since the
  Ruffle project doesn't publish an official package themselves. We
  should build our own package.

References:

* https://github.com/ruffle-rs/ruffle
* https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle#configure-webassembly-mime-type
* https://www.npmjs.com/package/ruffle-mirror
2021-03-31 20:20:22 -05:00
evazion
9baac1fec0 autocomplete: increase contrast of selected tag in light mode. 2021-03-24 13:29:27 -05:00