* Add a basic index page at https://danbooru.donmai.us/media_assets. * Add a basic show page at https://danbooru.donmai.us/media_assets/1. * Add ability to search /media_assets.json by metadata. Example: ** https://danbooru.donmai.us/media_assets.json?search[metadata][File:ColorComponents]=3 * Add a "»" link next to the filesize on posts linking to the metadata page. Known issues: * Sometimes the MD5 links on the /media_assets page return "That record was not found" errors. These are unfinished uploads that haven't been made into posts yet. * No good way to search for custom metadata fields in the search form. * Design is ugly.
16 lines
462 B
Ruby
16 lines
462 B
Ruby
class MediaAssetsController < ApplicationController
|
|
respond_to :html, :json, :xml
|
|
|
|
def index
|
|
@media_assets = authorize MediaAsset.visible(CurrentUser.user).paginated_search(params, count_pages: false)
|
|
@media_assets = @media_assets.joins(:media_metadata)
|
|
respond_with(@media_assets)
|
|
end
|
|
|
|
def show
|
|
@media_asset = authorize MediaAsset.find(params[:id])
|
|
@post = Post.find_by_md5(@media_asset.md5)
|
|
respond_with(@media_asset)
|
|
end
|
|
end
|