Class: Locomotive::Page

Constant Summary collapse

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 is_layout)

Constants included from Concerns::Page::Layout

Concerns::Page::Layout::BLOCK_REGEX, Concerns::Page::Layout::EXTENDS_FULLPATH_REGEX, Concerns::Page::Layout::EXTENDS_PARENT_REGEX, Concerns::Page::Layout::EXTENDS_REGEX, Concerns::Page::Layout::IS_LAYOUT_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Page::ToSteam

#to_steam

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::Layout

#find_layout, #is_layout_or_related?, #use_layout?

Methods included from Concerns::Page::EditableElements

#find_editable_element

Methods included from Concerns::Page::Tree

#children_with_minimal_attributes, #depth, #sort_children!

Instance Attribute Details

#skip_callbacks_on_updateObject

Returns the value of attribute skip_callbacks_on_update.



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

def skip_callbacks_on_update
  @skip_callbacks_on_update
end

Instance Method Details

#default_response_type?Boolean

Returns:



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

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

#hidden?Boolean

Returns:



100
101
102
# File 'app/models/locomotive/page.rb', line 100

def hidden?
  (self.display_settings || {})['hidden'] || false
end

#index?Boolean

methods ##

Returns:



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

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

#index_or_not_found?Boolean

Returns:



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

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:



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

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

#titleObject

validations ##



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

field :title,               localize: true

#touch_site_attributeObject



110
111
112
# File 'app/models/locomotive/page.rb', line 110

def touch_site_attribute
  self.raw_template_changed? ? :template_version : :content_version
end

#translated?Boolean

Returns:



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

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

#translated_inObject



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

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

#unpublished?Boolean

Returns:



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

def unpublished?
  !self.published?
end

#update_without_validation_and_callback!Object



104
105
106
107
108
# File 'app/models/locomotive/page.rb', line 104

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