Commit Graph
100 Commits
Author SHA1 Message Date
evazion 107729e17f ci: enable codeclimate reporter debug output. 2020-06-15 17:21:41 -05:00
evazion a615a28b1b ci: disable warnings during tests. 2020-06-15 16:45:37 -05:00
evazion f60b184a12 ci: don't trigger twice on pull requests. 2020-06-15 16:45:37 -05:00
evazion 6a7d25591b ci: use more permissive rubocop / codeclimate settings. 2020-06-15 16:45:37 -05:00
evazion ec5aa6c662 tests: fix saved search index action test.
This passed in development but failed in CI because SavedSearch.redis
used the live Redis server, which worked by accident as long as you had
a Redis server running.
2020-06-15 16:45:37 -05:00
evazion 3cdf679202 http: automatically follow redirects.
* Automatically follow redirects (up to 5, return a synthetic 598 error after that).
* Add `put` and `timeout` methods.
* Add tests.
2020-06-14 01:39:55 -05:00
evazion cd501fe27b iqdb: switch to Danbooru::Http. 2020-06-14 01:06:51 -05:00
evazion a4df18e650 Refactor Reportbooru API clients.
* Combine MissedSearchService, PostViewCountService, and
  PopularSearchService into single ReportbooruService class.
* Use Danbooru::Http for these services instead of HTTParty.
2020-06-14 00:32:42 -05:00
evazion 1846133cd6 post view count service: switch to Danbooru::Http. 2020-06-13 21:50:06 -05:00
evazion 9e29326b96 README.md: add Discord status badge. 2020-06-12 00:49:01 -05:00
evazion 025e09ff7f tests: upload test coverage reports to code climate.
Downgrade simplecov to 0.17 because 0.18 is incompatible with code
climate. Ref: github.com codeclimate/test-reporter/issues/413
2020-06-11 15:35:15 -05:00
evazion 8181ee6a1d Update rubocop config. 2020-06-11 14:08:23 -05:00
evazion 889c4ce4d9 Add Code Climate integration. 2020-06-11 13:31:17 -05:00
evazion be4646aa6f tests: fix username conflicts in parallel tests.
Parallel tests sometimes failed because the username generator sometimes
generated duplicate usernames.
2020-06-11 02:43:19 -05:00
evazion e14a577ed9 tests: clean up test_helper.rb initialization. 2020-06-11 02:41:44 -05:00
evazion 8e50f1d1a0 tests: remove unused test images in tmp/. 2020-06-11 02:41:17 -05:00
evazion 27c5361b96 tests: add minimum test coverage requirements. 2020-06-11 02:40:02 -05:00
evazion a829fbfb8d tests: fix test coverage reporting for parallel testing.
* Fix simplecov clobbering test coverage reports when using parallel tests.
* Generate coverage reports by default (remove $SIMPLECOV flag).
* Store coverage reports in tmp/coverage/ instead of coverage/.
* Enable branch coverage.

ref: github.com /colszowka/simplecov/issues/718#issuecomment-538201587
2020-06-11 02:16:20 -05:00
evazion 99a9149fc4 tests: eliminate as_user helper. 2020-06-11 01:02:01 -05:00
evazion 2d05004bef tests: don't cache pixiv sessions. 2020-06-11 00:47:12 -05:00
evazion 7ba786010d tests: store test uploads in temp dir.
Fixes parallel tests failing because uploads for different tests were
stored in the same directory and uploads got clobbered when cleaning up
this directory.
2020-06-10 22:54:33 -05:00
evazion 04c8c25976 tests: initialize pawoo credentials in github tests. 2020-06-10 22:49:28 -05:00
evazion 88dfc463a1 db/seeds: fix deprecation warning in find_or_create_by!.
`User.find_or_create_by!` calls `User.name_matches` during username
validation, which triggers a deprecation warning for some reason:

    DEPRECATION WARNING: Class level methods will no longer inherit scoping
    from `create!` in Rails 6.1. To continue using the scoped relation,
    pass it into the block directly. To instead access the full set of
    models, as Rails 6.1 will, use `User.default_scoped`.
2020-06-10 22:33:36 -05:00
evazion 5919fa0ca1 tests: enable parallel tests. 2020-06-10 22:26:47 -05:00
evazion 60e96f0e01 tests: fix post url generation test. 2020-06-10 20:22:21 -05:00
evazion 2ede41c4dc tests: fix twitter test broken by deleted tweet. 2020-06-10 20:22:16 -05:00
evazion ab1931a920 tests: fix artstation download tests.
Fix ArtStation download tests that were broken when 266e4054 added the
ability to download /4k/ files.
2020-06-10 19:45:56 -05:00
evazion d6b266514b tests: disable known broken pixiv fanbox tests. 2020-06-10 18:21:44 -05:00
evazion 45b3370d49 models: fix exception in api_attributes.
Fixup bug in eacb4d4df when calling `api_attributes` on an object that
doesn't have a policy (its policy inherited from ApplicationPolicy).
2020-06-10 18:16:58 -05:00
evazion 8a2ae91ff2 tests: skip video file tests if ffmpeg isn't installed. 2020-06-10 18:07:54 -05:00
evazion 15423e0b7b tests: add progress bar to test output.
Add minitest-reporters gem. Replace the default output of `bin/rails
test` with a progress bar. The default output just emits periods for
passed tests, which makes it hard to tell how long tests will take and
causes test runner output on Github to appear to hang. The web console
on Github is line buffered, but the default test runner doesn't normally
emit newlines (unless a test fails), so the output can hang for a long
time.
2020-06-10 17:52:33 -05:00
evazion 5e63a7cf77 Add test workflow. 2020-06-10 17:52:13 -05:00
evazion 8b5b320be7 docker: fix file permission problems.
Store the app in /home/danbooru/app instead of in /app so that we have
permission to write inside the app dir. /app was owned by root, which
prevented the danbooru user from writing to it.
2020-06-09 17:50:47 -05:00
evazion 15799f8af7 Fix #4260: Unable to replace cdn.donmai.us images?
Bug: Replacing posts hosted on cdn.donmai.us didn't work.

Cause: Original files on cdn.donmai.us are hosted under /var/www/danbooru/original/, but replacements
were trying to store them directly under /var/www/danbooru, which failed with a permission error.
We were trying to store them in the wrong directory because we didn't respect the `original_subdir`
option when generating file paths.
2020-06-09 15:57:43 -05:00
evazion 20abd8a5fd Fix build failure in nokogumbo.
Nokogumbo-2.0.2 fails to build when Nokogiri-1.11.0 is installed.
Nokogiri introduced some changes that are apparently incompatible with
Nokogumbo.

ref: https://nokogiri.org/CHANGELOG.html#versioninfo-and-the-output-of-nokogiri-v
2020-06-09 13:20:46 -05:00
evazion 8b5ffb4c43 uploads: allow admins to upload videos more than 2 minutes long.
At some point the ability for admins to bypass the video length
restriction got lost.

ref: https://danbooru.donmai.us/forum_topics/14647
2020-06-09 03:08:06 -05:00
evazion d002701bc1 Merge pull request #4494 from nonamethanks/fix_deviantart_api_downloads
Deviantart: fix api downloads
2020-06-09 01:37:03 -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
evazion b1f22df4ab Upgrade ruby version to 2.7.1. 2020-06-09 01:35:40 -05:00
evazion 470c3edd94 Upgrade ruby gems and yarn packages. 2020-06-09 01:21:56 -05:00
evazion 3a8d894154 Merge pull request #4498 from danbooru/dependabot/bundler/websocket-extensions-0.1.5
build(deps): bump websocket-extensions from 0.1.4 to 0.1.5
2020-06-09 01:11:41 -05:00
evazion f1581789ac Merge pull request #4500 from danbooru/dependabot/npm_and_yarn/websocket-extensions-0.1.4
build(deps): bump websocket-extensions from 0.1.3 to 0.1.4
2020-06-09 01:10:49 -05:00
evazion 3033bb4530 Update danbooru Dockerfile.
Split into build stage and runtime stage to reduce image size.
2020-06-09 01:07:42 -05:00
evazion eacb4d4df3 models: factor out api_attributes to policies.
Refactor models so that we define attribute API permissions in policy
files instead of directly in models.

This is cleaner because a) permissions are better handled by policies
and b) which attributes are visible to the API is an API-level concern
that models shouldn't have to care about.

This fixes an issue with not being able to precompile CSS/JS assets
unless the database was up and running. This was a problem when building
Docker images because we don't have a database at build time. We needed
the database because `api_attributes` was a class-level macro in some
places, which meant it ran at boot time, but this triggered a database
call because api_attributes used database introspection to get the list
of allowed API attributes.
2020-06-08 18:38:02 -05:00
evazion b6ed63841d footer: fix exception if git hash isn't defined.
The git hash may be undefined when running in a Docker container.
2020-06-08 18:12:32 -05:00
evazion 6d78d22571 Update docker test configuration. 2020-06-07 17:14:41 -05:00
evazion aa9d34a3f0 config: make danbooru_local_config.rb optional.
Make it so that if danbooru_local_config.rb doesn't exist, we continue
with the default config instead of failing.
2020-06-05 15:49:51 -05:00
evazion 82c09858f2 Remove unused data attributes from <body> tag.
Fixup for 647556761.
2020-06-03 11:51:21 -05: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 bfa76abb56 layouts/default: move <script> tag from header to footer.
* Inline Javascript in the <head> is a minor bottleneck because it
  blocks page rendering.
* Fix antiproxying protection (proxy sites like to strip <script> tags
  from the header).
2020-06-02 22:09:44 -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 18ce552dae tests: fix upload controller tests.
We can't use the name `test_file_upload` because then the helper method
gets treated like it's a test case.
2020-06-02 18:25:45 -05:00
evazion 276f23ba8d config: refactor remove_tag_after_replacement? config option. 2020-06-02 18:25:45 -05:00
evazion 47e6821a31 config: remove customize_new_user config option. 2020-06-02 18:25:45 -05:00
evazion 484eacfd3b config: remove is_unlimited_metatag? config option. 2020-06-02 18:25:42 -05:00
evazion 9997db44d8 config: remove banned_ip_for_download? option.
* Remove `banned_ip_for_download?` config option. This isn't something that usually needs
  to be configured.
* Replace the `ipaddress` gem with `ipaddress_2`. The `ipaddress` gem has several methods
  we need (`link_local?`, etc) that are only available in master because the gem hasn't had
  an official release in several years. `ipaddress_2` is a fork that is more actively
  maintained.
2020-06-02 15:32:19 -05:00
evazion 63f675b7d6 config: remove enable_post_search_counts option.
Enable by default if reportbooru is configured, otherwise disable.
2020-06-02 14:41:06 -05:00
evazion ed41fd77e5 config: remove unused config options. 2020-06-02 14:33:44 -05:00
evazion a8389c74d8 uploads: fix dropzone previews being stretched. 2020-06-02 03:04:36 -05:00
evazion 565e02c7ab Revert "search: temporarily raise tag limit to 12 for Danbirthday celebration."
This reverts commit af50e10c3a.
2020-06-01 23:32:25 -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 6b490cacba Update ruby gems and yarn packages. 2020-06-01 13:03:28 -05:00
evazion 2113b89f9b artists: don't show "Status Active" for undeleted artists.
An "active" artist entry is one that isn't deleted. Saying that every
undeleted artist is "active" confuses people.
2020-05-29 19:01:42 -05:00
evazion 855e31ac90 nijie: fetch commentary as html instead of plaintext.
Fix regression in #4475. Fetch the commentary as html instead of
plaintext so that we don't lose links or other formatting.

Also fix it so that /jump.php redirect links are replaced with the
actual url.
2020-05-29 15:36:21 -05:00
evazion 206ac7dd9a dtext#from_html: convert basic links to <url> syntax.
Convert

    <a href="https://www.example.com">https://www.example.com</a>

to

    <https://www.example.com>

instead of

    "https://www.example.com":[https://www.example.com]
2020-05-29 15:36:21 -05:00
evazion 9ca848d732 tests: fix more ruby 2.7 deprecation warnings. 2020-05-29 15:36:21 -05:00
evazion 29740f0bee tests: fix hentai foundry artist url test. 2020-05-29 15:36:21 -05:00
evazion 88d9fc4e5e sources: simplify artist finder url normalization.
Get rid of `normalized_for_artist_finder?` and `normalizable_for_artist_finder?`.
This was legacy bullshit that was originally designed to avoid API calls
when saving artist entries containing old Pixiv direct image urls that
had already been normalized, or that couldn't be normalized because they
were bad id.

Nowadays we store profile urls in artist entries instead of direct image
urls, so we don't normally need to do any API calls to normalize the
profile url. Strategies should take care to avoid triggering API calls
inside `profile_url` when possible.
2020-05-29 15:35:15 -05:00
evazion 9ba6d60ad3 Merge pull request #4489 from nonamethanks/add_weibo_normalization
Weibo: add source normalization
2020-05-29 11:29:40 -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
evazion 7a819b0060 artists: hide banned artist pages from anonymous users.
Hide banned artist pages from anonymous (logged out) users. Partial
revert of 6b066f2ca. Artists sometimes ask us to remove all their
information from the site, including their artist profile. It's easier
to hide their profile than to explain to Japanese artists that a) we're
under no obligation to remove their profile and b) we need to keep it to
maintain the ban on their content that they asked for.
2020-05-29 11:27:59 -05:00
evazion feeea6602c Merge pull request #4488 from nonamethanks/add_weibo_support
Add Weibo support
2020-05-27 16:53:14 -05:00
evazion 2c60a51f64 Merge pull request #4475 from nonamethanks/refactor_source_normalizing
Refactor source normalization
2020-05-27 16:52:17 -05:00
evazion 71f4e5b82a artstation: add tests for #4480. 2020-05-27 15:49:04 -05:00
evazion 241894428a Merge pull request #4480 from BrokenEagle/fix-artstation
Fixes issues with Artstation source strategy
2020-05-27 15:37:23 -05:00
evazion 7c5510a650 media_file/flash: add license information (#4484). 2020-05-27 15:11:46 -05:00
evazion f94c52478c media file: memoize expensive methods in subclasses. 2020-05-27 14:31:39 -05:00
evazion 84cd8540ab tests: add tests for uploading flash files (#4484). 2020-05-27 14:26:52 -05:00
evazion 16ed1db3b1 Merge pull request #4484 from lllusion3469/fix-flash-dimensions
Fix flash dimensions
2020-05-27 14:10:51 -05:00
evazion 8f10fb99f4 Merge pull request #4482 from BrokenEagle/add-monospace-font
Add monospace font
2020-05-25 19:34:55 -05:00
evazion c300b344de Merge pull request #4481 from BrokenEagle/fix-iqdb-image-url
Adds suport for using the image_url parameter with IQDB
2020-05-25 02:20:55 -05:00
evazion e22e403bac Merge pull request #4478 from nonamethanks/fix_nijie_truncated_commentary
Nijie: fetch full commentary rather than truncated preview
2020-05-25 02:13:24 -05:00
evazion 20f8a26709 tests: fix rails 2.7 keyword parameter deprecation warnings. 2020-05-25 01:48:46 -05:00
evazion 66a66cc952 Update ruby gems and yarn packages. 2020-05-25 01:10:49 -05:00
evazion 3e2949d157 uploads: fix exception when uploading gifs.
Older versions of libvips don't support get("n-pages"). This is known to
fail in libvips-8.4 and known to work in libvips-8.8.
2020-05-24 12:07:17 -05:00
evazion cf88411dce uploads: fix /uploads listing search not working.
Upload#search was declared as an instance method instead of a class
method.
2020-05-24 00:29:19 -05:00
evazion 5fc98eb35f rake: add image preview/sample regeneration script. 2020-05-23 23:51:23 -05:00
evazion dc4a3bcf38 uploads: fix incorrect sample image sizing.
ref: https://danbooru.donmai.us/forum_topics/16935.

Bug: sample images were being generated to be at most 850px width *and*
850px tall. They're supposed to be at most 850px wide with unlimited height.
2020-05-23 23:29:59 -05:00
evazion af50e10c3a search: temporarily raise tag limit to 12 for Danbirthday celebration. 2020-05-23 22:09:38 -05:00
evazion 5da04db9cd api: rename error url param to cause_error.
Rename the `error` url param to `cause_error`. Using this param causes
Danbooru to return an error response for testing purposes. Calling this
param `error` caused problems when OAuth2 authorization failed and the
user was redirected back to Danbooru with the `error` param set.
2020-05-23 22:01:29 -05:00
evazion 364343453c uploads: factor out remaining image methods to MediaFile. 2020-05-19 02:42:19 -05:00
evazion 45064853de uploads: move thumbnail generation code to MediaFile.
* Move image thumbnail generation code to MediaFile::Image.
* Move video thumbnail generation code to MediaFile::Video.
* Move ugoira->webm conversion code to MediaFile::Ugoira.

This separates thumbnail generation from the upload process so that it's
possible to generate thumbnails outside of uploads.
2020-05-18 04:19:04 -05:00
evazion 24c53172db config: remove enable_image_cropping option.
There's no need to disable this option. Supporting it adds complexity
and disabling it is untested.
2020-05-17 15:01:59 -05:00
evazion 0a12f35c47 posts/index: fix cropped thumbnails not being shown.
`show_cropped: true` wasn't being passed down to PostPresenter.preview.
2020-05-13 07:12:11 -05:00
evazion 1e2748595c tests: fix various broken tests. 2020-05-13 00:15:04 -05:00
evazion ad02e0f62c posts/index: fix rating:s being included in page title in safe mode.
Fixes bug described in https://github.com/danbooru/danbooru/commit/d3e4ac7c177486e962cdec328843db9568960f9a#commitcomment-39049351

When dealing with searches, there are several variables we have to keep
in mind:

* Whether tag aliases should be applied.
* Whether search terms should be sorted.
* Whether the rating:s and -status:deleted metatags should be added by
  safe mode and the hide deleted posts setting.

Which of these things we need to do depends on the context:

* We want to apply aliases when actually doing the search, calculating
  the count, looking up the wiki excerpt, recording missed/popular
  searches in Reportbooru, and calculating related tags for the sidebar,
  but not when displaying the raw search as typed by the user (for
  example, in the page title or in the tag search box).
* We want to sort the search when calculating cache keys for fast_count
  or related tags, and when recording missed/popular searches, but not
  in the page title or when displaying the raw search.
* We want to add rating:s and -status:deleted when performing the
  search, calculating the count, or recording missed/popular searches,
  but not when calculating related tags for the sidebar, or when
  displaying the page title or raw search.

Here we introduce normalized_query and try to use it in contexts where
query normalization is necessary. When to use the normalized query
versus the raw unnormalized query is still subtle and prone to error.
2020-05-12 21:47:00 -05:00
evazion ea400296d4 Fix #4455: Two tag search gives option to create wiki page when one is a metatag. 2020-05-12 17:52:41 -05:00
evazion ca00563a4d Fix #4303: Unable to rename artist entries with wiki pages
Remove the ability to edit an artist's wiki page directly from the
artist edit page. Instead the artist edit page has a link to open the
wiki edit page if you need to edit the wiki too.

Fixes an error being thrown when renaming an artist with a wiki page.
The problem is that changing the artist's name breaks the artist's
association with the old wiki page. Rails really wants nested
associations to be based on immutable IDs, not on mutable names, so
dealing with this correctly is difficult.

We don't really want to encourage people to create wiki pages for
artists to begin with, since they're usually just used to duplicate
the artist urls. Making it less convenient to edit artist wiki pages is
an intentional change to discourage creating unnecessary artist wikis.

Finally, this fixes an exploit where it was possible to edit locked wiki
pages through the artist edit page.
2020-05-12 16:57:05 -05:00
evazion 31c7abd2e9 footer: fix social icon links.
Image links were broken on pages like /artists/new because the links
were relative to the current page url, not to the root url.
2020-05-12 16:13:55 -05:00