diff --git a/app/assets/stylesheets/common/simple_form.scss b/app/assets/stylesheets/common/simple_form.scss index ca697547d..4350da3c3 100644 --- a/app/assets/stylesheets/common/simple_form.scss +++ b/app/assets/stylesheets/common/simple_form.scss @@ -71,6 +71,17 @@ form.inline-form { } } +form.one-line-form { + > input, > div.input { + display: inline; + + label { + display: inline; + margin-right: 1em; + } + } +} + div.ui-dialog { div.input { input[type="text"] { diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 9821ab9f1..760715ca9 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -20,9 +20,15 @@ class UploadsController < ApplicationController end def batch - @source = Sources::Site.new(params[:url], :referer_url => params[:ref]) - @source.get - @urls = @source.image_urls + @url = params.dig(:batch, :url) || params[:url] + @source = nil + + if @url + @source = Sources::Site.new(@url, :referer_url => params[:ref]) + @source.get + end + + respond_with(@source) end def image_proxy diff --git a/app/views/uploads/batch.html.erb b/app/views/uploads/batch.html.erb index 1cd12a528..a387f17d0 100644 --- a/app/views/uploads/batch.html.erb +++ b/app/views/uploads/batch.html.erb @@ -2,27 +2,34 @@
- <%= link_to "Image ##{i}", new_upload_path(url: url, ref: params[:url]), target: "_blank" %> -
+ <%= simple_form_for(:batch, url: batch_uploads_path, method: :get, defaults: { required: false }, html: { class: "one-line-form" }) do |f| %> + <%= f.input :url, label: "URL", input_html: { size: 70, value: @url, placeholder: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65981746" } %> + <%= f.submit "Fetch" %> + <% end %> - <%= link_to new_upload_path(url: url, ref: params[:url]), target: "_blank" do %> - <% if ImageProxy.needs_proxy?(url) %> - <%= image_tag(image_proxy_uploads_path(url: url)) %> - <% elsif url.is_a?(String) %> - <%= image_tag url %> - <% else %> - Direct Link + <% if @source.present? %> ++ <%= link_to "Image ##{i}", new_upload_path(url: url, ref: @url), target: "_blank" %> +
+ + <%= link_to new_upload_path(url: url, ref: @url), target: "_blank" do %> + <% if ImageProxy.needs_proxy?(url) %> + <%= image_tag(image_proxy_uploads_path(url: url)) %> + <% elsif url.is_a?(String) %> + <%= image_tag url %> + <% else %> + Direct Link + <% end %> <% end %> - <% end %> -<%= link_to "Open all links in new windows", "#", :id => "link" %>
+<%= link_to "Open all links in new windows", "#", :id => "link" %>
+