Commit Graph

10391 Commits

Author SHA1 Message Date
nonamethanks
e95731d58f Skeb: fix broken strategy 2021-05-04 21:18:12 +02:00
evazion
a2f3ba695c Revert "fix vote buttons."
This reverts commit a0b6047d00.
2021-04-02 03:58:14 -05:00
evazion
243b3264e9 posts: fix posts with .jpeg file extension.
There used to be about 1000 posts with a .jpeg file extension instead of
.jpg. These posts have been fixed manually, so we no longer have to
check for this any more.
2021-04-02 02:41:54 -05:00
evazion
26496bba8d posts: fix error when viewing nonexistent post IDs. 2021-04-01 18:24:26 -05:00
evazion
d58a0bf1e4 Fix #4781: Danbooru Javascript object is broken.
Downgrade Webpack from 5.28.0 to 5.26.3. Breakage was introduced at
5.27.0. It's unclear if this is a regression of issue 12742 in Webpack
or if we're doing something else wrong.

hxxps://github.com-webpack-webpack-issues-12742
hxxps://github.com-webpack-webpack-issues-12851
2021-04-01 03:10:44 -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
946b4cc960 Update CHANGELOG.md. 2021-03-31 21:32:01 -05:00
evazion
4deb8aeea2 uploads: disallow uploading new Flash files.
Flash is dead. It's no longer supported by browsers, it's not
well-supported by emulators, and only two Flash posts were uploaded in
the last year anyway. Old Flash files will continue to exist, but new
Flash uploads will no longer be allowed.
2021-03-31 20:47:35 -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
a062c040cb saved searches: fail gracefully when Redis is disabled.
Just make saved searches return nothing when Redis is disabled.
2021-03-30 05:35:42 -05:00
evazion
d59b0234ac config: disable Redis by default.
Fixes Docker containers and development installs that don't have Redis
installed from throwing errors about failing to connect to Redis.

Downstream boorus who do use Redis will need to uncomment this line or
set `redis_url` manually in their config to enable Redis again.
2021-03-30 05:34:49 -05:00
evazion
247934ad83 db: add non-null constraints to all non-optional columns.
Add non-null constraints to all columns that are non-optional. Now the
only columns that are nullable are optional columns.
2021-03-30 04:52:01 -05:00
evazion
803efe8501 Don't use secure cookes on non-HTTPS deployments.
Fixes not being able to login or signup when running in production mode
on a non-HTTPS site.
2021-03-30 03:58:34 -05:00
evazion
172265b4ef Merge pull request #4772 from nonamethanks/fix-alias-implication
Tag Aliases: automatically remove redundant implications
2021-03-30 00:40:11 -05:00
evazion
857776db9e Merge pull request #4779 from nonamethanks/fix-typo
Tag implications: fix typo in validate error
2021-03-30 00:33:45 -05:00
evazion
b3c1c753b3 comments: allow admins to remove comment votes (fix #4640)
Allow admins to remove comment votes by other users. This is done by
clicking the comment score to get to the comment vote list, then
clicking the Remove button on every vote.
2021-03-30 00:10:25 -05:00
evazion
6b91e55283 comments: allow votes to be soft deleted.
Make it so that when a user removes their own vote, the vote is soft
deleted (the is_deleted flag is set) instead of hard deleted.

Changes:

* Add is_deleted flag to comment votes.
* Relax uniqueness constraint so you can have multiple deleted votes on
  the same comment. You can still only have one active vote on the comment.
* Add `soft_delete` method to Deletable concern.
2021-03-30 00:10:22 -05:00
evazion
55129b1819 Rework Dockerfile.
* Optimize Dockerfile to minimize size of the Docker image.
* Specify exact versions of important dependencies (Ruby, Node, Vips) to
  ensure our dependencies are up to date and locked to known versions.
* Install Vips from source because the version that ships with Ubuntu is too old.
* Install FFmpeg from source because otherwise using the Ubuntu package
  pulls in tons of video libraries we don't need, bloating the image.
2021-03-29 06:00:37 -05:00
evazion
6f6a73edd2 Fix "Blocked host" error in development environment.
Fix custom hostnames being blocked in the development environment.
2021-03-29 03:01:06 -05:00
evazion
6404aa9aa9 Log to stdout in development and production.
Always log to stdout instead of logging to files in `log/{development,production}.log`.

For development, logging to files wasn't really useful, and could
generate multi-gigabyte log files if you weren't paying attention. For
production, most systems these days (such as Docker and Systemd) prefer
that you write your logs to stdout so they can manage them.

Fixes the Docker image writing logs inside the container, which never
got rotated and could fill up the container.
2021-03-29 03:01:02 -05:00
evazion
12436c4aa9 Fix IpAddressType autoload warning.
Fix Rails complaining about IpAddressType not being reloaded by hot
reloading:

    DEPRECATION WARNING: Initialization autoloaded the constant IpAddressType.

    Being able to do this is deprecated. Autoloading during initialization is going
    to be an error condition in future versions of Rails.

    Reloading does not reboot the application, and therefore code executed during
    initialization does not run again. So, if you reload IpAddressType, for example,
    the expected changes won't be reflected in that stale Class object.

    This autoloaded constant has been unloaded.

    In order to autoload safely at boot time, please wrap your code in a reloader
    callback this way:

        Rails.application.reloader.to_prepare do
        # Autoload classes and modules needed at boot time here.
        end

    That block runs when the application boots, and every time there is a reload.
    For historical reasons, it may run twice, so it has to be idempotent.

    Check the "Autoloading and Reloading Constants" guide to learn more about how
    Rails autoloads and reloads.
2021-03-29 03:01:02 -05:00
evazion
e2704f6a7b Danbooru::Http: redirect POST to GET on 302.
When a POST request returns a 302 redirect, follow the redirect with a
GET request instead of with a POST request.

HTTP standards leave it unspecified whether a POST request that returns
a 302 redirect should be followed with a GET or with a POST. A GET is
what most browsers use, which means it's what most servers expect.

Fixes the /tagme Discord command not working because when we uploaded
the image to DeepDanbooru, the POST request returned a 302 redirect,
which the server expected us to follow with a GET, not with a POST.

Ref:

* https://stackoverflow.com/questions/17605915/what-is-the-correct-behavior-expected-of-an-http-post-302-redirect-to-get
2021-03-29 03:01:02 -05:00
evazion
07720b04a5 Update Ruby gems and Yarn packages. 2021-03-29 03:01:02 -05:00
evazion
b8fa15cf50 gems: temp disable meta_request.
Revert 442d0f8dd. Fix was merged upstream but a new gem hasn't been
released yet.
2021-03-29 03:01:02 -05:00
nonamethanks
cda1f64d89 Tag implications: fix typo in validate error 2021-03-28 14:21:18 +02:00
evazion
7984575210 mimemagic: update to 0.3.8 (#4776). 2021-03-25 14:50:42 -05:00
evazion
442d0f8dd3 gems: remove meta_request fork.
Remove a workaround added in 2c06766c9. meta_request had a bug that
caused Rails to fail to launch under Rails 6.1. The fix was finally
merged upstream.

hxxps://github.com/dejan/rails_panel/pull/177.
2021-03-24 17:37:48 -05:00
evazion
c11f13050b Fix #4776: docker-compose.simple.yaml - fails to find mimemagic gem 2021-03-24 13:31:22 -05:00
evazion
9baac1fec0 autocomplete: increase contrast of selected tag in light mode. 2021-03-24 13:29:27 -05:00
evazion
178cf07690 discord: increase timeout of /count command. 2021-03-24 13:29:05 -05:00
evazion
08270973f1 Add scripts for a single-command Danbooru deployment.
Add a Docker Compose file that launches a minimal Danbooru instance in a
Docker container with a single command. This is suitable as a quick demo
or for personal use, not for public-facing sites.

To use it, just run `bin/danbooru`. This is a wrapper script that
installs Docker Compose then uses it to start Danbooru.

This will generate a lot of debug output and take several minutes while
it builds the Docker containers. Be patient. When it's done, you should
have an empty booru accessible at http://localhost.
2021-03-23 21:35:23 -05:00
evazion
9c07d710f4 config: fix bug in default backup storage manager config.
Fix uploads failing in the default configuration because the backup
storage manager didn't initialize the null storage manager with the
required `base_url` and `base_dir` options.
2021-03-23 19:53:31 -05:00
evazion
c60b9f2804 robots.txt: disallow /iqdb_queries.
Block Google from accidentally DoS'ing us by crawling /iqdb_queries en
masse.
2021-03-23 11:33:42 -05:00
evazion
1a8c70f5ff config: auto generate secret key if none given.
Automatically generate a random secret key for `Danbooru.config.secret_key_base`
if no key is specified.

This so that you can run Danbooru in a Docker container with zero
configuration.

This removes support for the ~/.danbooru/secret_token file and the
SECRET_TOKEN environment variable. If you used either one of these, you
must copy the value either to DANBOORU_SECRET_KEY_BASE in .env.local, or to
`secret_key_base` in config/danbooru_local_config.rb.

   # .env.local
   DANBOORU_SECRET_KEY_BASE=<value>

   # config/danbooru_local_config.rb
   def secret_key_base
      # <value>
   end
2021-03-23 03:11:41 -05:00
evazion
189adc683f config: set default database connection settings.
Set sensible defaults for connecting to the database. By default, we try
to connect to the `danbooru2` database running on localhost as the
`danbooru` user. These are the defaults recommended by the install
guide.

If you need to change the database settings, set DATABASE_URL in
.env.local or on the command line:

   # .env.local
   DATABASE_URL=postgresql://danbooru:password@localhost/danbooru2

   # command line
   $ DATABASE_URL=postgresql://danbooru:password@localhost/danbooru2 bin/rails server

This eliminates the need to copy script/install/database.yml.templ to
config/database.yml during installation and during deployment. This is
so that Danbooru works out of the box without extra configuration. In
particular, this is so that we can run Danbooru in a Docker container
without having to set DATABASE_URL.
2021-03-23 02:29:45 -05:00
evazion
6a84d33409 Fix #4770: Allow flaggers to update flag reason. 2021-03-23 01:27:16 -05:00
evazion
41e0cad458 ip bans: allow full bans to overlap partial bans.
Allow full banning an IP that is part of a subnet that has already been
partially banned.
2021-03-23 01:27:16 -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
c9ca5c0598 rake: fix images:manifest failing on file permission errors.
Fix images:manifest failing with an exception when a file can't be
opened because we don't have permission to access the file.
2021-03-20 16:15:16 -05:00
evazion
048171fe29 rake: fix images:manifest task to handle corrupted files. 2021-03-20 05:30:06 -05:00
evazion
6879fe73db rake: add task for checking image md5s.
Add a rake task for checking the md5s and size/width/height of all
uploaded files. Generates a JSON manifest file.

Usage: bin/rake images:manifest
2021-03-20 02:46:28 -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
92225177a8 Update oauth2 gem.
Fixes a critical bug introduced in oauth2 1.4.5 that caused the Pawoo
source strategy to fail.
2021-03-19 16:49:14 -05:00
evazion
737f4ffcf7 Update CHANGELOG.md. 2021-03-19 15:51:25 -05:00
nonamethanks
917b08639f Tag Aliases: automatically remove redundant implications 2021-03-19 15:38:47 +01:00
evazion
1a7a108d47 discord: add /tagme command. 2021-03-19 04:44:22 -05:00
evazion
cebfe3308e discord: show favcount in post embeds. 2021-03-18 23:00:13 -05:00
evazion
d5903b61c4 discord: add function to register all commands.
* Add a `DiscordSlashCommand.register_slash_commands!` method to register
  all slash commands with the Discord API.
* Allow registering global commands.
* Refactor slash commands to use class attributes for the command
  name, description, and options.
2021-03-18 22:59:43 -05:00