fixes #34: add scraper to replace box

This commit is contained in:
byte[] 2020-05-01 23:02:20 -04:00
parent 1f5f5ce104
commit 56ad635154
2 changed files with 11 additions and 1 deletions

View file

@ -7,6 +7,7 @@ defmodule PhilomenaWeb.Image.FileController do
plug PhilomenaWeb.CanaryMapPlug, update: :hide plug PhilomenaWeb.CanaryMapPlug, update: :hide
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
plug :verify_not_deleted plug :verify_not_deleted
plug PhilomenaWeb.ScraperPlug, params_name: "image", params_key: "image"
def update(conn, %{"image" => image_params}) do def update(conn, %{"image" => image_params}) do
case Images.update_file(conn.assigns.image, image_params) do case Images.update_file(conn.assigns.image, image_params) do

View file

@ -71,7 +71,16 @@
= form_for @changeset, Routes.image_file_path(@conn, :update, @image), [method: "put", multipart: true], fn f -> = form_for @changeset, Routes.image_file_path(@conn, :update, @image), [method: "put", multipart: true], fn f ->
#js-image-upload-previews #js-image-upload-previews
p Upload a file from your computer p Upload a file from your computer
.field = file_input f, :image, class: "input js-scraper" .field
= file_input f, :image, class: "input js-scraper"
.field.field--inline
= url_input f, :scraper_url, class: "input input--wide js-scraper", placeholder: "Link a deviantART page, a Tumblr post, or the image directly"
button.button.button--separate-left#js-scraper-preview(type="button" title="Fetch the image at the specified URL" data-disable-with="Fetch" disabled)
' Fetch
.field-error-js.hidden.js-scraper
= submit "Save changes", class: "button", data: [disable_with: raw("Replacing…")] = submit "Save changes", class: "button", data: [disable_with: raw("Replacing…")]
.block__tab.hidden data-tab="administration" .block__tab.hidden data-tab="administration"