2011-11-21 01:27:05 +00:00
|
|
|
module Locomotive
|
|
|
|
class PagePresenter < BasePresenter
|
|
|
|
|
2012-01-16 22:59:59 +00:00
|
|
|
delegate :title, :slug, :fullpath, :raw_template, :published, :listed, :templatized, :redirect, :redirect_url, :template_changed, :cache_strategy, :to => :source
|
2011-11-21 01:27:05 +00:00
|
|
|
|
2011-12-08 15:47:17 +00:00
|
|
|
def escaped_raw_template
|
|
|
|
h(self.source.raw_template)
|
|
|
|
end
|
|
|
|
|
2011-11-21 01:27:05 +00:00
|
|
|
def editable_elements
|
2011-11-25 01:04:42 +00:00
|
|
|
self.source.enabled_editable_elements.collect(&:as_json)
|
2011-11-21 01:27:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def included_methods
|
2012-01-26 01:33:39 +00:00
|
|
|
super + %w(title slug fullpath raw_template published listed templatized redirect redirect_url cache_strategy template_changed editable_elements edit_url 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
|
2011-11-21 01:27:05 +00:00
|
|
|
end
|
|
|
|
|
2011-12-08 15:47:17 +00:00
|
|
|
def as_json_for_html_view
|
|
|
|
methods = included_methods.clone - %w(raw_template)
|
|
|
|
self.as_json(methods)
|
|
|
|
end
|
|
|
|
|
2011-11-21 01:27:05 +00:00
|
|
|
end
|
|
|
|
end
|