Sha256: 632e0d20d458314c9386b15482d08a948a8a293d8eeb0ec0e1afffd2415ee1da

Contents?: true

Size: 982 Bytes

Versions: 16

Compression:

Stored size: 982 Bytes

Contents

module Pageflow
  class HomeButton
    attr_reader :revision, :theming

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

    def url
      revision.configuration['home_url'].presence || theming_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 theming_home_button_url
      if theming.home_url.present?
        options = Pageflow.config.theming_url_options(theming) || {}
        Pageflow::Engine.routes.url_for(options.merge(controller: 'pageflow/entries',
                                                      action: 'index',
                                                      only_path: !options[:host]))
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pageflow-15.8.0 app/models/pageflow/home_button.rb
pageflow-15.7.1 app/models/pageflow/home_button.rb
pageflow-15.7.0 app/models/pageflow/home_button.rb
pageflow-15.6.1 app/models/pageflow/home_button.rb
pageflow-15.6.0 app/models/pageflow/home_button.rb
pageflow-15.5.0 app/models/pageflow/home_button.rb
pageflow-15.4.0 app/models/pageflow/home_button.rb
pageflow-15.3.0 app/models/pageflow/home_button.rb
pageflow-15.2.2 app/models/pageflow/home_button.rb
pageflow-15.2.1 app/models/pageflow/home_button.rb
pageflow-15.2.0 app/models/pageflow/home_button.rb
pageflow-15.1.2 app/models/pageflow/home_button.rb
pageflow-15.1.1 app/models/pageflow/home_button.rb
pageflow-15.1.0 app/models/pageflow/home_button.rb
pageflow-15.1.0.rc0 app/models/pageflow/home_button.rb
pageflow-15.1.0.beta6 app/models/pageflow/home_button.rb