Changes: * Make it so you can click or hover over a post's favorite count to see the list of public favorites. * Remove the "Show »" button next to the favorite count. * Make the favorites list visible to all users. Before favorites were only visible to Gold users. * Make the /favorites page show the list of all public favorites, instead of redirecting to the current user's favorites. * Add /posts/:id/favorites endpoint. * Add /users/:id/favorites endpoint. This is for several reasons: * To make viewing favorites work the same way as viewing upvotes. * To make posts load faster for Gold users. Before, we loaded all the favorites when viewing a post, even when the user didn't look at them. This made pageloads slower for posts that had hundreds or thousands of favorites. Now we only load the favlist if the user hovers over the favcount. * To make the favorite list visible to all users. Before, it wasn't visible to non-Gold users, because of the performance issue listed above. * To make it more obvious that favorites are public by default. Before, since regular users could only see the favcount, they may have mistakenly believed other users couldn't see their favorites.
82 lines
2.8 KiB
Ruby
82 lines
2.8 KiB
Ruby
module ComponentsHelper
|
|
def post_preview(post, **options)
|
|
render PostPreviewComponent.new(post: post, **options)
|
|
end
|
|
|
|
def post_previews_html(posts, **options)
|
|
posts = posts.includes(:media_asset) if posts.is_a?(ActiveRecord::Relation)
|
|
render PostPreviewComponent.with_collection(posts, **options)
|
|
end
|
|
|
|
def render_comment(comment, current_user:, **options)
|
|
render CommentComponent.new(comment: comment, current_user: current_user, **options)
|
|
end
|
|
|
|
def render_comment_section(post, **options)
|
|
render CommentSectionComponent.new(post: post, **options)
|
|
end
|
|
|
|
def render_post_votes(post, **options)
|
|
render PostVotesComponent.new(post: post, **options)
|
|
end
|
|
|
|
def render_post_votes_tooltip(post, **options)
|
|
render PostVotesTooltipComponent.new(post: post, **options)
|
|
end
|
|
|
|
def render_favorites_tooltip(post, **options)
|
|
render FavoritesTooltipComponent.new(post: post, **options)
|
|
end
|
|
|
|
def render_post_navbar(post, **options)
|
|
render PostNavbarComponent.new(post: post, **options)
|
|
end
|
|
|
|
def render_source_data(source, **options)
|
|
render SourceDataComponent.new(source: source, **options)
|
|
end
|
|
|
|
# A simple vertical tag list with no post counts. Used in related tags.
|
|
def render_simple_tag_list(tag_names, **options)
|
|
tags = TagListComponent.tags_from_names(tag_names)
|
|
render TagListComponent.new(tags: tags, **options).with_variant(:simple)
|
|
end
|
|
|
|
# A horizontal tag list, with tags grouped by category. Used in post
|
|
# tooltips, on the comments index, and in the modqueue.
|
|
def render_inline_tag_list(post, **options)
|
|
render TagListComponent.new(tags: post.tags, **options).with_variant(:inline)
|
|
end
|
|
|
|
def render_inline_tag_list_from_names(tag_names, **options)
|
|
tags = TagListComponent.tags_from_names(tag_names)
|
|
render TagListComponent.new(tags: tags, **options).with_variant(:inline)
|
|
end
|
|
|
|
# A vertical tag list, with tags split into categories. Used on post show pages.
|
|
def render_categorized_tag_list(post, **options)
|
|
render TagListComponent.new(tags: post.tags, **options).with_variant(:categorized)
|
|
end
|
|
|
|
# A vertical tag list, used in the post index sidebar.
|
|
def render_search_tag_list(tag_names, **options)
|
|
tags = TagListComponent.tags_from_names(tag_names)
|
|
render TagListComponent.new(tags: tags, **options).with_variant(:search)
|
|
end
|
|
|
|
# The <link rel="next"> / <link rel="prev"> links in the <meta> element of the <head>.
|
|
def render_meta_links(records)
|
|
render PaginatorComponent.new(records: records, params: params).with_variant(:meta_links)
|
|
end
|
|
|
|
def numbered_paginator(records)
|
|
paginator = PaginatorComponent.new(records: records, params: params)
|
|
|
|
if paginator.use_sequential_paginator?
|
|
render paginator.with_variant(:sequential)
|
|
else
|
|
render paginator.with_variant(:numbered)
|
|
end
|
|
end
|
|
end
|