posts: show length of videos and animations in thumbnails.
Show the length of videos and animated posts in the thumbnail. The length is shown the top left corner in MM:SS format. This replaces the play button icon. Show a speaker icon instead of a music note icon for posts with sound. Doing this requires doing `.includes(:media_asset)` in a bunch of places to avoid N+1 queries when we access the post's duration.
This commit is contained in:
@@ -3,7 +3,7 @@ class ArtistCommentariesController < ApplicationController
|
||||
|
||||
def index
|
||||
@commentaries = authorize ArtistCommentary.paginated_search(params)
|
||||
@commentaries = @commentaries.includes(post: :uploader) if request.format.html?
|
||||
@commentaries = @commentaries.includes(post: [:uploader, :media_asset]) if request.format.html?
|
||||
|
||||
respond_with(@commentaries)
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class ArtistCommentaryVersionsController < ApplicationController
|
||||
def index
|
||||
set_version_comparison
|
||||
@commentary_versions = ArtistCommentaryVersion.paginated_search(params)
|
||||
@commentary_versions = @commentary_versions.includes(:updater, post: :uploader) if request.format.html?
|
||||
@commentary_versions = @commentary_versions.includes(:updater, post: [:uploader, :media_asset]) if request.format.html?
|
||||
|
||||
respond_with(@commentary_versions)
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class CommentVotesController < ApplicationController
|
||||
|
||||
def index
|
||||
@comment_votes = authorize CommentVote.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
||||
@comment_votes = @comment_votes.includes(:user, comment: [:creator, { post: [:uploader] }]) if request.format.html?
|
||||
@comment_votes = @comment_votes.includes(:user, comment: [:creator, { post: [:uploader, :media_asset] }]) if request.format.html?
|
||||
|
||||
respond_with(@comment_votes)
|
||||
end
|
||||
|
||||
@@ -99,7 +99,7 @@ class CommentsController < ApplicationController
|
||||
@comments = @comments.includes(:creator, :post)
|
||||
@comments = @comments.select { |comment| comment.post.visible? }
|
||||
elsif request.format.html?
|
||||
@comments = @comments.includes(:creator, :updater, post: :uploader)
|
||||
@comments = @comments.includes(:creator, :updater, post: [:uploader, :media_asset])
|
||||
@comments = @comments.includes(:votes) if CurrentUser.is_member?
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class ModqueueController < ApplicationController
|
||||
|
||||
def index
|
||||
authorize :modqueue
|
||||
@posts = Post.includes(:appeals, :disapprovals, :uploader, flags: [:creator]).in_modqueue.available_for_moderation(CurrentUser.user, hidden: search_params[:hidden])
|
||||
@posts = Post.includes(:appeals, :disapprovals, :uploader, :media_asset, flags: [:creator]).in_modqueue.available_for_moderation(CurrentUser.user, hidden: search_params[:hidden])
|
||||
@modqueue_posts = @posts.reselect(nil).reorder(nil).offset(nil).limit(nil)
|
||||
@posts = @posts.paginated_search(params, count_pages: true, count: @modqueue_posts.to_a.size, defaults: { order: "modqueue" })
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class PostAppealsController < ApplicationController
|
||||
@post_appeals = authorize PostAppeal.paginated_search(params)
|
||||
|
||||
if request.format.html?
|
||||
@post_appeals = @post_appeals.includes(:creator, post: [:appeals, :uploader, :approver])
|
||||
@post_appeals = @post_appeals.includes(:creator, post: [:appeals, :uploader, :approver, :media_asset])
|
||||
else
|
||||
@post_appeals = @post_appeals.includes(:post)
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class PostApprovalsController < ApplicationController
|
||||
|
||||
def index
|
||||
@post_approvals = authorize PostApproval.paginated_search(params)
|
||||
@post_approvals = @post_approvals.includes(:user, post: :uploader) if request.format.html?
|
||||
@post_approvals = @post_approvals.includes(:user, post: [:uploader, :media_asset]) if request.format.html?
|
||||
|
||||
respond_with(@post_approvals)
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class PostFlagsController < ApplicationController
|
||||
@post_flags = authorize PostFlag.paginated_search(params)
|
||||
|
||||
if request.format.html?
|
||||
@post_flags = @post_flags.includes(:creator, post: [:flags, :uploader, :approver])
|
||||
@post_flags = @post_flags.includes(:creator, post: [:flags, :uploader, :approver, :media_asset])
|
||||
else
|
||||
@post_flags = @post_flags.includes(:post)
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ class PostReplacementsController < ApplicationController
|
||||
def index
|
||||
params[:search][:post_id] = params.delete(:post_id) if params.key?(:post_id)
|
||||
@post_replacements = authorize PostReplacement.paginated_search(params)
|
||||
@post_replacements = @post_replacements.includes(:creator, post: :uploader) if request.format.html?
|
||||
@post_replacements = @post_replacements.includes(:creator, post: [:uploader, :media_asset]) if request.format.html?
|
||||
|
||||
respond_with(@post_replacements)
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class PostVersionsController < ApplicationController
|
||||
@post_versions = authorize PostVersion.paginated_search(params)
|
||||
|
||||
if request.format.html?
|
||||
@post_versions = @post_versions.includes(:updater, post: [:uploader, :versions])
|
||||
@post_versions = @post_versions.includes(:updater, post: [:uploader, :media_asset, :versions])
|
||||
else
|
||||
@post_versions = @post_versions.includes(post: :versions)
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class PostVotesController < ApplicationController
|
||||
|
||||
def index
|
||||
@post_votes = authorize PostVote.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
||||
@post_votes = @post_votes.includes(:user, post: :uploader) if request.format.html?
|
||||
@post_votes = @post_votes.includes(:user, post: [:uploader, :media_asset]) if request.format.html?
|
||||
|
||||
respond_with(@post_votes)
|
||||
end
|
||||
|
||||
@@ -26,9 +26,11 @@ class PostsController < ApplicationController
|
||||
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?
|
||||
@sibling_posts = @post.parent.present? ? @post.parent.children : Post.none
|
||||
@sibling_posts = @sibling_posts.undeleted unless include_deleted
|
||||
@sibling_posts = @sibling_posts.includes(:media_asset)
|
||||
|
||||
@child_posts = @post.children
|
||||
@child_posts = @child_posts.undeleted unless include_deleted
|
||||
@sibling_posts = @sibling_posts.includes(:media_asset)
|
||||
end
|
||||
|
||||
respond_with(@post) do |format|
|
||||
|
||||
@@ -26,7 +26,7 @@ class UploadsController < ApplicationController
|
||||
|
||||
def index
|
||||
@uploads = authorize Upload.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
||||
@uploads = @uploads.includes(:uploader, post: :uploader) if request.format.html?
|
||||
@uploads = @uploads.includes(:uploader, post: [:media_asset, :uploader]) if request.format.html?
|
||||
|
||||
respond_with(@uploads)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user