uploads: fix batch upload page to work without bookmarklet.

* Add a form to the /uploads/batch page so that it can be used without
  the bookmarklet.

* Fix an exception when no url is given.
This commit is contained in:
evazion
2018-04-20 15:42:42 -05:00
parent 83b96b4f3f
commit 8083c7daae
4 changed files with 52 additions and 21 deletions

View File

@@ -2,27 +2,34 @@
<div id="a-batch">
<h1>Batch Upload</h1>
<section>
<% @urls.each.with_index do |url, i| %>
<div class="upload-preview">
<p class="caption-top">
<%= link_to "Image ##{i}", new_upload_path(url: url, ref: params[:url]), target: "_blank" %>
</p>
<%= 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? %>
<section>
<% @source.image_urls.each.with_index do |url, i| %>
<div class="upload-preview">
<p class="caption-top">
<%= link_to "Image ##{i}", new_upload_path(url: url, ref: @url), target: "_blank" %>
</p>
<%= 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 %>
</div>
<% end %>
</section>
</div>
<% end %>
<p><%= link_to "Open all links in new windows", "#", :id => "link" %></p>
<p><%= link_to "Open all links in new windows", "#", :id => "link" %></p>
</section>
<% end %>
</div>
</div>