Sha256: 5804f8d37f7bdc459a99071a1b28c8b8f32c714e03b666292f0a7b0a8efc397f

Contents?: true

Size: 955 Bytes

Versions: 8

Compression:

Stored size: 955 Bytes

Contents

module Pageflow
  class HomeButton
    attr_reader :revision, :site

    def initialize(revision, site)
      @revision = revision
      @site = site
    end

    def url
      revision.configuration['home_url'].presence || site_home_button_url
    end

    def enabled?
      revision.configuration['home_button_enabled'] &&
        revision.theme.has_home_button? &&
        url.present?
    end

    def url_value
      revision.configuration['home_url']
    end

    def enabled_value
      revision.configuration['home_button_enabled']
    end

    private

    def site_home_button_url
      if site.home_url.present?
        options = Pageflow.config.site_url_options(site) || {}
        Pageflow::Engine.routes.url_for(options.merge(controller: 'pageflow/entries',
                                                      action: 'index',
                                                      only_path: !options[:host]))
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/models/pageflow/home_button.rb
pageflow-17.0.3 app/models/pageflow/home_button.rb
pageflow-17.0.2 app/models/pageflow/home_button.rb
pageflow-17.0.1 app/models/pageflow/home_button.rb
pageflow-17.0.0 app/models/pageflow/home_button.rb
pageflow-16.2.0 app/models/pageflow/home_button.rb
pageflow-16.1.0 app/models/pageflow/home_button.rb
pageflow-16.0.0 app/models/pageflow/home_button.rb