Sha256: 51a6f0ff241fd94777b7c50689f3a1a03992d8ce2c3ee38a4730ad7bce0102d6

Contents?: true

Size: 1016 Bytes

Versions: 9

Compression:

Stored size: 1016 Bytes

Contents

module Locomotive
  module ActionController
    module UrlHelpers

      extend ActiveSupport::Concern

      included do
        helper_method :current_site_public_url, :switch_to_site_url, :public_page_url
      end

      def current_site_public_url
        request.protocol + request.host_with_port
      end

      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

      def public_page_url(page, options = {})
        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

    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc10 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc9 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc8 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc7 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc6 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc5 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc4 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc2 lib/locomotive/action_controller/url_helpers.rb
locomotive_cms-2.0.0.rc1 lib/locomotive/action_controller/url_helpers.rb