Commit Graph

8377 Commits

Author SHA1 Message Date
evazion
754e3a2ee2 tests: fix forum post votes & wiki page updater tests.
* Move forum post vote tests from test/controllers to test/functional.
* Fix forum post vote tests to work with new routes.
* Fix obsolete wiki page tests dealing with updater_id.
2019-10-28 02:13:10 -05:00
evazion
dfbf4f3f0a Remove single alias/implication requests.
* Remove the single alias and implication request forms. From now
  on, bulk update requests are the only way to request aliases or
  implications.

* Remove the forum topic ID field from the bulk update request form.
  Instead, to attach a BUR to an existing topic you go to the topic then
  you click "Request alias/implication" at the top of the page.

* Update the bulk update request form to give better examples for the
  script format and to explain the difference between aliases and
  implications.
2019-10-28 01:36:28 -05:00
evazion
b5a40aa233 bulk update requests: list upvotes/downvotes on index page. 2019-10-28 01:06:23 -05:00
evazion
0e159960a2 forum post votes: add index page. 2019-10-28 01:06:23 -05:00
evazion
d617b20b49 dtext links: allow searching for forum posts linking to specific tag. 2019-10-27 01:05:54 -05:00
evazion
d946a84480 iqdb: download files inside danbooru, not inside iqdb.
Instead of sending IQDB the image url and letting it download the file,
download the file on Danbooru's end and send IQDB the downloaded file.

This fixes several issues:

* Some sites need the referer header set to avoid hotlink protection
  when downloading the file. Danbooru knows how to deal with this but
  IQDB doesn't.

* We need to enforce certain restrictions when downloading files,
  including setting max filesize limits, setting max timeouts, and not
  allowing downloads from forbidden IPs (to avoid SSRF attacks).
  Danbooru knows how to handle these things but IQDB doesn't.
2019-10-26 15:02:07 -05:00
evazion
a6efaa54a1 Downloads::File: fix following 302 redirects during download.
Fixes downloading yande.re preview images for iqdb. Yande.re previews
return a 302 redirect to the actual file. Before the html in the body of
the 302 response would get prepended to the image file.

https://files.yande.re/data/preview/12/8f/128fb480d8589be26d1dce7e1d841bcb.jpg
=> https://assets.yande.re/data/preview/12/8f/128fb480d8589be26d1dce7e1d841bcb.jpg
2019-10-26 14:04:19 -05:00
evazion
a15bbe4264 moebooru: fix preview_urls to fallback to image_urls.
Fix the moebooru strategy to fallback to returning the image url if we
can't find the preview url. Fixes iqdb lookups failing in some cases
because the strategy didn't return a valid url for preview_url.
2019-10-26 13:51:58 -05:00
evazion
ecfeaca7d4 iqdb: fix handling of error responses.
Handle JSON error responses returned by IQDB: `{ "error": <message> }`.
2019-10-26 13:01:08 -05:00
evazion
438a7a5a70 wikis: add "tag history", "wiki history", "what links here" sidebar options. 2019-10-26 02:59:46 -05:00
evazion
3a544ba5e0 Fix tag ordering in humanized_essential_tag_string.
* Pick the largest character or copyright tags by post count. Previously
  we picked the tags with the longest names, which was nonsensical.

* Remove tag cateogory logic from config file. We can't avoid hardcoding
  some knowledge about tag categories here, so there's no point in trying.

This affects tab titles on post show pages as well as filenames in
downloaded images.
2019-10-26 02:36:55 -05:00
evazion
ac775e2bdd Fix #4199: Aliased tags not included in related wiki tags. 2019-10-24 19:48:30 -05:00
evazion
6dcf0484f0 dtext links: add fix script to populate dtext_links table. 2019-10-24 19:48:30 -05:00
evazion
a0b6c9b116 wiki pages: drop creator and updater fields.
Drop the creator_id and updater_id fields from wiki pages. These fields
had several issues:

* The creator_id field was inconsistent with the wiki_page_versions
  table. Apparently during the migration to Danbooru 2 in 2012-2013 the
  creator_id field got reset to whoever last updated the wiki at that
  point in time.

* Saving a wiki would set the updater_id even when nothing actually
  changed. This also caused the updated_at timestamp to get bumped.
  Because of this, anything that saved a wiki, including things like
  creating aliases or implications, would bump the updater_id and
  updated_at even though the wiki didn't actually change. This meant
  these fields weren't consistent with the wiki_page_versions history.

Changes:

* Remove `creator_name` field from the /wiki_pages.json API.
* Remove creator name search option from /wiki_pages/search.
2019-10-24 19:48:30 -05:00
evazion
97a758dec6 dtext links: add search options for finding broken links.
Add "Wiki Exists?" and "Tag Exists?" options to /dtext_links. These can
be used to find links to wikis or tags that don't exist (broken links).
2019-10-23 21:36:48 -05:00
evazion
812cabfc07 dtext links: add basic index page. 2019-10-23 21:36:48 -05:00
evazion
9f0ecf7247 dtext links: add table for tracking links between wikis.
Add a dtext_links table for tracking links between wiki pages. This is
to allow for broken link detection and "what links here" searches, among
other uses.
2019-10-23 21:36:48 -05:00
evazion
f54885b72e css: update dtext external link icon selector.
DText was changed so that the .dtext-external-link class is now applied to all external links.
Previously it applied only to named links (ex: "google":[http://www.google.com]), not bare
links (ex: http://www.google.com).
2019-10-23 21:33:15 -05:00
evazion
8fbf989e8e /iqdb_queries: support bare image_url param. 2019-10-23 10:46:36 -05:00
evazion
5abbab644d font awesome: switch from svg+js to webfonts.
https://fontawesome.com/how-to-use/on-the-web/other-topics/performance

The default version of Font Awesome uses Javascript to replace <i> tags
with dynamically generated SVG elements. This adds a lot of weight to
the Javascript bundle (at least 1MB+), even when using subsetting to
load only the icons we actually use. The web font version is less
featureful than the JS version, but much lighter weight.
2019-10-22 16:20:53 -05:00
evazion
abee048de5 iqdb: use preview image url for iqdb lookups.
* Fix the IQDB lookup to handle error messages returned by IQDB.

* Fix `undefined method `>=' for nil:NilClass` error when trying to upload
  ugoiras. Using the preview image for IQDB lookups should be faster and
  give the same results as the full image, plus it should work with things
  like ugoiras and videos that IQDB can't handle.

  Also add an image_url param so that API users can continue using the
  full image if needed.
2019-10-22 13:07:21 -05:00
evazion
2c6567b5d2 Remove uses of the read replica database.
https://danbooru.donmai.us/forum_topics/9127?page=283#forum_post_160508

There was a recent outage that was caused by the read replica
(yukinoshita.donmai.us) being temporarily unavailable. The pg driver in
rails got hardstuck trying to connect to the replica, which brought down
the whole site. The app servers stopped responding and could only be
brought down with SIGKILL. Even try to boot the rails console didn't
work.

We only really used this to calculate tag counts inside Post.fast_count,
which wasn't really beneficial since the read replica is slower than the
main database.
2019-10-22 12:15:46 -05:00
evazion
8541974d19 Update gems. 2019-10-22 12:11:31 -05:00
evazion
103742eb6c Fix #4058: FontAwesome CDN is slow/blocking.
Switch to the free self-hosted version of FontAwesome. We're not using
any Pro icons, so the Pro version isn't necessary.
2019-10-22 12:02:26 -05:00
evazion
e9a3ed563c dtext: fix tag colors bleeding through [spoiler] tags.
https://danbooru.donmai.us/forum_topics/9127?page=283#forum_post_160443
2019-10-18 07:56:55 -05:00
evazion
e2a8f618a3 uploads: fix "Related Posts" header to match "Similar Posts" header. 2019-10-17 01:19:00 -05:00
evazion
649c10ecf8 Fix #4194: Add CSS IDs to the uploads page. 2019-10-17 01:03:13 -05:00
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