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

Instance Method Details

#current_site_public_urlObject



11
12
13
# File 'lib/locomotive/action_controller/url_helpers.rb', line 11

def current_site_public_url
  request.protocol + request.host_with_port
end

#public_page_url(page, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/locomotive/action_controller/url_helpers.rb', line 26

def public_page_url(page, options = {})
  # Rails.logger.debug "[public_page_url] =====> #{page.attributes.inspect} / #{page.fullpath.inspect}\n\n"
  if content = options.delete(:content)
    File.join(current_site_public_url, page.fullpath.gsub('content_type_template', ''), content._slug)
  else
    File.join(current_site_public_url, page.fullpath)
  end
end

#switch_to_site_url(site, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/locomotive/action_controller/url_helpers.rb', line 15

def switch_to_site_url(site, options = {})
  options = { :fullpath => true, :protocol => true }.merge(options)

  url = "#{site.subdomain}.#{Locomotive.config.domain}"
  url += ":#{request.port}" if request.port != 80

  url = File.join(url, request.fullpath) if options[:fullpath]
  url = "http://#{url}" if options[:protocol]
  url
end