mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 10:30:01 +08:00
70bb2aa426
This refactors handling of s3 so it can be specified via GlobalSetting This means that in a multisite environment you can configure s3 uploads without actual sites knowing credentials in s3 It is a critical setting for situations where assets are mirrored to s3.
26 lines
509 B
Ruby
26 lines
509 B
Ruby
module GlobalPath
|
|
def path(p)
|
|
"#{GlobalSetting.relative_url_root}#{p}"
|
|
end
|
|
|
|
def cdn_path(p)
|
|
"#{GlobalSetting.cdn_url}#{path(p)}"
|
|
end
|
|
|
|
def upload_cdn_path(p)
|
|
if SiteSetting.Upload.s3_cdn_url.present?
|
|
p = p.sub(Discourse.store.absolute_base_url, SiteSetting.Upload.s3_cdn_url)
|
|
end
|
|
p =~ /^http/ ? p : cdn_path(p)
|
|
end
|
|
|
|
def cdn_relative_path(path)
|
|
if (cdn_url = GlobalSetting.cdn_url).present?
|
|
URI.parse(cdn_url).path + path
|
|
else
|
|
path
|
|
end
|
|
end
|
|
|
|
end
|