Revert "fix wonky logic figuring out host name"
This reverts commit 114fcb4734
.
This commit is contained in:
parent
114fcb4734
commit
160567e372
|
@ -1,3 +1,5 @@
|
|||
require 'cache'
|
||||
|
||||
module Discourse
|
||||
|
||||
# When they try to do something they should be logged in for
|
||||
|
@ -12,31 +14,39 @@ module Discourse
|
|||
# When something they want is not found
|
||||
class NotFound < Exception; end
|
||||
|
||||
def self.cache
|
||||
@cache ||= Cache.new
|
||||
end
|
||||
|
||||
# Get the current base URL for the current site
|
||||
def self.current_hostname
|
||||
if SiteSetting.force_hostname.present?
|
||||
SiteSetting.force_hostname
|
||||
RailsMultisite::ConnectionManagement.current_hostname
|
||||
end
|
||||
|
||||
def self.base_uri default_value=""
|
||||
if !ActionController::Base.config.relative_url_root.blank?
|
||||
return ActionController::Base.config.relative_url_root
|
||||
else
|
||||
RailsMultisite::ConnectionManagement.current_hostname
|
||||
return default_value
|
||||
end
|
||||
end
|
||||
|
||||
def self.base_url
|
||||
default_port = 80
|
||||
def self.base_url_no_prefix
|
||||
protocol = "http"
|
||||
if SiteSetting.use_ssl?
|
||||
protocol = "https"
|
||||
default_port = 443
|
||||
end
|
||||
|
||||
result = "#{protocol}://#{current_hostname}"
|
||||
if SiteSetting.port.present? && SiteSetting.port.to_i > 0 && SiteSetting.port.to_i != default_port
|
||||
result << ":#{SiteSetting.port}"
|
||||
protocol = "https" if SiteSetting.use_ssl?
|
||||
if SiteSetting.force_hostname.present?
|
||||
result = "#{protocol}://#{SiteSetting.force_hostname}"
|
||||
else
|
||||
result = "#{protocol}://#{current_hostname}"
|
||||
end
|
||||
result << ":#{SiteSetting.port}" if SiteSetting.port.present? && SiteSetting.port.to_i > 0
|
||||
result
|
||||
end
|
||||
|
||||
def self.base_url
|
||||
return base_url_no_prefix + base_uri
|
||||
end
|
||||
|
||||
def self.enable_maintenance_mode
|
||||
$redis.set maintenance_mode_key, 1
|
||||
true
|
||||
|
@ -63,6 +73,12 @@ module Discourse
|
|||
end
|
||||
end
|
||||
|
||||
# Either returns the system_username user or the first admin.
|
||||
def self.system_user
|
||||
user = User.where(username_lower: SiteSetting.system_username).first if SiteSetting.system_username.present?
|
||||
user = User.admins.order(:id).first if user.blank?
|
||||
user
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
Loading…
Reference in New Issue