Use the normalized source in the upload form.

This makes it so you can use the bookmarklet to upload from any of these Pixiv pages:

* http://www.pixiv.net/member_illust.php?mode=medium&illust_id=45792845
* http://www.pixiv.net/member_illust.php?mode=big&illust_id=45792845
* http://www.pixiv.net/member_illust.php?mode=manga&illust_id=45792845
* http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=45792845&page=0

and the source field in the upload form will be filled in with the
actual image URL (e.g. http://i2.pixiv.net/img18/img/ringo78/45792845_big_p0.jpg),
and it will also be used for the "This post was already uploaded" check.
This commit is contained in:
evazion
2014-10-01 17:43:22 -05:00
parent 964b5efcd3
commit 58f0ec3dec
2 changed files with 4 additions and 3 deletions

View File

@@ -7,9 +7,8 @@ class UploadsController < ApplicationController
def new
@upload = Upload.new
if params[:url]
@post = Post.find_by_source(params[:url])
@normalized_url = params[:url]
headers = {
"User-Agent" => "#{Danbooru.config.safe_app_name}/#{Danbooru.config.version}"
}
@@ -17,6 +16,8 @@ class UploadsController < ApplicationController
@normalized_url, headers = strategy.new.rewrite(@normalized_url, headers)
end
@post = Post.find_by_source(@normalized_url)
begin
@source = Sources::Site.new(params[:url])
rescue Exception

View File

@@ -36,7 +36,7 @@
<div class="input">
<%= f.label :source %>
<% if params[:url].present? %>
<%= f.text_field :source, :size => 50, :value => params[:url] %>
<%= f.text_field :source, :size => 50, :value => @normalized_url %>
<% else %>
<%= f.text_field :source, :size => 50 %>
<% end %>