Module: GlobalPath
- Extended by:
- GlobalPath
- Included in:
- ApplicationController, ApplicationHelper, Badge, GlobalPath, Group, SiteIconManager, SiteSetting, Stylesheet::Importer, Theme, UserNotificationsHelper
- Defined in:
- lib/global_path.rb
Instance Method Summary collapse
- #cdn_path(p) ⇒ Object
- #cdn_relative_path(path) ⇒ Object
- #full_cdn_url(url) ⇒ Object
- #path(p) ⇒ Object
- #upload_cdn_path(p) ⇒ Object
Instance Method Details
#cdn_path(p) ⇒ Object
8 9 10 |
# File 'lib/global_path.rb', line 8 def cdn_path(p) GlobalSetting.cdn_url.blank? ? p : "#{GlobalSetting.cdn_url}#{path(p)}" end |
#cdn_relative_path(path) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/global_path.rb', line 18 def cdn_relative_path(path) if (cdn_url = GlobalSetting.cdn_url).present? URI.parse(cdn_url).path + path else path end end |
#full_cdn_url(url) ⇒ Object
26 27 28 29 30 |
# File 'lib/global_path.rb', line 26 def full_cdn_url(url) uri = URI.parse(UrlHelper.absolute(upload_cdn_path(url))) uri.scheme = SiteSetting.scheme if uri.scheme.blank? uri.to_s end |
#path(p) ⇒ Object
4 5 6 |
# File 'lib/global_path.rb', line 4 def path(p) "#{GlobalSetting.relative_url_root}#{p}" end |
#upload_cdn_path(p) ⇒ Object
12 13 14 15 16 |
# File 'lib/global_path.rb', line 12 def upload_cdn_path(p) p = Discourse.store.cdn_url(p) if SiteSetting.Upload.s3_cdn_url.present? (p =~ /\Ahttp/ || p =~ %r{\A//}) ? p : cdn_path(p) end |