Commit Graph

483 Commits

Author SHA1 Message Date
evazion
20f8a26709 tests: fix rails 2.7 keyword parameter deprecation warnings. 2020-05-25 01:48:46 -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
ad02e0f62c posts/index: fix rating:s being included in page title in safe mode.
Fixes bug described in d3e4ac7c17 (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
e3187e0bd0 tags: add general?, character?, copyright?, artist?, meta?, empty? helper methods. 2020-05-10 23:56:50 -05:00
evazion
d675bde187 presenters: inline UploadPresenter. 2020-05-10 19:29:12 -05:00
evazion
a2814364ee presenters: merge PostSetPresenter into PostSet.
Reduce indirection. PostSet is basically a collection of helper methods
for rendering the post index page. PostSetPresenter was a set of helper
methods for rendering the tag list on the post index page. These don't
need to be separated.
2020-05-10 19:28:45 -05:00
evazion
2749269d5b related tags: refactor to take PostQuery instead of tag string.
Refactor RelatedTagCalculator and RelatedTagQuery to take a PostQuery
object instead of a raw tag string.

* Fixes the related tag sidebar on the post index page having to reparse
  the query and reevaluate aliases.
* Fixes related tags being affected by the current user's safe mode and
  hide deleted posts settings.
2020-05-08 15:40:28 -05:00
evazion
67aab0236d search: apply aliases after parsing searches.
Make PostQueryBuilder apply aliases earlier, immediately after parsing
the search.

On the post index page there are multiple places where we need to apply
aliases:

* When running the search with PostQueryBuilder#build.
* When calculating the search count with PostQueryBuilder#fast_count.
* When calculating the related tags for the sidebar.
* When tracking missed searches and popular searches for Reportbooru.
* When looking up wiki excerpts.

Applying aliases after parsing ensures we only have to apply aliases
once for all of these things.

We also normalize the order of tags in searches and strip repeated tags.
This is so that we have consistent cache keys for fast_count.

* Fixes searches for aliased tags being counted as missed searches (fixes #4433).
* Fixes wiki excerpts not showing up when searching for aliased tags.
2020-05-07 13:53:35 -05:00
evazion
f38c38f26e search: split tag_match into user_tag_match / system_tag_match.
When doing a tag search, we have to be careful about which user we're
running the search as because the results depend on the current user.
Specifically, things like private favorites, private favorite groups,
post votes, saved searches, and flagger names depend on the user's
permissions, and whether non-safe or deleted posts are filtered out
depend on whether the user has safe mode on or the hide deleted posts
setting enabled.

* Refactor internal searches to explicitly state whether they're
  running as the system user (DanbooruBot) or as the current user.
* Explicitly pass in the current user to PostQueryBuilder instead of
  implicitly relying on the CurrentUser global.
* Get rid of CurrentUser.admin_mode? (used to ignore the hide deleted
  post setting) and CurrentUser.without_safe_mode (used to ignore safe
  mode).
* Change the /counts/posts.json endpoint to ignore safe mode and the
  hide deleted posts settings when counting posts.
* Fix searches not correctly overriding the hide deleted posts setting
  when multiple status: metatags were used (e.g. `status:banned status:active`)
* Fix fast_count not respecting the hide deleted posts setting when the
  status:banned metatag was used.
2020-05-07 03:29:44 -05:00
evazion
a753ebbea9 posts: move fast_count to PostQueryBuilder. 2020-05-07 03:29:38 -05:00
evazion
2cbe4d3672 search: add unaliased:<tag> metatag.
* Add unaliased:<tag> metatag. This allows you to search for a tag
  without applying aliases. This is mainly useful for debugging purposes
  and for searching for large tags that are in the process of being
  aliased but haven't had all their posts moved yet.

* Remove the "raw" url param from the posts index page. The "raw" param
  also caused the search to ignore aliases, but it was undocumented and
  exploitable. It was possible to use the raw param to view private
  favorites since favorites are treated like a hidden tag.
2020-04-30 17:45:07 -05:00
evazion
dd0d9dff4a search: move misc search parsing helpers to PostQueryBuilder.
* Move various search parser helper methods (`has_metatag?`,
  `is_single_tag?` et al) from PostSets and the Tag model to
  PostQueryBuilder.

* Fix various minor bugs stemming from trying to check if a search query
  contains certain metatags using regexes or other adhoc techniques.
2020-04-23 01:51:30 -05:00
evazion
844e8703d8 posts: remove tags from thumbnail alt text. 2020-04-04 02:36:24 -05:00
evazion
6b1d73ddae user name changes: fix permission inconsistencies.
* Let moderators see name changes for deleted users on the user name
  change requests index and show pages. Before they could see name changes
  for deleted users on user profiles, but not on the user name changes index.

* Let members see previous names on profile pages. Before they could see
  previous names on the user name changes index, but not on profile pages
  (ref: #4382).
2020-04-03 23:44:02 -05:00
evazion
08ce5a71c4 Eliminate various dead code. 2020-03-31 21:57:34 -05:00
evazion
1a2c082b86 search: support negated wildcards in post searches.
* Support negated wildcards in searches (e.g. "holding -holding_*")
* Raise wildcard limit to matching 25 tags regardless of user level.
* Fix wildcards potentially matching empty tags.
* Fix wildcard tags being sorted by post count only, and therefore not
  having a stable ordering when tags have equal post counts.
* Fix sidebar to calculate wildcards tags the same way the search does.
2020-03-06 23:23:38 -06:00
evazion
85f1674618 modqueue: highlight bad tags instead of entire post.
Change it so that when a post contains bad tags, the tags themselves are
highlighted rather than the entire post.

This also adds a data-tag-name attribute to tags in tag lists.
2020-03-03 03:25:51 -06:00
evazion
b0e2ffbe7d modqueue: remove highlighting of high/low scoring posts. 2020-03-03 03:25:51 -06:00
evazion
9ddf408ec5 modqueue: add sidebar.
Add a sidebar to the modqueue page that shows the following information:

* Number of pending and flagged posts.
* Number of posts disapproved for poor quality or breaking rules.
* Top uploaders in the queue.
* Top artist, copyright, and character tags in the queue.
2020-03-02 13:47:54 -06:00
evazion
ce11485fe0 Remove super voters. 2020-02-23 17:52:38 -06:00
evazion
2f5255f6b7 user presenter: fix syntax error in previous names.
Fixup for 0ad42d23c.
2020-02-21 00:20:18 -06:00
evazion
0ad42d23c9 models: refactor search visibility methods.
Refactor how model visibility works in index actions:

* Call `visible` in the controller instead of in model `search`
  methods. This decouples model visibility from model searching.

* Explicitly pass CurrentUser when calling `visible`. This reduces
  hidden dependencies on the current user inside models.

* Standardize on calling the method `visible`. In some places it was
  called `permitted` instead.

* Add a `visible` base method to ApplicationModel.
2020-02-19 17:08:59 -06:00
evazion
7e67d3dd9c views: replace .category-N css classes with .tag-type-N
* Replace the .category-N CSS classes on tags with .tag-type-N. Before
  we were inconsistent about whether tag colors were indicated with
  .category-N or .tag-type-N. Now it's always .tag-type-N.

* Fix various places to not use Tag.category_for. Tag.category_for does
  one Redis call per tag lookup, which leads to N Redis calls on many
  pages. This was inefficient because usually we either already had the
  tags from the database, or we could fetch them easily.
2020-02-16 04:35:37 -06:00
evazion
caf54fe45a blacklists: remove ability for mods to blacklist uploaders by name. 2020-02-16 04:00:42 -06:00
evazion
60ff2ae929 models: rename post/pool archives to post/pool versions. 2020-02-15 06:52:10 -06:00
evazion
3c2a379d6f uploads: replace old upload limits with new upload limits. 2020-02-03 22:05:58 -06:00
evazion
fb9b2bb014 views: update seo title and description of post index page.
Change the title of the post index page to look like this:

    "Danbooru: Anime Image Board" (for the front page)
    "Kantai Collection Art | Danbooru" (for a tag search)

Change the meta description of the front page to look like this:

    Danbooru is the original anime image 'booru. Find over 3.75 million
    anime pictures categorized by over 100 million tags.

Change the meta description for a tag search to look like this:

    Find over 37,168 Azur Lane images on Danbooru. Azur Lane (碧蓝航线)
    (벽람항로) is a Chinese shipgirl-themed side-scrolling shoot 'em up
    mobile game developed by Shanghai Manjuu and Xiamen Yongshi...
2020-01-25 05:44:38 -06:00
evazion
edaf6323fd /favorite_groups: add search, creators, timestamps, edit/delete links. 2020-01-22 02:03:19 -06:00
evazion
4a7322b197 users: rework privacy mode into private favorites (fix #4257).
* Rename 'privacy mode' to 'private favorites'.
* Make the private favorites setting only hide favorites, not favgroups
  and not the user's uploads on their profile page.
* Make the favgroup is_public flag default to true instead of false and
  fix existing favgroups to be public if the user didn't have privacy mode
  enabled before.
* List _all_ public favgroups on the /favorite_groups index, not just
  favgroups belonging to the current user.
* Add a /users/<id>/favorite_groups endpoint.
2020-01-17 22:24:29 -06:00
evazion
ed75db8d93 Merge pull request #4266 from BrokenEagle/fix-missing-blank-message
Remove posts not shown for blank message check
2020-01-17 01:08:32 -06:00
BrokenEagle
b2d12e2e20 Remove posts not shown for blank message check 2020-01-17 07:01:16 +00:00
evazion
ab325c5d2b favgroups: convert post_ids from string to array. 2020-01-17 00:19:20 -06:00
evazion
617e1ca98a users/show: change favcount link to ordfav: search. 2020-01-15 13:22:30 -06:00
evazion
b3eeb170cb explore/posts/intro: remove page.
This was an alternate frontpage that contained a list of previews of the
most popular tags. This page was never linked from anywhere and it was
unknown by most users.
2020-01-12 23:01:04 -06:00
evazion
12a845de92 explore/posts/popular: refactor post previews. 2020-01-12 23:01:04 -06:00
evazion
74ce866890 explore/posts/viewed: refactor post previews. 2020-01-12 23:01:04 -06:00
evazion
083ce75c10 pools/gallery: refactor post previews. 2020-01-12 23:01:04 -06:00
evazion
8ddf7ee716 wiki pages: drop unused wiki page presenter. 2020-01-12 20:13:44 -06:00
evazion
f2269d39a7 wiki_pages/show: fix <meta> description tag.
Use an excerpt of the first paragraph rather than the entire page.
2020-01-12 20:13:44 -06:00
evazion
50c6840be3 wiki_pages/show: refactor post previews.
* Increase number of previews from 4 to 8.
* Eliminate wiki page post set classes.
2020-01-12 20:13:44 -06:00
evazion
77935808e2 user profiles: fix links when Post.fast_count returns nil.
If Post.fast_count returns nil, then the link_to call becomes
link_to(nil, <posts_path>) so the link text becomes the url itself,
which isn't what we want.

Instead the count is displayed as a '?' mark to indicate that we don't
know the true count.
2020-01-05 17:48:50 -06:00
evazion
5341dc4197 tags: remove Tag.trending method.
This is used for the frontpage taglist when popular searches are
disabled. This isn't used in production and there's no need for it in
development.
2020-01-01 13:59:20 -06:00
evazion
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06:00
evazion
5791f4e805 recommendations: show favcount beneath recommended posts.
* Add favorite count beneath recommended posts. Clicking the favcount
  loads more recommended posts like that post.
* Increase number of recommendations shown on post show page.
2019-12-02 03:08:01 -06:00
evazion
3a908f84bb wiki pages: use names instead of ids in urls.
Switching to using wiki names in URLs instead of IDs:

* https://danbooru.donami.us/wiki_pages/vocaloid
* https://danbooru.donami.us/wiki_pages/hatsune_miku

ID numbers can still be used, but they redirect to the name instead:

* https://danbooru.donami.us/wiki_pages/11 (redirects to /wiki_pages/touhou).

Numeric tags are prefixed with '~' to distinguish them from IDs:

* https://danbooru.donami.us/wiki_pages/2019 (the wiki with id 2019)
* https://danbooru.donami.us/wiki_pages/~2019 (the wiki for the tag named 2019)

The tag names 'new' and 'search' are disallowed to prevent conflicts
with existing routes:

* https://danbooru.donami.us/wiki_pages/new
* https://danbooru.donami.us/wiki_pages/search
2019-10-31 19:04:18 -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
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
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
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