Class: Page
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Page
- Includes:
- PagesCore::HumanizableParam, PagesCore::PageModel::Attachments, PagesCore::PageModel::Autopublishable, PagesCore::PageModel::DatedPage, PagesCore::PageModel::Images, PagesCore::PageModel::Localizable, PagesCore::PageModel::Pathable, PagesCore::PageModel::Redirectable, PagesCore::PageModel::Searchable, PagesCore::PageModel::Sortable, PagesCore::PageModel::Status, PagesCore::PageModel::Templateable, PagesCore::PageModel::Tree, PagesCore::SearchableDocument, PagesCore::Sweepable, PagesCore::Taggable
- Defined in:
- app/models/page.rb
Instance Attribute Summary
Attributes included from PagesCore::Taggable
Attributes included from PagesCore::Sweepable
Class Method Summary collapse
- .archive_finder ⇒ Object
-
.enabled_feeds(locale, options = {}) ⇒ Object
Find all published and feed enabled pages.
Instance Method Summary collapse
- #empty? ⇒ Boolean (also: #blank?)
- #excerpt_or_body ⇒ Object
- #extended? ⇒ Boolean
- #headline_or_name ⇒ Object
- #move(parent:, position:) ⇒ Object
-
#published_at ⇒ Object
Get publication date, which defaults to the creation date.
- #to_param ⇒ Object
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
Methods included from PagesCore::PageModel::Redirectable
Methods included from PagesCore::PageModel::Pathable
#ensure_path_segment, #full_path, #full_path?, #pathable?
Methods included from PagesCore::PageModel::Localizable
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
Class Method Details
.archive_finder ⇒ Object
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, = {}) conditions = [: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?
62 63 64 |
# File 'app/models/page.rb', line 62 def empty? !body? && !excerpt? end |
#excerpt_or_body ⇒ Object
67 68 69 |
# File 'app/models/page.rb', line 67 def excerpt_or_body excerpt? ? excerpt : body end |
#extended? ⇒ Boolean
71 72 73 |
# File 'app/models/page.rb', line 71 def extended? excerpt? && body? end |
#headline_or_name ⇒ Object
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_at ⇒ Object
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_param ⇒ Object
95 96 97 |
# File 'app/models/page.rb', line 95 def to_param humanized_param(transliterated_name) end |