2015-03-10 03:24:16 +08:00
|
|
|
module GlobalPath
|
|
|
|
def path(p)
|
|
|
|
"#{GlobalSetting.relative_url_root}#{p}"
|
|
|
|
end
|
2015-05-26 13:41:50 +08:00
|
|
|
|
|
|
|
def cdn_path(p)
|
2018-11-23 23:11:05 +08:00
|
|
|
GlobalSetting.cdn_url.blank? ? p : "#{GlobalSetting.cdn_url}#{path(p)}"
|
2015-05-26 13:41:50 +08:00
|
|
|
end
|
2016-02-05 10:05:47 +08:00
|
|
|
|
2017-05-08 23:38:48 +08:00
|
|
|
def upload_cdn_path(p)
|
2017-10-06 13:20:01 +08:00
|
|
|
if SiteSetting.Upload.s3_cdn_url.present?
|
2018-10-24 12:14:01 +08:00
|
|
|
p = Discourse.store.cdn_url(p)
|
2017-05-08 23:38:48 +08:00
|
|
|
end
|
|
|
|
p =~ /^http/ ? p : cdn_path(p)
|
|
|
|
end
|
|
|
|
|
2016-02-05 10:05:47 +08: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-10 03:24:16 +08:00
|
|
|
end
|