* 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.
40 lines
1.5 KiB
Plaintext
40 lines
1.5 KiB
Plaintext
<div id="c-media-assets">
|
|
<div id="a-index">
|
|
<%= search_form_for(media_assets_path) do |f| %>
|
|
<%= f.input :md5, input_html: { value: params[:search][:md5] } %>
|
|
<%= f.input :image_width, input_html: { value: params[:search][:image_width] } %>
|
|
<%= f.input :image_height, input_html: { value: params[:search][:image_height] } %>
|
|
<%= f.input :file_size, input_html: { value: params[:search][:file_size] } %>
|
|
<%= f.input :file_ext, input_html: { value: params[:search][:file_ext] } %>
|
|
|
|
<%= f.simple_fields_for :metadata do |meta| %>
|
|
<% params.dig(:search, :metadata).to_h.each do |key, value| %>
|
|
<%= meta.input key, label: key, input_html: { value: value } %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%= f.submit "Search" %>
|
|
<% end %>
|
|
|
|
<%= table_for @media_assets, class: "striped autofit" do |t| %>
|
|
<% t.column "MD5", td: { class: "font-monospace" } do |media_asset| %>
|
|
<%= link_to media_asset.md5, posts_path(md5: media_asset.md5) %>
|
|
<% end %>
|
|
<% t.column :image_width %>
|
|
<% t.column :image_height %>
|
|
<% t.column :file_size %>
|
|
<% t.column :file_ext %>
|
|
|
|
<% t.column "Metadata" do |media_asset| %>
|
|
<%= link_to pluralize(media_asset.metadata.size, "tags"), media_asset %>
|
|
<% end %>
|
|
|
|
<% t.column "Created" do |media_asset| %>
|
|
<%= time_ago_in_words_tagged(media_asset.created_at) %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<%= numbered_paginator(@media_assets) %>
|
|
</div>
|
|
</div>
|