2012-02-04 01:10:55 +00:00
|
|
|
module Locomotive
|
|
|
|
module PagesHelper
|
|
|
|
|
|
|
|
def css_for_page(page)
|
|
|
|
%w(index not_found templatized redirect).inject([]) do |memo, state|
|
|
|
|
memo << state.dasherize if page.send(:"#{state}?")
|
|
|
|
memo
|
|
|
|
end.join(' ')
|
|
|
|
end
|
2011-11-09 01:35:59 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def page_toggler(page)
|
|
|
|
image_tag("locomotive/list/icons/node_#{(cookies["folder-#{page._id}"] != 'none') ? 'open' : 'closed'}.png", :class => 'toggler')
|
|
|
|
end
|
2011-11-14 09:13:58 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def parent_pages_options
|
|
|
|
roots = current_site.pages.roots.where(:slug.ne => '404').and(:_id.ne => @page.id)
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
[].tap do |list|
|
|
|
|
roots.each do |page|
|
|
|
|
list = add_children_to_options(page, list)
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
end
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def add_children_to_options(page, list)
|
|
|
|
return list if page.parent_ids.include?(@page.id) || page == @page
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
offset = '- ' * (page.depth || 0) * 2
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
list << ["#{offset}#{page.title}", page.id]
|
|
|
|
page.children.each { |child| add_children_to_options(child, list) }
|
|
|
|
list
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2012-02-09 23:57:57 +00:00
|
|
|
def options_for_target_klass_name
|
|
|
|
base_models = current_site.content_types.map do |type|
|
|
|
|
[type.name.humanize, type.klass_with_custom_fields(:entries)]
|
|
|
|
end
|
|
|
|
base_models + Locomotive.config.models_for_templatization.map { |name| [name.underscore.humanize, name] }
|
|
|
|
end
|
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def options_for_page_cache_strategy
|
|
|
|
[
|
|
|
|
[t('.cache_strategy.none'), 'none'],
|
|
|
|
[t('.cache_strategy.simple'), 'simple'],
|
|
|
|
[t('.cache_strategy.hour'), 1.hour.to_s],
|
|
|
|
[t('.cache_strategy.day'), 1.day.to_s],
|
|
|
|
[t('.cache_strategy.week'), 1.week.to_s],
|
|
|
|
[t('.cache_strategy.month'), 1.month.to_s]
|
|
|
|
]
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
end
|
|
|
|
end
|