From 58f0ec3dec24ce5f6b50066af8dc5e0a3651db2f Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 1 Oct 2014 17:43:22 -0500 Subject: [PATCH] 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. --- app/controllers/uploads_controller.rb | 5 +++-- app/views/uploads/new.html.erb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 5d5507384..05b58dabd 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -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 diff --git a/app/views/uploads/new.html.erb b/app/views/uploads/new.html.erb index 424b68e90..d325ad52f 100644 --- a/app/views/uploads/new.html.erb +++ b/app/views/uploads/new.html.erb @@ -36,7 +36,7 @@
<%= 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 %>