Commit Graph

8350 Commits

Author SHA1 Message Date
evazion
d2c6d6d17b iqdb: hide low similarity results behind "show" link. 2019-10-16 23:53:09 -05:00
evazion
958ba0f8b7 iqdb: delete leftover unused code.
* Delete unused Iqdb::Download module.
* Fix N+1 query in decorate_posts.
* /iqdb_queries: Raise max value of `limit` param to 1000.
2019-10-16 23:52:39 -05:00
evazion
57de1d8ef3 /uploads: raise iqdb similarity threshold to 50%. 2019-10-15 01:12:08 -05:00
evazion
0059597f1e /uploads: fix manually clicking 'Similar' button.
Manually clicking Similar called `/iqdb_queries` instead of
`/iqdb_queries.js`, which caused it to update the page incorrectly.
2019-10-15 00:49:31 -05:00
evazion
ab5227e8bd Fix #4193: Wiki tags for related tags are no longer in wiki order. 2019-10-15 00:36:22 -05:00
evazion
1ca4add525 related tags: fix exception on copyright tags with nonexistent wiki pages. 2019-10-15 00:19:43 -05:00
evazion
eb2bec95fa related tags: fix artist profile links not opening in new tab. 2019-10-14 23:07:43 -05:00
evazion
ae521e600e iqdb: proxy iqdb searches through danbooru.
Previously the search form on the /iqdb_queries page submitted directly
to the iqdb service (karasuma.donmai.us), which redirected back to
Danbooru with the search results.

This was different than API requests, which submitted to
/iqdb_queries.json which proxied the call to iqdb through Danbooru.
Because of this, searches on the /iqdb_queries page had different
behavior than API requests. Things like filesize limits and referrer
spoofing were handled differently.

Now searches on the /iqdb_queries page submit directly to Danbooru. This
is simpler and it means that API requests and HTML requests have the
same behavior.
2019-10-14 21:16:04 -05:00
evazion
f7116ad1c4 post previews: fix thumbnail width/height outside post index.
Normally thumbnails have a fixed size of 154x154, but that's not always
desirable outside of the posts index because it creates empty gaps
around thumbnails.
2019-10-14 21:16:04 -05:00
evazion
5b0c77d126 iqdb: add more info to iqdb thumbnails.
* Add the source (twitter, pixiv, etc) and upload date ("X minutes ago")
  to iqdb thumbnails.
* Link the filesize to the full file so you can compare files in new tabs.
* Link the similarity to a iqdb search so you can pivot your search to other posts.
2019-10-14 21:16:04 -05:00
evazion
fa37b1edcd iqdb: lower similarity cutoff, return more results (fix #4190).
* Change cutoffs on upload page to max 5 results, min. 20% similarity.
* Change cutoffs on standalone /iqdb_queries page to max 20 results, min. 0% similarity.
* /iqdb_queries.json: add `limit` and `similarity` params to change default cutoffs.
2019-10-14 21:16:04 -05:00
evazion
ca54e2d67b iqdb: simplify ajax call.
Also add support for .xml responses to /iqdb_queries.
2019-10-14 21:16:04 -05:00
evazion
ccf32aa7a4 posts: remove 'Similar' button from post edit form.
Remove the 'Similar' button next to the source field in the post edit
form. Removed for multiple reasons:

* It doesn't make sense to have to open the edit form to do a reverse
  image search.

* The 'Similar' button tries to redownload the file from the source,
  which has various problems: the source might have been deleted, it
  might have been changed or revised, it might be a format that iqdb
  can't handle (ugoira/webm/mp4), or it might otherwise not match the
  the actual post.

* The 'Find similar' button already exists in the sidebar and it does
  the right thing by using the preview image from Danbooru, which
  avoids all the above issues.
2019-10-14 21:16:04 -05:00
evazion
f6b73a5150 posts: fix exception when rendering thumbnails for posts with null width/height.
Fixes https://danbooru.donmai.us/forum_topics/15909?page=4#forum_post_160367.
2019-10-14 21:16:04 -05:00
evazion
18e8b13aeb css: fix long usernames in comments not word wrapping.
Ex: https://danbooru.donmai.us/posts/4206#comment_1954688.
2019-10-14 21:16:04 -05:00
evazion
269e2973ac tests: fix related tag tests. 2019-10-14 15:11:04 -05:00
evazion
3e37869768 rails: disable asset pipeline.
Disable the assets pipeline (Sprockets). Sprockets errors out now after
upgrading to Sprockets 4 because of missing config files. We don't use
it any more after switching to Webpack, so we can disable it entirely.

Also disable a few more Rails features that we don't use (ActiveStorage,
ActionCable, ActionMailbox, ActionText).
2019-10-14 13:50:31 -05:00
evazion
90f32b2ae1 Update gems. 2019-10-13 19:09:06 -05:00
evazion
07116d1445 Mark links in notes and fetch source data box as external. 2019-10-13 18:53:46 -05:00
evazion
7ebf6ed9d7 Remove rel="nofollow" from internal links.
This was used to discourage crawlers from crawling certain pages we
didn't want them to crawl, primarily post searches.

Remove because there are better ways to control crawling. Some of these
links weren't even visible to crawlers anyway. This lets us be
consistent about only applying rel="nofollow" to external links.
2019-10-13 18:53:46 -05:00
evazion
8bffe8dba1 Fix #4189: long source: link not wrapping on tag changes report, and underscores shown as spaces
* Use underscores instead of spaces for tags in inline tag lists (upload
  tags report, tooltips, modqueue, comments page).

* Allow long tags to word wrap. Fixes long sources not wrapping in the
  uploads tag report. Also fixes very long tags that don't have
  underscores not wrapping in the sidebar (ex: kuouzumiaiginsusutakeizumonokamimeichoujin_mika).
2019-10-13 18:53:46 -05:00
evazion
20f28910da /posts: word wrap long sources in sidebar.
* Don't truncate long sources in the sidebar on the post show page. Word
  wrap them instead.
* Word wrap long external links in general (mainly links in dtext).
* Turn sources into links on modqueue page.
2019-10-13 18:53:46 -05:00
evazion
ee6f7a1d7e /posts: increase width of sidebar.
Also fix search box to stretch to full width of sidebar.
2019-10-13 18:53:46 -05:00
evazion
f3f80ff4f8 gems: bump dtext version. 2019-10-11 18:45:55 -05:00
evazion
33f2725ae7 Fix #4112: Colorize tags in DText.
DText is processed in three phases: a preprocessing phase, the regular
parsing phases, and a postprocessing phase.

In the preprocessing phase we extract all the wiki links from all the
dtext messages on the page (more precisely, we do this in forum threads
and on comment pages, because these are the main places with lots of
dtext). This is so we can lookup all the tags and wiki pages in one
query, which is necessary because in the worst case (in certain forum
threads and in certain list_of_* wiki pages) there can be hundreds of
tags per page.

In the postprocessing phase we fixup the html generated by the ragel
parser to add CSS classes to wiki links. We do this in a postprocessing
step because it's easier than doing it in the ragel parser itself.
2019-10-11 18:45:55 -05:00
evazion
3d9c6fef1d related tags: fix wiki page tag extraction.
* Parse the wiki page with the actual dtext parser instead of by hand.
  This is so that wiki links inside things like [nodtext] or [code]
  blocks are handled properly.

* Only include tags that exist and are nonempty. Don't include links to
  dead pages or blank tags.
2019-10-11 16:53:37 -05:00
evazion
6b4ac0c042 wiki pages: fix title normalization.
Fix inconsistent title normalization. Strip whitespace and underscores
from the ends of the title and strip consecutive underscores.
2019-10-11 16:53:37 -05:00
evazion
08b1c76533 dtext: refactor stripping markup from dtext.
There are a handful of places where we need to strip markup from a piece
of dtext, primarily in <meta> description tags in the wiki. Currently
the dtext parser handles this by having a special mode where it parses
the text but doesn't output html tags. Here we refactor to instead parse
the text normally then strip out the html tags after the fact.

This is more flexible and allows us to simplify a lot of things in the
dtext parser. This also produces more readable output than before in
certain cases.
2019-10-09 16:36:01 -05:00
evazion
30091b989d /pools: fix pagination typo. 2019-10-08 00:50:27 -05:00
evazion
3955c3fc8d /forum_topics: fix default limit being ignored. 2019-10-08 00:00:16 -05:00
evazion
cd47987b05 tests: fixup tests for cc4e39b88. 2019-10-07 23:29:31 -05:00
evazion
930e904594 mobile: reduce swipe gesture sensitivity.
Address complaints that gestures are too sensitive and interfere with
scrolling.
2019-10-07 23:20:16 -05:00
evazion
eb80d4f36e mobile: disable "swipe left to go back" gesture on post show page.
The swipe left gesture interfered with scrolling left and right, using
using pinch to zoom, and with copy and pasting text. This gesture wasn't
really necessary anyway, since the back button can always be used to go
back instead.
2019-10-07 23:17:13 -05:00
evazion
64d32a5201 js: upgrade jquery to 3.4.1. 2019-10-07 22:50:03 -05:00
evazion
f1d2e0b849 Update gems. 2019-10-07 22:47:19 -05:00
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
r888888888
62a1aeabce expose user's api key as api_token field on sessions 2019-10-07 13:54:52 -07: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