Commit Graph

216 Commits

Author SHA1 Message Date
evazion
07e23204b6 rubocop: fix various Rubocop warnings. 2021-06-17 04:17:53 -05:00
evazion
fd09cc5e96 posts: fix Download link not respecting tagged filenames option.
Fix bug reported in forum #182766:

    The Download button on the posts page does not respect the Disable
    tagged filenames user setting. Tags are included in the filename when
    clicking the Download button even when the Disable tagged filenames
    setting is set to Yes. Right click -> Save As on the image still
    respects the setting.
2021-03-20 02:14:23 -05:00
evazion
1f637867a4 tags: refactor tag lists to use ViewComponent. 2021-02-05 02:37:02 -06:00
evazion
1e778dbbf6 posts: factor out post navbar into component.
* Factor out the post navbar into a component. The post navbar is the
  part of the post containing the current search, the list of pools, and
  the list of favgroups, along with next/prev navigation links.

* Change navbar markup: remove various unused CSS classes/IDs, change
  pools to use same markup as favgroups, replace nested <div>'s with
  flat <ul>/<li> list.

* Use CSS to truncate long searches/pool names/favgroup names if they're
  too wide for the screen (especially on mobile).
2021-01-29 21:46:21 -06:00
evazion
b6fef7f3f3 users: remove option to disable search navbar.
Remove the enable_sequential_post_navigation option. This option was
used to disable the next/previous post navbar below posts.

This option was originally added in issue #674 because of people
complaining about the navbar when it was originally added. Also there
were complaints about URLs being uglier because of search params in the
URL (e.g. /posts/1234?q=touhou). There were also various minor bugs with
it at the time, such as keyboard shortcuts not working correctly, or the
page not remembering your search after a tag edit.

These complaints are irrelevant nowadays because a) people are used to
the navbar by now (and more often complain about it *not* being there
for order:score searches), b) post URLs always contain the search now,
this option hasn't disabled that for years, and c) the initial bugs with
it were fixed years ago.

Only ~1000 users disabled this option and only ~600 were seen in the last year.

Users still wishing to hide the search navbar can use custom CSS instead.
2021-01-15 02:03:54 -06:00
evazion
1b30b71a07 posts: refactor post previews to use ViewComponent.
Refactor the post preview html to use the ViewComponent framework. This
lets us encapsulate all the HTML, CSS, and helper methods for a UI
component in a single place.

See https://viewcomponent.org.
2021-01-14 21:17:57 -06:00
evazion
1e7a5ba49d Fix ruby warnings about deprecated keyword arguments. 2021-01-11 05:12:09 -06:00
evazion
de16d31135 favorites: remove is_favorited attribute from post API.
* Remove the data-is-favorited attribute from post thumbnails.
* Remove the is_favorited attribute from the /posts.json API.
* Remove the fav_string attribute from the /posts.json API (only visible
  to moderators).
* Change `Post#favorited_by?` to not use the fav_string.

Further addresses #4652 by eliminating the last places where fav_string
was used.
2021-01-03 19:58:43 -06:00
evazion
78b9613498 Fix #4554: Searches with "-status:active" not showing deleted posts.
Also fixes #4542: Quoted search metatag status:"deleted" yields no results.
2020-08-12 20:53:14 -05:00
evazion
0a0a85ee70 Fix #4568: Send appealed posts back to the mod queue
* Include appealed posts in the modqueue.

* Add `status` field to appeals. Appeals start out as `pending`, then
  become `rejected` if the post isn't approved within three days. If the
  post is approved, the appeal's status becomes `succeeded`.

* Add `status` field to flags. Flags start out as `pending` then become
  `rejected` if the post is approved within three days. If the post
  isn't approved, the flag's status becomes `succeeded`.

* Leave behind a "Unapproved in three days" dummy flag when an appeal
  goes unapproved, just like when a pending post is unapproved.

* Only allow deleted posts to be appealed. Don't allow flagged posts to be appealed.

* Add `status:appealed` metatag. `status:appealed` is separate from `status:pending`.

* Include appealed posts in `status:modqueue`. Search `status:modqueue order:modqueue`
  to view the modqueue as a normal search.

* Retroactively set old flags and appeals as succeeded or rejected. This
  may not be correct for posts that were appealed or flagged multiple
  times. This is difficult to set correctly because we don't have
  approval records for old posts, so we can't tell the actual outcome of
  old flags and appeals.

* Deprecate the `is_resolved` field on post flags. A resolved flag is a
  flag that isn't pending.

* Known bug: appealed posts have a black border instead of a blue
  border. Checking whether a post has been appealed would require either
  an extra query on the posts/index page, or an is_appealed flag on
  posts, neither of which are very desirable.

* Known bug: you can't use `status:appealed` in blacklists, for the same
  reason as above.
2020-08-06 20:55:45 -05:00
evazion
a8577b2b94 posts: remove data-* attributes from #image element.
These attributes can be found on the `.image-container` element instead.
2020-07-31 15:16:01 -05:00
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
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
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
08ce5a71c4 Eliminate various dead code. 2020-03-31 21:57:34 -05:00
evazion
b0e2ffbe7d modqueue: remove highlighting of high/low scoring posts. 2020-03-03 03:25:51 -06:00
evazion
caf54fe45a blacklists: remove ability for mods to blacklist uploaders by name. 2020-02-16 04:00:42 -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
ab325c5d2b favgroups: convert post_ids from string to array. 2020-01-17 00:19: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
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
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
59b277ead1 users: drop id_to_name, name_to_id caching.
Changes:

* Drop Users.id_to_name.
* Don't cache Users.name_to_id.
* Replace calls to name_to_id with find_by_name when possible.
* Don't autodefine creator_name in belongs_to_creator.
* Don't autodefine updater_name in belongs_to_updater.
* Instead manually define creator_name / updater_name only on models that need
  to return these fields in the api.

id_to_name was cached to reduce the impact of N+1 query patterns in
certain places, especially in api responses that return creator_name /
updater_name fields. But it still meant we were doing N calls to
memcache. Using `includes` to prefetch users avoids this N+1 pattern.

name_to_id had no need be cached, it was never used in any performance-
sensitive contexts.

Avoiding caching also avoids the need to keep these caches consistent.
2019-08-18 11:24:42 -05:00
Albert Yi
d8aabff77b remove post keeper references 2019-01-31 15:45:06 -08:00
evazion
bd0bb658b8 Fix #3974: Pool galleries: link thumbnails to pools instead of posts. 2018-11-06 14:33:04 -06:00
evazion
841104f09a post presenter: fixup typo in 26c1eadf. 2018-11-06 13:15:09 -06:00
evazion
26c1eadf6a modqueue: move score highlighting from js to presenter.
The 'post-has-children' class was dropped because it was unused
('post-status-has-children' is already added elsewhere).
2018-11-06 10:42:48 -06:00
Albert Yi
5d83864131 fix bug with post previews 2018-11-02 16:38:28 -07:00
Albert Yi
1a41ccf7ba fix ids of post previews 2018-11-02 15:51:14 -07:00
Albert Yi
542641e3e2 refactor pool nav html 2018-11-01 17:42:49 -07:00
evazion
39374a70d3 posts/show: rename tags params to q in various places.
Fixup for 011a6f1f7.
2018-10-30 11:32:07 -05:00
Albert Yi
011a6f1f7c move post preview presenter to partial 2018-10-29 17:46:45 -07:00
evazion
88a177e1d5 TagSetPresenter: refactor humanized_essential_tag_string.
Move Post#humanized_essential_tag_string to TagSetPresenter#humanized_essential_tag_string.

This allows humanized_essential_tag_string to reuse the same set of tags
already fetched by the tag set presenter for the sidebar.

This avoids fetching the tag categories from memcache again (via
Post#typed_tags) when we're already fetched the tags once before.

This also means it's no longer necessary to cache humanized_essential_tag_string
itself in memcache, since it can be generated as quickly as the sidebar taglist.
2018-09-30 21:52:24 -05:00
evazion
739bb1270c TagSetPresenter: refactor tag string for post edit form.
Move PostPresenter#categorized_tag_groups to TagSetPresenter#split_tag_list_text.

This allows split_tag_list_text to reuse the same set of tags already
fetched by the tag set presenter for the sidebar.

This avoids a memcache call to get the tag categories when rendering the
tag string for the post edit form.
2018-09-30 21:52:24 -05:00
evazion
03abbd0683 Fix #2894: Use [[:space:]] instead of \s in regexes. 2018-09-20 19:24:38 -05:00
evazion
bbb233b93f css: remove unused or redundant rules. 2018-09-14 13:31:59 -05:00
evazion
22c27f8910 post previews: fix css for captioned post previews.
Captioned post previews (previews with the pool name, similarity, or
size beneath) need to have `height: auto` set, otherwise they'll default
to `height: 154px` (just enough for the image) and the caption won't be visible.
2018-09-06 20:44:47 -05:00
Albert Yi
76342582b2 add fallback for older previews 2018-07-18 13:02:05 -07:00
Albert Yi
a610111658 switch post previews to use flexbox, add better styling for cropped thumbnails 2018-07-18 11:38:00 -07:00
Albert Yi
4d4f36c2c8 make image cropping optional 2018-07-09 10:07:51 -07:00
Albert Yi
56b40a0255 add iqdb preview 2018-06-22 16:41:13 -07:00
Albert Yi
64446d49e1 add image cropping support 2018-06-22 14:41:57 -07:00
evazion
a6499b5169 post tooltips: add disable option (#3689).
* Add "disable post tooltips" account setting.
* Add back title attribute for when fancy tooltips are disabled.
2018-04-28 23:50:51 -05:00