Commit Graph

10673 Commits

Author SHA1 Message Date
evazion
ad523b3745 Fix #4895: Deleted forum topics visible by default in index.
The bug was that since search parameters normally come from URL request
parameters, a string value is expected here.
2021-10-01 17:14:48 -05:00
evazion
6c7fbb96b3 news updates: use relative time instead of date.
Use relative time on site updates to show when a site update was posted
("5m ago"), instead of the date ("Oct 1").
2021-10-01 05:15:40 -05:00
evazion
1335639298 Merge pull request #4894 from nonamethanks/add-million-scale
Add million scale to humanized number helper
2021-10-01 04:43:50 -05:00
evazion
33f3a12dd1 Update Ruby gems and Yarn packages. 2021-09-30 08:24:51 -05:00
evazion
d128bb71b6 ci: use /tmp for test suite database.
Store the Postgres database for the test suite in /tmp to effectively
run it in a ramdisk and make the test suite run faster.
2021-09-30 08:24:51 -05:00
nonamethanks
13741d88b5 Add million scale to humanized number helper 2021-09-30 14:14:40 +02:00
evazion
cc9d7b8349 Revert "ci: prevent running multiple Docker builds at once."
This reverts commit 9d62f71cd9.

This caused a problem where if you pushed multiple branches or tags at
once, for example to the betabooru and production branches, then the
Docker image would only get built for one branch. This led to deploys
not fetching the latest image.
2021-09-29 08:13:39 -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
f9d25660b8 Fixup regression in 2eb89a835.
Fix regression in 2eb89a835 that broke the modqueue page because the
arguments to `paginated_search` changed and weren't updated here.

Also fix incorrect YARD documentation syntax.
2021-09-29 06:28:53 -05:00
evazion
627e8e1013 cron: fix undefined variable in exception handler (again)
Fixup for a1d4408c2.
2021-09-29 06:04:28 -05:00
evazion
2eb89a8354 Fix #4601: Hide deleted pools by default in pool search.
* On /pools, hide deleted pools by default in HTML responses. Don't
  filter out deleted pools in API responses.

* API change: on /forum_topics, only hide deleted forum topics by
  default for HTML responses, not for API responses. Explicitly do
  https://danbooru.donmai.us/forum_topics.json?search[is_deleted]=false
  to filter out deleted topics.

* API change: on /tags, only hide empty tags by default for HTML
  responses, not for API responses. Explicitly do
  https://danbooru.donmai.us/tags.json?search[is_empty]=false to filter
  out empty tags.

* API change: on /pools, default to 20 posts per page for API responses,
  not 40.

* API change: add `search[is_empty]` param to /tags.json endpoint.
  `search[hide_empty]=true` is deprecated in favor of `search[is_empty]=false`.

* On /pools, add option to show/hide deleted pools in search form.

* Fix the /forum_topics page putting `search[order]=sticky&limit=40` in
  the URL when browsing past page 1.
2021-09-29 05:44:59 -05:00
evazion
4a525c7473 cron: fix maintenance tasks failing to run.
Fix maintenance tasks failing to run in production. In production they
were losing the database connection and not re-establishing it, so they
couldn't queue jobs. `ApplicationRecord.verify!` will check if the
connection is lost and re-establish it if it is.

The database connection was being lost because in production we use a
Kubernetes service IP for the database IP, which is essentially a
virtual IP that maps to the real IP. This mapping is implemented with
IPVS[1][2], which has a default idle connection timeout of 5 minutes. If
the connection isn't used for more than 5 minutes, then it's closed.
Since maintenance only runs once an hour, the database connection would
be lost because it was idle for too long.

1: https://kubernetes.io/docs/concepts/services-networking/service/#proxy-mode-ipvs
2: https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/
2021-09-28 18:06:57 -05:00
evazion
a1d4408c29 cron: fix undefined variable in exception handler. 2021-09-28 16:34:05 -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
3e4492ce33 Update maintenance page.
* Move maintenance.html.bak to maintenance.html.
* Add Github / Twitter / Discord icons to footer.
* Include some CSS to make it look more like the regular site.
* Auto-refresh every 10 seconds.
2021-09-27 19:17:04 -05:00
evazion
738be825ff twitter: include artist name in source URLs on post pages.
Show Twitter sources on post pages like this:

    https://twitter.com/BOW999/status/1261877313349640194

and not like this:

    https://twitter.com/i/web/status/1261877313349640194

We originally removed the artist name because the link would be broken
when the artist changed their name. This is no longer the case.
2021-09-27 11:07:25 -05:00
evazion
4477984d2d navbar: remove ?group_by=post from comments link
Remove the `group_by=post` param from the `https://danbooru.donmai.us/comments?group_by=post`
link in the main navbar. This is unnecessary since it's the default mode
for `https://danbooru.donmai.us/comments`.
2021-09-27 10:48:07 -05:00
evazion
10f2b41ace gems: re-enable meta_request.
Upstream finally released a new version that fixed the "stack level too
deep" bug on Rails 6.1.
2021-09-27 10:43:29 -05:00
evazion
3835a63771 cron: fix tasks not being logged.
Fix maintenance tasks not being logged by the cron daemon because
in production the log level defaulted to `error` instead of `info`.
2021-09-27 10:43:06 -05:00
evazion
50d6cdf140 Use pry for rails console in production.
Use pry for `bin/rails console` in production too, not just in
development. Useful for hotfixes in production.
2021-09-27 10:02:27 -05:00
evazion
ec9e844ab3 jobs: disable timeouts by default for all jobs.
Fix a regression in 52bf4a3a6 that caused certain jobs to timeout.
2021-09-27 09:17:50 -05:00
evazion
0e901b2f84 media file: get duration of animated GIFs, PNGs, and ugoiras.
Add methods to MediaFile to calculate the duration, frame count, and
frame rate of animated GIFs, PNGs, Ugoiras, and videos.

Some considerations:

* It's possible to have a GIF or PNG that's technically animated but
  just has one frame. These are treated as non-animated images.

* It's possible to have an animated GIF that has an unspecified
  frame rate. In this case we assume the frame rate is 10 FPS; this is
  browser dependent and may not be correct.

* Animated GIFs, PNGs, and Ugoiras all support variable frame rates.
  Technically, each frame has a separate delay, and the delays can be
  different frame-to-frame. We report only the average frame rate.

* Getting the duration of an APNG is surprisingly hard. Most tools don't
  have good support for APNGs since it's a rare and non-standardized
  format. The best we can do is get the frame count using ExifTool and the
  frame rate using ffprobe, then calculate the duration from that.
2021-09-27 05:18:25 -05:00
evazion
79fdfa86ae Fix various rubocop warnings. 2021-09-27 00:46:13 -05:00
evazion
a2a4ab887d newrelic: insert browser timing header manually.
Insert the <script> tag that monitors browser timing into the <head>
manually. This is to avoid this error:

    Skipping RUM instrumentation. Unable to find <body> tag in first 50000 bytes of document.

See also https://docs.newrelic.com/docs/agents/ruby-agent/features/new-relic-browser-ruby-agent/#manual_instrumentation
2021-09-27 00:46:13 -05:00
evazion
1f77e6980a puma: disable request timeout in development. 2021-09-26 23:11:12 -05:00
evazion
f8d52e6758 /status: add more information to /status page.
Add the following:

* Container name, machine name, worker id.
* Container uptime, puma uptime, worker uptime.
* Number of requests processed by current worker.
* ExifTool version.

Also change /status page to show information in tables instead of lists.
2021-09-26 23:11:08 -05:00
evazion
52bf4a3a6b maintenance: break maintenance tasks into individual jobs.
Break the hourly/daily/weekly/monthly maintenance tasks down into
individual delayed jobs. This way if one task fails, it won't prevent
other tasks from running. Also, jobs can be run in parallel, and can be
individually retried if they fail.
2021-09-26 20:38:30 -05:00
evazion
7d3e491dc6 posts: stop autotagging huge_filesize.
https://danbooru.donmai.us/forum_topics/19526
2021-09-26 18:26:38 -05:00
evazion
1075277d36 posts: remove unused methods. 2021-09-26 08:15:17 -05:00
evazion
01cdc7da7f media assets: add status column. 2021-09-26 08:06:13 -05:00
evazion
3d30bfd69d media assets: add duration column.
Add a column for tracking the duration (length) of videos and
animations. The duration will be null for static images.
2021-09-26 07:45:29 -05:00
evazion
ab3f35580f metadata: move metadata parsing into ExifTool::Metadata.
Move the metadata parsing code from MediaAsset to ExifTool::Metadata so
we can use it outside the context of a MediaAsset, in particular when
dealing with a MediaFile that hasn't been saved to disk yet.
2021-09-26 07:19:36 -05:00
evazion
960817e9fe posts: don't send cookies for thumbnail requests.
Set `crossorigin="anonymous"` on the <img> tag for thumbnails. This
makes it so we don't send session cookies in requests for thumbnails.
Since images are served from cdn.donmai.us, and since session cookies
are set on *.donmai.us, session cookies are sent by default with every
thumbnail request.

Not sending cookies saves up to 1kb of overhead per thumbnail request
(in reality, it's less than this because of HTTP/2 multiplexing and
header compression).
2021-09-26 07:19:36 -05:00
evazion
7d3eebaced posts: purge all cached URLs when post is regenerated
Fix not all URLs being purged from Cloudflare when a post is
regenerated.
2021-09-26 01:21:32 -05:00
evazion
63240e0446 Remove config/spring.rb.
We no longer use Spring (https://github.com/rails/spring).
2021-09-25 08:00:52 -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
51bc953383 post preview component: remove workaround for blank width/height.
Remove workaround for old posts that had a null width or height. These
posts were fixed a while ago.
2021-09-25 06:34:15 -05:00
evazion
6f02918676 Merge pull request #4887 from nonamethanks/update-artist-finder
Update artist finder blacklist
2021-09-24 08:54:48 -05:00
evazion
c183237b6b docker: update docker-compose file.
* Listen on port 3000 instead of port 80. Port 80 is prone to conflicts
  with other webservers.

* Use the production version of the Danbooru Docker image. It's less
  likely to have bugs than master.

* Fix the autoinstall script to work with `curl ... | sh`.

* Lower PUMA_WORKERS to 1 to reduce memory usage.
2021-09-24 08:40:33 -05:00
evazion
463e6d7b49 artists: fix deadlock when banning artists.
Caused by d854bf6b. Banning an artist would deadlock because it was
performed in a transaction, which didn't work with the `parallel_each`
inside the "create an implication to banned_artist" step.
2021-09-24 08:40:33 -05:00
evazion
9d62f71cd9 ci: prevent running multiple Docker builds at once. 2021-09-24 08:40:33 -05:00
evazion
e8a09bc400 js: fix eslint warnings. 2021-09-24 08:40:33 -05:00
nonamethanks
16f76fe396 Update artist finder blacklist 2021-09-24 14:50:19 +02:00
evazion
dd9c4dd04a Fix #4846: Codeclimate integration broken 2021-09-24 07:46:00 -05:00
evazion
74b03a7bd0 posts: fix incorrect exif rotation for PNGs.
Fix a bug where where PNG images could be incorrectly detected as
exif-rotated. This would happen when a PNG contained the
IFD0:Orientation flag. It's technically possible for a PNG to contain
this flag, but it's ignored by libvips and by browsers.

post #3762340 (nsfw) is an example of a PNG like this.

The fix is to use `autorot` to let libvips apply the rotation instead of
trying to interpret the exif data ourselves. Note that libvips-8.9 has a
bug where it doesn't strip the orientation flag after applying
`autorot`, which leads to the image being incorrectly rotated a second
time when generating the thumbnail. Use libvips-8.11 instead.
2021-09-23 00:10:00 -05:00
evazion
9c0ab258cb Upgrade libvips to 8.11.3. 2021-09-22 23:56:59 -05:00
evazion
e7a455ea44 Merge pull request #4884 from nonamethanks/remove_long_image
Posts: stop autotagging long_image
2021-09-22 23:09:08 -05:00
GlassedSilver
0dd77b0f7f Bump Ruby to 3.0.2 in INSTALL.debian 2021-09-22 23:02:13 -05:00
evazion
ee5cd8330d uploads: fix exception when pruning expired uploads.
Hourly pruning of expired uploads was failing because of nil deference
errors in `media_asset.destroy!`. There are various cases where an
upload doesn't have a media asset, for example when the source url
fails to download or when the upload is of an invalid filetype.
2021-09-22 13:24:27 -05:00