Sha256: c6aef8bef6b42b83b2b3d967f9d6703868fd7fa5c89fb3eedc2c68249e524ef4

Contents?: true

Size: 809 Bytes

Versions: 2

Compression:

Stored size: 809 Bytes

Contents

module Viewable
  class ViewPresenter < ViewablePresenter
    def initialize(model, context)
      super
      set_cms_view
      set_meta_tags
    end

    def add_link
      return unless h.cms_edit_mode?

      h.link_to add_path, class: "cms-add cms-add-page", 'data-no-turbolink' => true do
        h.t('cms.add_page')
      end
    end

    private

    def set_cms_view
      h.instance_variable_set :@cms_view, self
    end

    def set_meta_tags
      tags = %w[
        title
        meta_keywords
        meta_description
      ]
      tags.each do |tag|
        h.instance_variable_set("@cms_page_#{tag}", m.send(tag).presence)
      end
    end

    def add_path
      h.main_app.new_viewable_url(list_key: h.cms_list_key(m.short_type, m.unique_key_name), max: Float::INFINITY)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_admin_cms-0.0.2 app/presenters/viewable/view_presenter.rb
rails_admin_cms-0.0.1 app/presenters/viewable/view_presenter.rb