Sha256: 22db2e331a3696fb168ca696b4c7614a68b4144818a434a1149bd10d040acf97

Contents?: true

Size: 605 Bytes

Versions: 24

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

module Maglev
  # Get the url used to build the URLs of the pages.
  # In the preview mode, we need the maglev root path.
  class GetBaseUrl
    include Injectable

    dependency :context
    dependency :fetch_site

    argument :preview_mode, default: nil

    def call
      preview_mode? ? site_preview_path : live_url
    end

    private

    def preview_mode?
      preview_mode.nil? ? context.rendering_mode == :editor : preview_mode
    end

    def site_preview_path
      context.controller.site_preview_path
    end

    def live_url
      nil
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
maglevcms-1.7.3 app/services/maglev/get_base_url.rb
maglevcms-1.7.2 app/services/maglev/get_base_url.rb
maglevcms-1.7.1 app/services/maglev/get_base_url.rb
maglevcms-1.7.0 app/services/maglev/get_base_url.rb
maglevcms-1.6.1 app/services/maglev/get_base_url.rb
maglevcms-1.6.0 app/services/maglev/get_base_url.rb
maglevcms-1.5.1 app/services/maglev/get_base_url.rb
maglevcms-1.4.0 app/services/maglev/get_base_url.rb
maglevcms-1.3.0 app/services/maglev/get_base_url.rb
maglevcms-1.2.2 app/services/maglev/get_base_url.rb
maglevcms-1.2.1 app/services/maglev/get_base_url.rb
maglevcms-1.2.0 app/services/maglev/get_base_url.rb
maglevcms-1.1.7 app/services/maglev/get_base_url.rb
maglevcms-1.1.6 app/services/maglev/get_base_url.rb
maglevcms-1.1.5 app/services/maglev/get_base_url.rb
maglevcms-1.1.4 app/services/maglev/get_base_url.rb
maglevcms-1.1.3 app/services/maglev/get_base_url.rb
maglevcms-1.1.2 app/services/maglev/get_base_url.rb
maglevcms-1.1.1 app/services/maglev/get_base_url.rb
maglevcms-1.1.0 app/services/maglev/get_base_url.rb