Module: Locomotive::ActionController::UrlHelpers
- Extended by:
- ActiveSupport::Concern
- Included in:
- BaseController, Public::BaseController
- Defined in:
- lib/locomotive/action_controller/url_helpers.rb
Instance Method Summary collapse
- #current_site_public_url ⇒ Object
- #public_page_url(page, options = {}) ⇒ Object
- #switch_to_site_url(site, options = {}) ⇒ Object
Instance Method Details
#current_site_public_url ⇒ Object
11 12 13 14 |
# File 'lib/locomotive/action_controller/url_helpers.rb', line 11 def current_site_public_url # by convention, a public site is displayed in http not https. 'http://' + request.host_with_port end |
#public_page_url(page, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/locomotive/action_controller/url_helpers.rb', line 27 def public_page_url(page, = {}) # Rails.logger.debug "[public_page_url] =====> #{page.attributes.inspect} / #{page.fullpath.inspect} / #{current_site_public_url}\n\n" locale = [:locale] fullpath = current_site.localized_page_fullpath(page, locale) if content = .delete(:content) fullpath = File.join(fullpath.gsub('content_type_template', ''), content._slug) end File.join(current_site_public_url, fullpath) end |
#switch_to_site_url(site, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/locomotive/action_controller/url_helpers.rb', line 16 def switch_to_site_url(site, = {}) = { fullpath: true, protocol: true }.merge() url = "#{site.subdomain}.#{Locomotive.config.domain}" url += ":#{request.port}" if request.port != 80 url = File.join(url, request.fullpath) if [:fullpath] url = "http://#{url}" if [:protocol] url end |