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 def new
@upload = Upload.new @upload = Upload.new
if params[:url] if params[:url]
@post = Post.find_by_source(params[:url])
@normalized_url = params[:url] @normalized_url = params[:url]
headers = { headers = {
"User-Agent" => "#{Danbooru.config.safe_app_name}/#{Danbooru.config.version}" "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) @normalized_url, headers = strategy.new.rewrite(@normalized_url, headers)
end end
@post = Post.find_by_source(@normalized_url)
begin begin
@source = Sources::Site.new(params[:url]) @source = Sources::Site.new(params[:url])
rescue Exception rescue Exception

View File

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