Class: Page

Instance Attribute Summary

Attributes included from PagesCore::Taggable

#new_tags

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

#search_document_attributes

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_names, #tag_with, #tag_with!

Methods included from PagesCore::SearchableDocument

#search_document_attributes, #update_search_documents!

Methods included from PagesCore::HumanizableParam

#humanized_param

Class Method Details

.archive_finderObject



51
52
53
# File 'app/models/page.rb', line 51

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

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

Find all published and feed enabled pages



56
57
58
59
# File 'app/models/page.rb', line 56

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)


62
63
64
# File 'app/models/page.rb', line 62

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

#excerpt_or_bodyObject



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

def excerpt_or_body
  excerpt? ? excerpt : body
end

#extended?Boolean

Returns:

  • (Boolean)


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

def extended?
  excerpt? && body?
end

#headline_or_nameObject



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

def headline_or_name
  headline? ? headline : name
end

#move(parent:, position:) ⇒ Object



79
80
81
82
83
84
# File 'app/models/page.rb', line 79

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



87
88
89
90
91
92
93
# File 'app/models/page.rb', line 87

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

#to_paramObject



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

def to_param
  humanized_param(transliterated_name)
end