Commit Graph
100 Commits
Author SHA1 Message Date
evazion cc4e39b88b sessions: raise exception on failed login attempts.
* Allow both xml and json authentication in sessions controller.

* Raise an exception if a login attempt fails so that a) we return a
  proper error for json/xml requests and b) failed login attempts get
  reported to NewRelic (for monitoring abuse).
2019-10-07 22:35:37 -05:00
evazion a5ab25d0ba pagination: avoid counting pages outside searches.
Replace this common pattern in controllers:

    @tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])

with this:

    @tags = Tag.paginated_search(params)

`search_count` is used to skip doing a full page count when we're not
doing a search (on the assumption that the number of results will be
high when not constrained by a search). We didn't do this consistently
though. Refactor to do this in every controller.
2019-10-07 22:02:03 -05:00
evazion 93dd952949 pagination: refactor to avoid counting pages in API.
Previously the page-based (numbered) paginator would always count the
total_pages, even in API calls when it wasn't needed. This could be very
slow in some cases. Refactor so that total_pages isn't calculated unless
it's called.

While we're at it, refactor to condense all the sequential vs. numbered
pagination logic into one module. This incidentally fixes a couple more
bugs:

* "page=b0" returned all pages rather than nothing.
* Bad parameters like "page=blaha123" and "page=a123blah" were accepted.
2019-10-07 22:01:37 -05:00
evazion e1f37113b3 Merge pull request #4188 from r888888888/feature/token-auth
expose user's api key as api_token field on sessions
2019-10-07 16:31:57 -05:00
evazion 1518c7aad6 /uploads: set referrerpolicy=no-referrer on hotlinked previews.
Don't send the referer when hotlinking preview images on the
/uploads/new page. Improves user privacy and may bypass anti-hotlinking
protections in some cases.
2019-10-07 13:44:35 -05:00
evazion 8209a75e95 nicoseiga: remove referer spoofing.
NicoSeiga doesn't appear to have any hotlink protection, so we don't
need to spoof the referer.
2019-10-07 13:15:48 -05:00
evazion 48ed227fc5 views: reduce set of <body> data attributes.
Some API attributes aren't generally useful or are too expensive to calculate
on every pageload. Only include basic attributes plus account settings.
2019-10-07 12:55:47 -05:00
evazion e6c53a9e9a Fix #4187: Meh vote color not working. 2019-10-07 12:52:33 -05:00
evazion 4e630f50cc post tooltips: add system tests. 2019-10-06 18:05:13 -05:00
evazion c9b2891f80 post tooltips: remove speech bubble tips. 2019-10-06 18:05:13 -05:00
evazion d723195838 post tooltips: remove gap beneath thumbnail on post #xxx tooltips.
Set the thumbnail height to auto instead of 154px so that there's not a
big empty gap beneath thumbnails that aren't 150px high.

This requires setting dimensions on the <img> tag itself so that the
image height is known before loading, otherwise the tooltip will be
mispositioned after the image loads in.

We set the min-width and min-height instead of the <img> width and
height properties because our calculated dimensions are sometimes
off-by-one compared to the actual dimensions. I'm not sure how libvips
calculates the thumbnail dimensions, but this avoids forcing a slightly
wrong aspect ratio, which produces ugly resizing artifacts.
2019-10-06 18:05:13 -05:00
evazion 8e4e274dae Fix #4186: Add tooltips to post #xxx links. 2019-10-06 18:05:13 -05:00
evazion d69e95a539 Fix #4180: Tooltip requests can be spammed.
* Cancel pending ajax requests when mousing out of the thumbnail.
  Prevents multiple requests from piling up if the user moves in and out
  of the thumbnail before the first request completes. This normally
  isn't possible except during slowbooru.

* Show an error message if the ajax request fails unexpectedly.
2019-10-06 02:54:27 -05:00
evazion 61619b719e Add rel="noreferrer" to external links.
Tells browsers not to send the Referer header when following external
links. Among other things, this bypasses Pixiv's anti-hotlinking
protection when opening direct image sources from Pixiv.
2019-10-06 01:32:14 -05:00
evazion ce33cd8b02 Fix #4185: Embedded translation notes aren't being styled. 2019-10-06 01:26:08 -05:00
evazion fbb5076c70 Fix #4184: post_versions API throws when user is 'anonymous' 2019-10-06 00:42:51 -05:00
evazion 188602abcc css: fix long blacklists not truncating in sidebar.
* https://danbooru.donmai.us/forum_topics/9127?page=281#forum_post_160147
* https://css-tricks.com/flexbox-truncated-text
2019-10-03 21:51:33 -05:00
evazion d64236813a js: replace <meta> tags with <body> data attributes.
Refactor things to store information about the current user as data
attributes on the <body> tag rather than as <meta> tags. These <meta>
tags are now deprecated and will be eventually removed.

* Store all of the current user's API attributes as data attributes on
  the <body> tag.

* Add `CurrentUser.data` for getting data from the <body> tag, and
  use it instead of `Utility.meta`.

* Add `CurrentUser.update` for updating the current user's settings.

* Fix a bug with the user named "Anonymous" not being able to edit notes.
2019-10-02 15:59:22 -05:00
evazion b492b5de9c modqueue: improve layout on mobile.
* Switch layout from float to flexbox.
* Collapse to one column layout on mobile (thumbnails above post info).
* Wordbreak overly long sources.
2019-10-02 01:52:24 -05:00
evazion d9f154094f css: switch mod dashboard, keyboard shortcuts pages to flexbox.
* Switch /static/keyboard_shortcuts from float-based layout to flexbox.
* Switch /moderator/dashboard from float-based layout to flexbox.
* Remove various .clearfix, `clear: both` rules.
* Remove dead .quick-mod rule.
2019-10-02 01:52:24 -05:00
evazion b9c869f3e4 css: fix stylelint issues. 2019-10-02 01:52:24 -05:00
evazion 60eaa99784 css: add stylelint. 2019-10-02 01:52:24 -05:00
evazion c17d95309a gems: update gems. 2019-10-02 01:52:19 -05:00
evazion 3096cea2d6 maintenance: fix db timeouts in regenerate_post_counts!
Disable database timeouts durings daily maintenance. Fixes
`regenerate_post_counts!` timing out. Remove calls to without_timeout
because otherwise it will reenable the timeout when trying to restore
the old timeout (see 97cc873a3f).
2019-10-01 22:51:40 -05:00
evazion 5d90256b24 spam detection: whitelist users more than 1 month old. 2019-10-01 22:51:40 -05:00
evazion ed7b6c781a /related_tags: fix category dropdown not working. 2019-10-01 22:51:13 -05:00
evazion 978844c548 /user_name_change_requests: fix renames not being visible to all users. 2019-10-01 00:45:45 -05:00
evazion 1291505546 Fix blacklists not working on /comments page.
This rule:

    .post-preview.blacklisted-active, #image-container.blacklisted-active, #c-comments .post.blacklisted-active {
      display: none;
    }

was being overridden by this rule:

    div#c-comments div#a-index div.post, div#c-comments div#a-show div.post {
      display: flex;
    }
2019-10-01 00:36:47 -05:00
evazion f6d63b6843 Fix broken layouts in old browsers that lack flexbox support.
Very old browsers (in particular, Firefox 16 and iOS 8.4 Safari) don't
support flexbox without prefixes, which breaks sidebar and comment
layouts. Extend the browserlist config so that autoprefixer generates
flexbox prefixes for these browsers.
2019-09-30 16:40:56 -05:00
evazion 83538b8105 /posts: fix duplicate share box id. 2019-09-30 12:01:42 -05:00
evazion dade1e67b0 /post_versions: add search form, tweak layout.
* Add search form above table.
* Move thumbnail to left of table when viewing history of single post.
* Remove unrelated links from subnav menu.
* Fix bugs with changed_tags search.
2019-09-30 02:51:13 -05:00
evazion e3b49a2a6d unicorn: bump worker processes (16 -> 20). 2019-09-30 01:00:28 -05:00
evazion 4d45141c4e js: standardize width of dialog boxes.
Increase width of artist commentary dialog, saved search dialog, and
favgroups dialog to 700px (the width that most other dialog boxes use).
2019-09-30 00:58:34 -05:00
evazion c66f7c4626 post/pool versions: fix database timeouts not being set.
Bug: database timeouts were set only on the main database, not on the
post and pool versions database, so users effectively had an unlimited
timeout when dealing with these things.
2019-09-30 00:58:34 -05:00
evazion 5b2675b831 css: clean up responsive css.
* Reduce size of buttons, form inputs, site menu items, paginator, and
  sidebar text.
* Remove various dead rules (nonexistent selectors, rules overriden by
  other rules, rules that were otherwise redundant or did nothing).
* Increase page margin size.
* Fix notes being mispositioned (caused by `#image { margin-top: 5px }` rule).
2019-09-30 00:58:34 -05:00
evazion 5818c367fd css: add .mobile-only, .desktop-only classes. 2019-09-30 00:58:34 -05:00
evazion cf97235aa6 css: reduce spacing between comments on mobile. 2019-09-30 00:58:34 -05:00
evazion fa70014a3c forum topics: adjust page title, reply link.
* Change page title from "Forum - Blah blah - Danbooru" to "Blah blah blah - Forum - Danbooru"
  so that more of the thread title is visible in tabs.

* Change "Reply »" to "Post reply" for consistency with comments (where
  the new comment link is called "Post comment".

* Remove "Topic: " so that topic titles take up less space on mobile.
2019-09-29 16:12:16 -05:00
evazion fc3441606e forum posts, comments: make timestamps into permalinks.
Make the timestamp beneath the username on forum posts into a permalink
that links to the post in full context of the thread. For comments, make
the timestamp link to the comment in full context of the post.

* Make the timestamp in forum posts link to /forum_posts/123.
* Make the timestamp in comments link to /posts/456#comment_123.
* Make /forum_posts/123 redirect to /forum_topics/456#forum_post_123.
* Make /comments/123 redirect to /posts/456#comment_123.
* Remove the "ID: ###" and "Permalink" fields from forum posts.
2019-09-29 15:57:15 -05:00
evazion 9ba46105dd tests: skip system tests when firefox isn't installed. 2019-09-29 14:29:28 -05:00
evazion f34489af02 css: factor out shared forum post / comment css. 2019-09-29 14:09:47 -05:00
evazion 5dfc14ba07 css: switch sidebar layout from float to flexbox. 2019-09-28 23:45:47 -05:00
evazion 960e5d4ae0 views: factor out sidebar layout template.
* Factor out common sidebar layout template.
* Convert wiki pages and posts to use this template.
* Add data-layout attribute to <body> element indicating the current layout.
2019-09-28 17:50:10 -05:00
evazion f7d7ed4b23 css: generalize anchor :target highlighting.
Generalize :target css so that it works on other things besides forum
posts (e.g. wiki pages, /post_versions#post-version-123).
2019-09-28 17:50:10 -05:00
evazion 6ef1a1c0b8 css: fix dead space around thumbnails in tables. 2019-09-28 17:50:10 -05:00
evazion 085e903e02 /post_versions: reorganize layout, add thumbnails.
* Add thumbnails to /post_versions (when viewing history of a single
  post, thumbnail is above table rather than in every table row).
* Combine user, date, and ip address columns into one column.
* Remove rating and parent columns (rating and parent changes are
  already listed in the tags column).
2019-09-28 17:48:35 -05:00
evazion 609a440d1c /post_versions: unify standard and revert listings. 2019-09-28 14:47:21 -05:00
evazion 62ec679bfb /post_versions/search: add tag autocomplete + quicksearch. 2019-09-28 12:14:09 -05:00
evazion 82af426592 Remove reference to google-api-client gem (fixup b2d0d2689). 2019-09-28 12:06:42 -05:00
evazion a39b67b901 Remove mod-only user revert system (#4178).
The mass undo system from #4178 replaces this system.

Followup to f2dccf8cf.
2019-09-27 21:48:49 -05:00
evazion 3b75dbf64f Update gems. 2019-09-27 21:28:16 -05:00
evazion b2d0d2689b gems: remove unused google-api-client gem. 2019-09-27 21:14:38 -05:00
evazion f2dccf8cf1 Remove mod-only bulk revert system (#4178).
The mass undo system added in #4178 is a replacement for the mod-only
bulk revert system.
2019-09-27 21:12:53 -05:00
evazion 1341dbb262 Remove post changes report.
This was a mod-only report that used Google BigQuery to search post
versions by tag. 2b4ee0ee8 allows all users to search post versions by
tag, so this report is no longer necessary.
2019-09-27 21:12:53 -05:00
evazion d29bbbbd71 Fix #4178: add ability to mass undo tag edits.
Adds checkboxes to the /post_versions index allowing you to select and
undo multiple versions at once.
2019-09-27 21:02:32 -05:00
evazion 9000bc5cc6 Fix ApplicationRecord#search_attribute (fixup 2b4ee0ee).
`column.array?` failed when the column was actually an association.
2019-09-27 21:02:32 -05:00
evazion 6f0b58ad49 tags: fix typo in order_similarity (fixup 8de692580). 2019-09-26 22:14:48 -05:00
evazion 97e0c16af6 /tags: add history, related, similar links. 2019-09-26 22:14:29 -05:00
evazion 2b4ee0ee8f post versions: add ability to search post versions by tags.
* Add ability to search /post_versions by added tags, removed tags, or
  changed tags (added or removed).

* Add 'History' link to the sidebar of the /posts index. This is a
  shortcut for a /post_versions search of the current tag.
2019-09-26 22:14:29 -05:00
evazion 12de26d2cf post versions: add more search options to /post_versions/search. 2019-09-26 16:35:05 -05:00
evazion 3341223b40 css: adjust comment / forum post layout on mobile.
* Remove borders around comments.
* Remove background behind commenter name / timestamp.
* Put timestamp on same line as commenter name.
2019-09-26 02:03:13 -05:00
evazion bca35d93bd css: fix comment layout on mobile.
Display comments and forum posts the same way on mobile.
2019-09-26 01:35:24 -05:00
evazion cb6f467764 css: unify comment and forum post css.
Unify comments and forum posts to have the same CSS and HTML structure.
Fixes various minor spacing and styling inconsistencies.
2019-09-26 01:35:14 -05:00
evazion 37eb6d0a4d css: switch comments and forum posts to flexbox. 2019-09-26 01:35:14 -05:00
evazion b8744cd2c4 pool tooltips: don't grey out tooltips until hovered. 2019-09-25 22:18:04 -05:00
evazion eff6480699 user name changes: require confirmation of new name. 2019-09-25 22:16:06 -05:00
evazion 07f706e75f user name changes: don't create feedback or modaction.
Don't create a neutral feedback, create a mod action, or dmail the user
after changing a user's name. The name change is already recorded in
/user_name_change_requests, so creating feedbacks and mod actions is
redundant. They also expose private information (when a user deletes
their account, old name changes aren't supposed to be visible any more).
2019-09-25 21:43:01 -05:00
evazion c710aa3ffb Fix #4177: Allow all users to change their username. 2019-09-25 21:43:01 -05:00
evazion 3b63f94968 user name changes: remove unused reason, status fields.
Remove all infrastructure around approving or rejecting user name
changes. Name changes haven't been moderated for several years.

* Remove status, approver_id, change_reason, and rejection_reason fields.
* Remove approve and reject controller actions.
2019-09-25 21:43:01 -05:00
evazion 8d1874d309 css: clean up various unnecessary css. 2019-09-25 18:32:49 -05:00
evazion bc34fb16a4 tags: automatically fix incorrect tag counts during maintenance.
* Automatically fix all tags with incorrect counts during daily
  maintenance (previously only tags with negative counts were fixed).
* Log fixed tags to NewRelic.
* Remove the ability to manually fix tag counts with the "Fix" button on
  the /tags listing. This is no longer necessary now that tags are
  fixed automatically.
2019-09-25 17:57:11 -05:00
evazion 03d9b3feca pixiv: support new https://www.pixiv.net/artworks/:id urls. 2019-09-24 03:33:21 -05:00
evazion e96d3cba78 autocomplete: fix autocomplete triggering after blank space. 2019-09-23 22:30:56 -05:00
evazion 51e4edadb1 Fix upgrade notice conditional (fixup e98db8a). 2019-09-23 19:22:00 -05:00
evazion 77d2260576 css: clean up <ul> css.
* Remove `list-style-type: none` rules (this is the default).
* Add `list-bulleted` and `list-inline` utility classes.
* Wrap terms of service and user deletion pages in dtext `.prose` class
  so we don't have to redefine basic list styles on these pages.
2019-09-23 19:10:40 -05:00
evazion f4512576a4 css: standardize width of fixed width pages.
Standardize various width-limited pages to 70em width.
2019-09-23 17:56:50 -05:00
evazion 0a6661d145 uploads: switch to active job.
* Switch upload processing from DelayedJob to ActiveJob.
* Remove remaining references to delayed job from tests.

Closes #4128.
2019-09-23 15:11:18 -05:00
evazion 8de6925807 Fix raw sql deprecation warning in tag autocomplete.
DEPRECATION WARNING: Dangerous query method (method whose arguments
    are used as raw SQL) called with non-attribute argument(s): "trunc(3
    * similarity(name, 'two')) DESC". Non-attribute arguments will be
    disallowed in Rails 6.1. This method should not be called with
    user-provided values, such as request parameters or model
    attributes. Known-safe values can be passed by wrapping them in
    Arel.sql(). (called from order_similarity at
    /home/admin/src/danbooru/app/models/tag.rb:817)
2019-09-23 13:52:21 -05:00
evazion c1bb88a52a tests: fix mock_saved_search_service! calls (fixup 4e4c4d627) 2019-09-23 03:22:32 -05:00
evazion 05e754eba3 users: change default user level to member in database.
Fixup for 9c34d5cc3. Default to member level in the database because
setting it in `customize_new_user` clobbered user levels set by factory
bot in tests, which broke the test suite.
2019-09-23 02:22:54 -05:00
evazion 09972477cd users: fix find_by_name for names with special characters.
`User.find_by_name` used `where_ilike` to do a case-insensitve name
search, but it didn't escape `*` or `\` characters first, so it didn't
handle names containing these characters properly.
2019-09-23 00:03:11 -05:00
evazion dcc2c793f9 Update gems. 2019-09-22 23:44:21 -05:00
evazion a164951b54 saved searches: add more order options (#4171). 2019-09-22 23:38:48 -05:00
evazion a5949a4b28 saved searches: always show 'Saved searches' link in navbar.
* Always display 'Saved searches' link in subnav bar, even if the user
  hasn't created any saved searches yet.
* Eliminate use of `has_saved_searches` bitpref on users.
2019-09-22 23:14:55 -05:00
evazion 4e4c4d627e saved searches: remove option to disable saved searches.
Remove `SavedSearch.enabled?` checks. There's no need to make saved
searches optional, since Redis is now required to run Danbooru.
2019-09-22 23:04:22 -05:00
evazion c33c33500e notes: fix embedded note text color in dark mode. 2019-09-22 22:59:33 -05:00
evazion cdb1c5c5ae uploads: fix drag and drop to work anywhere on page. 2019-09-22 22:59:33 -05:00
evazion bf3e9e1c76 uploads: show thumbnails in dropzone widget. 2019-09-22 22:59:33 -05:00
evazion 94d2bc72f2 uploads: move dropzone code to uploads.js. 2019-09-22 22:59:33 -05:00
evazion 5a7b3d812e uploads: fix dropzone widget to allow replacing files. 2019-09-22 22:59:33 -05:00
evazion 22d4625071 Fix #4173: Fix inconsistent max upload size. 2019-09-22 22:59:33 -05:00
evazion 1d6d816b23 nginx: add production nginx config files. 2019-09-22 22:59:33 -05:00
evazion e1cdcbd4ce uploads: add max filesize to upload page.
Fixes #4172.
2019-09-22 22:59:15 -05:00
evazion 79c22b8d50 Fix #4174: Don't allow invalid prefix combinations for autocomplete.
* Autocorrect duplicated operators (e.g. complete `--tag` as `-tag`).
* Don't accept invalid metatag + prefix combinations (e.g. don't
  complete `char:rating:s` as `rating:safe`).
2019-09-22 18:58:12 -05:00
evazion 9839f97f9e Fix #4176: Ordering favorite groups errors out. 2019-09-22 15:24:23 -05:00
evazion e98db8a5b8 css: refactor notice box css.
* Remove .ui-corner-all, .ui-state-highlight, .ui-state-error classes
  from notice boxes.
* Use .notice, .notice-info, .notice-error classes instead.
* Replace <p> elements in notices with <div>'s so that we don't have to
  work around the `margin-bottom: 1em` from <p> elements.
* Replace <h1> elements in notices with <h2>.
* Standardize info notices to use the same shade of light yellow in the
  light theme.
2019-09-22 15:09:45 -05:00
evazion 6b2e6fa3f4 css: fix width of #tags input in search box.
Fix the #tags input not shrinking to fit inside the sidebar.

https://github.com/r888888888/danbooru/commit/9720e4cfa9a02bb0d412183709f70541b2653bef#r35160195
2019-09-22 02:58:09 -05:00
evazion 8f6fd95e2d posts: change "»" links next to sources in sidebar.
* On the posts show page, make the "»" link next to the source visible
  to all users, not just builders.
* Make "»" link to the raw unnormalized source, instead of a `source:` search.
* Remove the special case for displaying old pixiv sources as `pixiv/moniker`.
2019-09-22 02:58:09 -05:00
evazion 5f43401b7b Fix #4175: Twitter no longer redirects tweet links for non-existent handles. 2019-09-22 02:58:09 -05:00
evazion 14077502a9 css: tweak dark mode colors. 2019-09-22 02:58:09 -05:00