Commit Graph

823 Commits

Author SHA1 Message Date
evazion
adc5bbf906 posts: fix paginator not appearing when all posts are hidden.
Fix the paginator not appearing when all posts on the page are hidden,
because of deleted posts, banned artists, censored tags, or non-safe
posts in safe mode. This prevented navigating to the next or previous
page.
2022-01-14 22:07:38 -06:00
evazion
c1a1741d20 posts: add z=N URL param to searches and tag lists.
Add a `z=N` param to the URL when doing a search from the search box, or
when clicking a link in the tag list. This is to gather data on how
often the links in the tag list are used, and whether it's more common
to click tags in the tag list or to perform searches manually.

This is temporary and will be removed when enough data is collected.
2022-01-12 10:36:14 -06:00
evazion
1518c3c4be posts: fix search queries not being logged to NewRelic in some cases (#4900)
Fix the /posts index controller not logging the normalized search query
to NewRelic when the search failed, either because of a tag limit error,
a search timeout, or a RSS feed rate limit error.

Also don't log the number of search results when it's an API request or
failed search. This is to avoid doing a potentially slow full post count
when it's not otherwise needed.
2022-01-11 13:39:30 -06:00
evazion
698d732667 Fix #4878: Disapproval messages appear out of order.
Display disapproval messages in oldest-to-newest order.
2022-01-11 12:27:56 -06:00
evazion
379775d10d Remove HTML data attributes from thumbnails #4943
Remove most data attributes from thumbnails, except the ones used by our
own Javascript.
2021-12-16 15:48:07 -06:00
evazion
0997f5595e posts: increase default thumbnail size.
* Increase the default thumbnail size from small (150x150) to medium (180x180).
* Change the mobile layout to use three posts per row instead of two for small thumbnails.

Parent/child posts are still 150x150 to avoid taking up even more space above posts.
2021-12-13 05:23:38 -06:00
evazion
e04892fb38 posts: use 180x180 thumbnails in place of 150x150 thumbnails.
For small thumbnails, use 180x180 thumbnails scaled down to 150x150.
This is so we can get rid of 150x150 images and just use 180x180 for
both small and medium size thumbnails.

Also fix RSS feeds, XML sitemaps, and Discord embeds to use 360x360
thumbnails instead of 150x150 thumbnails.
2021-12-13 05:23:38 -06:00
evazion
bf022e858a seo: prevent crawlers from crawling /posts/:id/favorites. 2021-12-10 01:46:01 -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
7e57ae7d3c posts: inline partials in posts/index template.
Make the posts/index template easier to read by putting everything in
one file, instead of splitting it up into a bunch of partials that
aren't used anywhere else.
2021-12-08 03:01:54 -06:00
evazion
396062869a posts: fix thumbnails on comment and modqueue pages.
Fix thumbnails being fit-to-width instead of a fixed size on the
/comments and /modqueue pages, which caused the columns to be misaligned.
2021-12-05 16:39:24 -06:00
evazion
2e6f480d07 pools: fix pool gallery page layout.
Fix the /pools/gallery page layout being broken by 8841de68a.

This required refactoring the PostGalleryComponent to take a set of
PostPreviewComponents instead of a set of Posts.

The upshot is that it's technically possible to have adjustable
thumbnail sizes on the pool gallery page now (although this is not yet
exposed in the UI).
2021-12-05 02:52:07 -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
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
0baca68a37 search: make order:random truly random; add random:N metatag.
Make the `order:random` metatag truly randomize the search. Add a
`random:N` metatag that returns up to N random posts, like what
`order:random` did before.

`order:random` now returns the entire search in random order. Before it
just returned a pageful of pseudorandom posts. This will be more
accurate for small searches, but slower for large searches. If
`order:random` times out, try `random:N` instead.

The `random:N` metatag returns up to N pseudorandom posts. This is
faster than `order:random` for large searches, but for small searches,
it may return less than N posts, and the randomness may be biased. Some
posts may be more likely than others to appear. N must be between 0 and
200.

Also, `/posts?tags=touhou&random=1` now redirects to `/posts?tags=touhou+random:N`.
Before the `random=1` param acted like a free `order:random` tag; now it
redirects to a `random:N` search, so it counts against your tag limit.
2021-11-25 18:14:34 -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
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
126046cb69 posts: remove rating, note, and status locks.
Remove the ability for users to lock ratings, note, and post statuses.

Historically the majority of locked posts were from 10+ years ago when
certain users habitually locked ratings and notes on every post they
touched for no reason. Nowadays most posts have been unlocked. Only a
handful of locked posts are left, none of which deserve to be locked.

The is_rating_locked, is_note_locked, and is_status_locked columns still
exist in the database, but aren't used.
2021-09-27 22:32:30 -05:00
evazion
eab4e165b1 posts: update safe mode help link.
Change this message:

    2 post(s) on this page were hidden by safe mode. Go to Danbooru or
    disable safe mode to view them (learn more).

To link to [[help:safe mode]] instead of [[help:user settings]].
2021-09-11 19:48:15 -05:00
evazion
2d976cf557 posts: remove has_dimensions? method.
All posts have non-null width and height now that unsupported filetypes
have been purged.

https://danbooru.donmai.us/forum_topics/18027
2021-09-02 05:58:45 -05:00
nonamethanks
66e6d235c1 Posts sidebar: add link to tag discussions in forums 2021-06-21 16:42:38 +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
ca8bfb9149 Update Ruby gems and Yarn packages. 2021-05-15 02:48:13 -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
d906de8192 Merge pull request #4773 from nonamethanks/delete-notice
Add embed wiki to delete dialog
2021-03-23 00:42:39 -05:00
evazion
fd09cc5e96 posts: fix Download link not respecting tagged filenames option.
Fix bug reported in forum #182766:

    The Download button on the posts page does not respect the Disable
    tagged filenames user setting. Tags are included in the filename when
    clicking the Download button even when the Disable tagged filenames
    setting is set to Yes. Right click -> Save As on the image still
    respects the setting.
2021-03-20 02:14:23 -05:00
nonamethanks
e7e0c2314d Add embed wiki to delete dialog 2021-03-20 05:45:34 +01:00
evazion
e1ef94faf7 sources: factor out 'Fetch source data' box into view component. 2021-02-26 01:24:30 -06:00
evazion
af84314c38 posts: remove dead has_ugoira_webm? code. 2021-02-18 04:05:18 -06:00
evazion
75b0c9e9aa iqdb: block crawling of Find Similar links. 2021-02-16 15:32:43 -06:00
evazion
b8d95ace64 css: adjust form input box sizes.
Adjust input boxes to fit the screen better on mobile, and to use
consistent sizes throughout the site (no ad-hoc overrides to make
certain input boxes a bit bigger in random places).

On desktop, this makes most input boxes a bit taller and narrower. On
mobile, it makes input boxes the full width of the screen.

This most notably affects the tag edit box, the comment and forum
post box, the wiki page edit box, and the commentary box.
2021-02-16 09:28:38 -06:00
evazion
1e80540a04 css: refactor CSS to use Tailwind-style utility classes.
Refactor CSS to use standard Tailwind-style utility classes instead of
ad-hoc rules. This eliminates a lot of single-purpose rules for specific
UI elements and standardizes margins to be more consistent throughout
the site.

Utility classes are defined manually on an as-needed basis instead of
importing Tailwind as a whole. Naming conventions mostly follow
Tailwind's conventions, otherwise they follow Bootstrap.

* https://tailwindcss.com/docs/
* https://getbootstrap.com/docs/5.0/utilities/spacing/
2021-02-16 09:28:38 -06:00
evazion
7b4bab54af artists: prevent Google from indexing banned artists.
Prevent search engines from indexing artist pages, wiki pages, and tag
searches for banned artists.
2021-02-07 23:28:50 -06:00
evazion
3f6e7ff6b5 Fix #4701: Odd behavior on older versions of Chrome.
Regression caused by the upgrade to Webpacker 6.0 in 90cd3293e. This
caused various Javascript errors in old versions of Chrome, which
somehow resulted in the keyboard shortcut for visiting the next page
being triggered when you pressed any key.

Specifically, the mobx library (used by the TagCounter component) called
`Object.entries`, which isn't available in Chrome 49, and for some
unknown reason this triggered the buggy shortcut behavior.

`Object.entries` is supposed to be automatically polyfilled by Babel to
support old browsers, but something changed in Webpacker 6 that broke
this and I couldn't get it working again. The probable cause is that
Webpacker 6 no longer transpiles code inside ./node_modules by default,
which means that any libraries we use that use new Javascript features
won't get transpiled down to support old browsers, but even after fixing
that it still didn't work. The workaround is to just drop mobx and
preact entirely to avoid the issue.
2021-02-07 05:53:32 -06:00
evazion
620c9e9ac9 Fix #4697: Better UX for disabling tooltips. 2021-02-05 02:37:02 -06:00
evazion
1f637867a4 tags: refactor tag lists to use ViewComponent. 2021-02-05 02:37:02 -06:00
evazion
3e9184ff1e Merge pull request #4693 from nonamethanks/fix-4692
Post sidebar: ignore metatags for the tag history link
2021-02-04 00:34:16 -06:00
nonamethanks
efa20d8e53 Post sidebar: ignore metatags for the tag history link 2021-02-01 19:02:54 +01:00
evazion
27cac98516 posts: eliminate pool_id, favgroup_id url params.
Replace the `pool_id` and `favgroup_id` url params:

    https://danbooru.donmai.us/posts/123?pool_id=456
    https://danbooru.donmai.us/posts/123?favgroup_id=456

with the `q` param:

    https://danbooru.donmai.us/posts/123?q=pool:456
    https://danbooru.donmai.us/posts/123?q=favgroup:456
2021-01-29 23:01:44 -06:00
evazion
1e778dbbf6 posts: factor out post navbar into component.
* Factor out the post navbar into a component. The post navbar is the
  part of the post containing the current search, the list of pools, and
  the list of favgroups, along with next/prev navigation links.

* Change navbar markup: remove various unused CSS classes/IDs, change
  pools to use same markup as favgroups, replace nested <div>'s with
  flat <ul>/<li> list.

* Use CSS to truncate long searches/pool names/favgroup names if they're
  too wide for the screen (especially on mobile).
2021-01-29 21:46:21 -06:00
evazion
ffdd5e6128 posts: make post votes work the same way as comment votes.
Change post votes to work the same way as comment votes:

* Make the upvote arrow blue if you've upvoted the post, or grey if you
  haven't. Likewise for the downvote arrow.
* Make it so you can click the upvote or downvote arrows to undo the vote.
* Don't show any notices when you vote on a post.

Also fix it so that votes work the same way on the posts page, the
comments page, and in the modqueue. Before it wasn't possible to undo
votes on the comments page or in the modqueue.
2021-01-29 02:21:08 -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
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