Sha256: e8e515e7109dd88e33ee2836d2661a290f2f3c4a59470cecb2141511ab847a46

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

module Locomotive
  class PagePresenter < BasePresenter

    delegate :title, :slug, :fullpath, :handle, :raw_template, :published, :listed, :templatized, :templatized_from_parent, :redirect, :redirect_url, :template_changed, :cache_strategy, :response_type, :to => :source

    def escaped_raw_template
      h(self.source.raw_template)
    end

    def editable_elements
      self.source.enabled_editable_elements.collect(&:as_json)
    end

    def included_methods
      super + %w(title slug fullpath handle raw_template published listed templatized templatized_from_parent redirect redirect_url cache_strategy response_type template_changed editable_elements localized_fullpaths)
    end

    def localized_fullpaths
      site = self.source.site

      {}.tap do |hash|
        site.locales.each do |locale|
          hash[locale] = site.localized_page_fullpath(self.source, locale)
        end
      end
    end

    def as_json_for_html_view
      methods = included_methods.clone - %w(raw_template)
      self.as_json(methods)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc11 app/presenters/locomotive/page_presenter.rb
locomotive_cms-2.0.0.rc10 app/presenters/locomotive/page_presenter.rb
locomotive_cms-2.0.0.rc9 app/presenters/locomotive/page_presenter.rb
locomotive_cms-2.0.0.rc8 app/presenters/locomotive/page_presenter.rb
locomotive_cms-2.0.0.rc7 app/presenters/locomotive/page_presenter.rb
locomotive_cms-2.0.0.rc6 app/presenters/locomotive/page_presenter.rb
locomotive_cms-2.0.0.rc5 app/presenters/locomotive/page_presenter.rb
locomotive_cms-2.0.0.rc4 app/presenters/locomotive/page_presenter.rb