Files
danbooru/app/controllers/artist_commentaries_controller.rb
evazion f1b5c34b4d 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.
2021-10-25 02:56:55 -05:00

40 lines
1.2 KiB
Ruby

class ArtistCommentariesController < ApplicationController
respond_to :html, :xml, :json, :js
def index
@commentaries = authorize ArtistCommentary.paginated_search(params)
@commentaries = @commentaries.includes(post: [:uploader, :media_asset]) if request.format.html?
respond_with(@commentaries)
end
def search
end
def show
if params[:id]
@commentary = authorize ArtistCommentary.find(params[:id])
else
@commentary = authorize ArtistCommentary.find_by_post_id!(params[:post_id])
end
respond_with(@commentary) do |format|
format.html { redirect_to post_path(@commentary.post) }
end
end
def create_or_update
post_id = params[:artist_commentary].delete(:post_id)
@artist_commentary = authorize ArtistCommentary.find_or_initialize_by(post_id: post_id)
@artist_commentary.update(permitted_attributes(@artist_commentary))
respond_with(@artist_commentary)
end
def revert
@artist_commentary = authorize ArtistCommentary.find_by_post_id!(params[:id])
@version = @artist_commentary.versions.find(params[:version_id])
@artist_commentary.revert_to!(@version)
respond_with(@artist_commentary)
end
end