Class: Locomotive::Page

Constant Summary

MINIMAL_ATTRIBUTES =
%w(_id title slug fullpath position depth published templatized target_klass_name redirect listed response_type parent_id parent_ids site_id created_at updated_at raw_template)

Instance Method Summary collapse

Methods included from Concerns::Page::Templatized

#content_type, #content_type_id, #content_type_with_main_attributes, #fetch_target_entries, #fetch_target_entry, #target_entry_name, #target_klass, #target_klass_slug, #target_klass_slug=

Methods included from Concerns::Page::EditableElements

#add_or_update_editable_element, #change_element_type, #disable_all_editable_elements, #disable_parent_editable_elements, #editable_element_blocks, #editable_elements_grouped_by_blocks, #enable_editable_elements, #enabled_editable_elements, #find_editable_element, #find_editable_elements, #find_editable_files, #merge_editable_elements_from_page, #remove_disabled_editable_elements

Methods included from Concerns::Page::Tree

#children_with_minimal_attributes, #depth, #siblings_and_self_with_scoping, #sort_children!

Instance Method Details

#default_response_type?Boolean

Returns:



89
90
91
# File 'app/models/locomotive/page.rb', line 89

def default_response_type?
  self.response_type == 'text/html'
end

#index?Boolean

methods ##

Returns:



69
70
71
# File 'app/models/locomotive/page.rb', line 69

def index?
  self.slug == 'index' && self.depth.to_i == 0
end

#index_or_not_found?Boolean

Returns:



81
82
83
# File 'app/models/locomotive/page.rb', line 81

def index_or_not_found?
  self.index? || self.not_found?
end

#latest_updatedObject

named scopes ##



56
# File 'app/models/locomotive/page.rb', line 56

scope :latest_updated,      -> { order_by(updated_at: :desc).limit(Locomotive.config.ui[:latest_entries_nb]) }

#not_found?Boolean

Returns:



73
74
75
# File 'app/models/locomotive/page.rb', line 73

def not_found?
  self.slug == '404' && self.depth.to_i == 0
end

#siteObject

validations ##



32
# File 'app/models/locomotive/page.rb', line 32

belongs_to :site, class_name: 'Locomotive::Site', validate: false, autosave: false

#titleObject

behaviours ##



21
# File 'app/models/locomotive/page.rb', line 21

field :title,               localize: true

#translated?Boolean

Returns:



93
94
95
# File 'app/models/locomotive/page.rb', line 93

def translated?
  self.title_translations.key?(::Mongoid::Fields::I18n.locale.to_s) rescue false
end

#translated_inObject



97
98
99
# File 'app/models/locomotive/page.rb', line 97

def translated_in
  self.title_translations.try(:keys)
end

#unpublished?Boolean

Returns:



77
78
79
# File 'app/models/locomotive/page.rb', line 77

def unpublished?
  !self.published?
end

#update_without_validation_and_callback!Object



101
102
103
104
105
# File 'app/models/locomotive/page.rb', line 101

def update_without_validation_and_callback!
  self.updating_descendants = true
  self.save(validate: false)
  self.updating_descendants = false
end

#with_cache?Boolean

Returns:



85
86
87
# File 'app/models/locomotive/page.rb', line 85

def with_cache?
  self.cache_strategy != 'none'
end