Fix #3603: Unable to view images on Hijiribe/Sonohara when Danbooru domain is blocked.
This commit is contained in:
@@ -172,6 +172,7 @@ class ApplicationController < ActionController::Base
|
||||
def reset_current_user
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
CurrentUser.root_url = root_url
|
||||
end
|
||||
|
||||
def set_started_at_session
|
||||
|
||||
@@ -48,6 +48,14 @@ class CurrentUser
|
||||
Thread.current[:current_ip_addr]
|
||||
end
|
||||
|
||||
def self.root_url
|
||||
Thread.current[:current_root_url] || "http://#{Danbooru.config.hostname}/"
|
||||
end
|
||||
|
||||
def self.root_url=(root_url)
|
||||
Thread.current[:current_root_url] = root_url
|
||||
end
|
||||
|
||||
def self.id
|
||||
if user.nil?
|
||||
nil
|
||||
|
||||
@@ -14,7 +14,7 @@ class StorageManager
|
||||
end
|
||||
|
||||
def default_base_url
|
||||
Rails.application.routes.url_helpers.root_url + "data"
|
||||
CurrentUser.root_url + "data"
|
||||
end
|
||||
|
||||
# Store the given file at the given path. If a file already exists at that
|
||||
|
||||
@@ -230,7 +230,7 @@ module Danbooru
|
||||
# base_url - where to serve files from (default: http://#{hostname}/data)
|
||||
# hierarchical: false - store files in a single directory
|
||||
# hierarchical: true - store files in a hierarchical directory structure, based on the MD5 hash
|
||||
StorageManager::Local.new(base_dir: "#{Rails.root}/public/data", hierarchical: false)
|
||||
StorageManager::Local.new(base_url: CurrentUser.root_url + "data", base_dir: "#{Rails.root}/public/data", hierarchical: false)
|
||||
|
||||
# Store files on one or more remote host(s). Configure SSH settings in
|
||||
# ~/.ssh_config or in the ssh_options param (ref: http://net-ssh.github.io/net-ssh/Net/SSH.html#method-c-start)
|
||||
|
||||
Reference in New Issue
Block a user