Class: Page

Instance Attribute Summary

Attributes included from PagesCore::Sweepable

#cache_swept

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PagesCore::PageModel::Templateable

#default_subtemplate, #template, #template_config

Methods included from PagesCore::PageModel::Status

#deleted?, #draft?, #flag_as_deleted!, #hidden?, #published?, #reviewed?, #status_label

Methods included from PagesCore::PageModel::Sortable

#content_order, #reorderable?, #reorderable_children?

Methods included from PagesCore::PageModel::Redirectable

#redirect_path, #redirects?

Methods included from PagesCore::PageModel::Pathable

#ensure_path_segment, #full_path, #full_path?, #pathable?

Methods included from PagesCore::PageModel::Localizable

#transliterated_name

Methods included from PagesCore::PageModel::Images

#image, #image?, #images, #page_images

Methods included from PagesCore::PageModel::DatedPage

#next_sibling_by_date, #previous_sibling_by_date, #upcoming?

Methods included from PagesCore::PageModel::Attachments

#attachments, #attachments?, #files, #page_files

Methods included from PagesCore::Taggable

#serialized_tags, #serialized_tags=, #tag_list, #tag_list=, #tag_with

Methods included from PagesCore::HumanizableParam

#humanized_param

Class Method Details

.archive_finderObject



48
49
50
# File 'app/models/page.rb', line 48

def archive_finder
  PagesCore::ArchiveFinder.new(all, timestamp: :published_at)
end

.enabled_feeds(locale, options = {}) ⇒ Object

Find all published and feed enabled pages



53
54
55
56
# File 'app/models/page.rb', line 53

def enabled_feeds(locale, options = {})
  conditions = options[:include_hidden] ? "status IN (2,3)" : "status = 2"
  Page.where(feed_enabled: true).where(conditions).localized(locale)
end

Instance Method Details

#empty?Boolean Also known as: blank?

Returns:

  • (Boolean)


59
60
61
# File 'app/models/page.rb', line 59

def empty?
  !body? && !excerpt?
end

#excerpt_or_bodyObject



64
65
66
# File 'app/models/page.rb', line 64

def excerpt_or_body
  excerpt? ? excerpt : body
end

#extended?Boolean

Returns:

  • (Boolean)


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

def extended?
  excerpt? && body?
end

#headline_or_nameObject



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

def headline_or_name
  headline? ? headline : name
end

#move(parent:, position:) ⇒ Object



76
77
78
79
80
81
# File 'app/models/page.rb', line 76

def move(parent:, position:)
  Page.transaction do
    update(parent: parent) unless self.parent == parent
    insert_at(position)
  end
end

#published_atObject

Get publication date, which defaults to the creation date



84
85
86
87
88
89
90
# File 'app/models/page.rb', line 84

def published_at
  self[:published_at] ||= if created_at?
                            created_at
                          else
                            Time.now.utc
                          end
end

#to_paramObject



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

def to_param
  humanized_param(transliterated_name)
end