replacements: link to old and new media assets.
On the /post_events and /post_replacements pages, include links to the old and new media assets pages so you can compare the two images.
This commit is contained in:
@@ -9,7 +9,7 @@ class PostEventsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@post_events = authorize PostEvent.paginated_search(params, defaults: { post_id: @post&.id }, count_pages: @post.present?)
|
@post_events = authorize PostEvent.paginated_search(params, defaults: { post_id: @post&.id }, count_pages: @post.present?)
|
||||||
@post_events = @post_events.includes(:creator, :post, model: [:post]) if request.format.html?
|
@post_events = @post_events.includes(:creator, :post, model: [:post, :media_asset, :old_media_asset]) if request.format.html?
|
||||||
|
|
||||||
respond_with(@post_events)
|
respond_with(@post_events)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class PostReplacementsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
params[:search][:post_id] = params.delete(:post_id) if params.key?(:post_id)
|
params[:search][:post_id] = params.delete(:post_id) if params.key?(:post_id)
|
||||||
@post_replacements = authorize PostReplacement.paginated_search(params)
|
@post_replacements = authorize PostReplacement.paginated_search(params)
|
||||||
@post_replacements = @post_replacements.includes(:creator, post: [:uploader, :media_asset]) if request.format.html?
|
@post_replacements = @post_replacements.includes(:creator, :old_media_asset, :media_asset, post: [:uploader, :media_asset]) if request.format.html?
|
||||||
|
|
||||||
respond_with(@post_replacements)
|
respond_with(@post_replacements)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,16 +49,50 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% when "PostReplacement" %>
|
<% when "PostReplacement" %>
|
||||||
<% if model.old_file_size && model.old_file_ext && model.old_image_width && model.old_image_height && model.file_size && model.file_ext && model.image_width && model.image_height %>
|
<%= link_to post.dtext_shortlink, post %> was replaced by <%= link_to_user creator %>:
|
||||||
<%= link_to post.dtext_shortlink, post %> was replaced by <%= link_to_user creator %>
|
|
||||||
(<%= external_link_to model.original_url.presence || "none", Source::URL.site_name(model.original_url) || model.original_url %>,
|
<% if model.original_url.match?(%r{\Ahttps?://}) %>
|
||||||
<%= model.old_file_size.to_formatted_s(:human_size, precision: 4) %> .<%= model.old_file_ext %>, <%= model.old_image_width %>x<%= model.old_image_height %> ->
|
<%= external_link_to(model.original_url, external_site_icon(Source::URL.site_name(model.original_url), title: model.original_url, class: "h-4")) %>
|
||||||
<%= external_link_to model.replacement_url, Source::URL.site_name(model.replacement_url) || model.replacement_url %>,
|
<% elsif model.original_url.present? %>
|
||||||
<%= model.file_size.to_formatted_s(:human_size, precision: 4) %> .<%= model.file_ext %>, <%= model.image_width %>x<%= model.image_height %>).
|
<%= tag.span(model.original_url.truncate(30, omission: "...#{model.original_url.last(15)}"), title: model.original_url) %>,
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if model.old_media_asset.present? %>
|
||||||
|
<%= link_to model.old_media_asset do %><%#
|
||||||
|
%><%= model.old_media_asset.file_size.to_fs(:human_size, precision: 4) %>
|
||||||
|
.<%= model.old_media_asset.file_ext %>
|
||||||
|
(<%= model.old_media_asset.image_width %>x<%= model.old_media_asset.image_height %><%= ", " + duration_to_hhmmss(model.old_media_asset.duration) if model.old_media_asset.duration.present? %>)
|
||||||
|
<% end %>
|
||||||
|
<% elsif model.old_file_size && model.old_file_ext && model.old_image_width && model.old_image_height %>
|
||||||
|
<%= model.old_file_size.to_fs(:human_size, precision: 4) %>
|
||||||
|
.<%= model.old_file_ext %>
|
||||||
|
(<%= model.old_image_width %>x<%= model.old_image_height %>)
|
||||||
|
<% elsif model.old_md5.present? %>
|
||||||
|
<%= model.old_md5 %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to post.dtext_shortlink, post %> was replaced by <%= link_to_user creator %>
|
<i>unknown file</i>
|
||||||
(<%= external_link_to model.original_url.presence || "none", Source::URL.site_name(model.original_url) || model.original_url %> ->
|
<% end %>
|
||||||
<%= external_link_to model.replacement_url, Source::URL.site_name(model.replacement_url) || model.replacement_url %>).
|
→
|
||||||
|
<% if model.replacement_url.match?(%r{\Ahttps?://}) %>
|
||||||
|
<%= external_link_to(model.replacement_url, external_site_icon(Source::URL.site_name(model.replacement_url), title: model.replacement_url, class: "h-4")) %>
|
||||||
|
<% elsif model.replacement_url.present? %>
|
||||||
|
<%= tag.span(model.replacement_url.truncate(30, omission: "...#{model.replacement_url.last(15)}"), title: model.replacement_url) %>,
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if model.media_asset.present? %>
|
||||||
|
<%= link_to model.media_asset do %>
|
||||||
|
<%= model.media_asset.file_size.to_fs(:human_size, precision: 4) %>
|
||||||
|
.<%= model.media_asset.file_ext %>
|
||||||
|
(<%= model.media_asset.image_width %>x<%= model.media_asset.image_height %><%= ", " + duration_to_hhmmss(model.media_asset.duration) if model.media_asset.duration.present? %>)<%#
|
||||||
|
%><% end %>
|
||||||
|
<% elsif model.file_size && model.file_ext && model.image_width && model.image_height %>
|
||||||
|
<%= model.file_size.to_fs(:human_size, precision: 4) %>
|
||||||
|
.<%= model.file_ext %>
|
||||||
|
(<%= model.image_width %>x<%= model.image_height %>)
|
||||||
|
<% elsif model.md5.present? %>
|
||||||
|
<%= model.md5 %>
|
||||||
|
<% else %>
|
||||||
|
<i>unknown file</i>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% when "ModAction" %>
|
<% when "ModAction" %>
|
||||||
<% case model.category %>
|
<% case model.category %>
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
<% if post_replacement.old_md5.present? && post_replacement.md5.present? %>
|
<% if post_replacement.old_md5.present? && post_replacement.md5.present? %>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Original MD5</dt>
|
<dt>Original MD5</dt>
|
||||||
<dd><%= post_replacement.old_md5 %></dd>
|
<dd><%= link_to_if post_replacement.old_media_asset.present?, post_replacement.old_md5, post_replacement.old_media_asset %></dd>
|
||||||
|
|
||||||
<dt>Replacement MD5</dt>
|
<dt>Replacement MD5</dt>
|
||||||
<dd><%= post_replacement.md5 %></dd>
|
<dd><%= link_to_if post_replacement.media_asset.present?, post_replacement.md5, post_replacement.media_asset %></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -44,14 +44,12 @@
|
|||||||
<dl>
|
<dl>
|
||||||
<dt>Original Size</dt>
|
<dt>Original Size</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<%= post_replacement.old_image_width %>x<%= post_replacement.old_image_height %>
|
<%= link_to_if post_replacement.old_media_asset.present?, "#{post_replacement.old_image_width}x#{post_replacement.old_image_height} (#{post_replacement.old_file_size.to_fs(:human_size, precision: 4)}, #{post_replacement.old_file_ext})", post_replacement.old_media_asset %>
|
||||||
(<%= post_replacement.old_file_size.to_formatted_s(:human_size, precision: 4) %>, <%= post_replacement.old_file_ext %>)
|
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>Replacement Size</dt>
|
<dt>Replacement Size</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<%= post_replacement.image_width %>x<%= post_replacement.image_height %>
|
<%= link_to_if post_replacement.media_asset.present?, "#{post_replacement.image_width}x#{post_replacement.image_height} (#{post_replacement.file_size.to_fs(:human_size, precision: 4)}, #{post_replacement.file_ext})", post_replacement.media_asset %>
|
||||||
(<%= post_replacement.file_size.to_formatted_s(:human_size, precision: 4) %>, <%= post_replacement.file_ext %>)
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user