2015-03-09 14:24:16 -05:00
|
|
|
module GlobalPath
|
|
|
|
def path(p)
|
|
|
|
"#{GlobalSetting.relative_url_root}#{p}"
|
|
|
|
end
|
2015-05-26 00:41:50 -05:00
|
|
|
|
|
|
|
def cdn_path(p)
|
|
|
|
"#{GlobalSetting.cdn_url}#{path(p)}"
|
|
|
|
end
|
2016-02-04 20:05:47 -06:00
|
|
|
|
2017-05-08 10:38:48 -05:00
|
|
|
def upload_cdn_path(p)
|
2017-10-06 00:20:01 -05:00
|
|
|
if SiteSetting.Upload.s3_cdn_url.present?
|
|
|
|
p = p.sub(Discourse.store.absolute_base_url, SiteSetting.Upload.s3_cdn_url)
|
2017-05-08 10:38:48 -05:00
|
|
|
end
|
|
|
|
p =~ /^http/ ? p : cdn_path(p)
|
|
|
|
end
|
|
|
|
|
2016-02-04 20:05:47 -06:00
|
|
|
def cdn_relative_path(path)
|
|
|
|
if (cdn_url = GlobalSetting.cdn_url).present?
|
|
|
|
URI.parse(cdn_url).path + path
|
|
|
|
else
|
|
|
|
path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-03-09 14:24:16 -05:00
|
|
|
end
|