diff --git a/lib/philomena/images/thumbnailer.ex b/lib/philomena/images/thumbnailer.ex index a58a2816..1913289e 100644 --- a/lib/philomena/images/thumbnailer.ex +++ b/lib/philomena/images/thumbnailer.ex @@ -106,6 +106,9 @@ defmodule Philomena.Images.Thumbnailer do defp image_file(%Image{image: image}), do: Path.join(image_file_root(), image) + defp image_thumb_dir(%Image{created_at: created_at, id: id, hidden_from_users: true, hidden_image_key: key}), + do: Path.join([image_thumbnail_root(), time_identifier(created_at), "#{id}-#{key}"]) + defp image_thumb_dir(%Image{created_at: created_at, id: id}), do: Path.join([image_thumbnail_root(), time_identifier(created_at), to_string(id)]) diff --git a/lib/philomena_web/controllers/image/repair_controller.ex b/lib/philomena_web/controllers/image/repair_controller.ex index 3dc43888..9073a765 100644 --- a/lib/philomena_web/controllers/image/repair_controller.ex +++ b/lib/philomena_web/controllers/image/repair_controller.ex @@ -6,7 +6,6 @@ defmodule PhilomenaWeb.Image.RepairController do plug PhilomenaWeb.CanaryMapPlug, create: :hide plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true - plug :verify_not_deleted def create(conn, _params) do spawn(fn -> @@ -17,16 +16,4 @@ defmodule PhilomenaWeb.Image.RepairController do |> put_flash(:info, "Repair job started.") |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) end - - defp verify_not_deleted(conn, _opts) do - case conn.assigns.image.hidden_from_users do - true -> - conn - |> put_flash(:error, "Cannot repair a hidden image.") - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) - - _false -> - conn - end - end end diff --git a/lib/philomena_web/templates/image/_options.html.slime b/lib/philomena_web/templates/image/_options.html.slime index d12b2dd0..1b26136c 100644 --- a/lib/philomena_web/templates/image/_options.html.slime +++ b/lib/philomena_web/templates/image/_options.html.slime @@ -91,19 +91,18 @@ = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Rule violation", required: true = submit "Delete", class: "button button--state-danger button--separate-left" - - else - = button_to "Restore", Routes.image_delete_path(@conn, :delete, @image), method: "delete", class: "button button--state-success" - .flex.flex--spaced-out.flex--wrap = if not @image.hidden_from_users do = form_for @changeset, Routes.image_feature_path(@conn, :create, @image), [method: "post"], fn _f -> .field p Automatically tags 'featured image' = submit "Feature", data: [confirm: "Are you really, really sure?"], class: "button button--state-success" + - else + = button_to "Restore", Routes.image_delete_path(@conn, :delete, @image), method: "delete", class: "button button--state-success" - = form_for @changeset, Routes.image_repair_path(@conn, :create, @image), [method: "post"], fn _f -> - .field - = submit "Repair", class: "button button--state-success" + = form_for @changeset, Routes.image_repair_path(@conn, :create, @image), [method: "post"], fn _f -> + .field + = submit "Repair", class: "button button--state-success" = form_for @changeset, Routes.image_hash_path(@conn, :delete, @image), [method: "delete"], fn _f -> .field