Class: Panda::CMS::Page
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Panda::CMS::Page
- Defined in:
- app/models/panda/cms/page.rb
Instance Method Summary collapse
-
#effective_canonical_url ⇒ String
Returns the effective canonical URL for this page Falls back to the page’s own URL if not explicitly set.
-
#effective_og_description ⇒ String?
Returns the effective Open Graph description Falls back to SEO description.
-
#effective_og_title ⇒ String
Returns the effective Open Graph title Falls back to SEO title, then page title.
-
#effective_seo_description ⇒ String?
Returns the effective SEO description for this page With optional inheritance from parent pages.
-
#effective_seo_title ⇒ String
Returns the effective SEO title for this page Falls back to page title if not set, with optional inheritance.
-
#last_updated_at ⇒ Time
Returns the most recent update time between the page and its block contents Uses cached value for performance.
-
#refresh_last_updated_at! ⇒ Time
Refresh the cached last updated timestamp Used when block contents are updated.
-
#robots_meta_content ⇒ String
Generates the robots meta tag content based on seo_index_mode.
-
#update_auto_menus ⇒ Object
Update any menus which include this page or its parent as a menu item.
Instance Method Details
#effective_canonical_url ⇒ String
Returns the effective canonical URL for this page Falls back to the page’s own URL if not explicitly set
177 178 179 |
# File 'app/models/panda/cms/page.rb', line 177 def effective_canonical_url canonical_url.presence || path end |
#effective_og_description ⇒ String?
Returns the effective Open Graph description Falls back to SEO description
166 167 168 |
# File 'app/models/panda/cms/page.rb', line 166 def effective_og_description og_description.presence || effective_seo_description end |
#effective_og_title ⇒ String
Returns the effective Open Graph title Falls back to SEO title, then page title
155 156 157 |
# File 'app/models/panda/cms/page.rb', line 155 def effective_og_title og_title.presence || effective_seo_title end |
#effective_seo_description ⇒ String?
Returns the effective SEO description for this page With optional inheritance from parent pages
141 142 143 144 145 146 |
# File 'app/models/panda/cms/page.rb', line 141 def effective_seo_description return seo_description if seo_description.present? return nil unless inherit_seo self_and_ancestors.reverse.find { |p| p.seo_description.present? }&.seo_description end |
#effective_seo_title ⇒ String
Returns the effective SEO title for this page Falls back to page title if not set, with optional inheritance
126 127 128 129 130 131 132 |
# File 'app/models/panda/cms/page.rb', line 126 def effective_seo_title return seo_title if seo_title.present? return title unless inherit_seo # Traverse up tree to find inherited value self_and_ancestors.reverse.find { |p| p.seo_title.present? }&.seo_title || title end |
#last_updated_at ⇒ Time
Returns the most recent update time between the page and its block contents Uses cached value for performance
101 102 103 |
# File 'app/models/panda/cms/page.rb', line 101 def last_updated_at cached_last_updated_at || updated_at end |
#refresh_last_updated_at! ⇒ Time
Refresh the cached last updated timestamp Used when block contents are updated
112 113 114 115 116 117 |
# File 'app/models/panda/cms/page.rb', line 112 def refresh_last_updated_at! block_content_updated_at = block_contents.maximum(:updated_at) = [updated_at, block_content_updated_at].compact.max update_column(:cached_last_updated_at, ) end |
#robots_meta_content ⇒ String
Generates the robots meta tag content based on seo_index_mode
187 188 189 190 191 192 193 194 195 196 |
# File 'app/models/panda/cms/page.rb', line 187 def case seo_index_mode when "visible" "index, follow" when "invisible" "noindex, nofollow" else "index, follow" # Default fallback end end |
#update_auto_menus ⇒ Object
Update any menus which include this page or its parent as a menu item
89 90 91 92 |
# File 'app/models/panda/cms/page.rb', line 89 def .find_each(&:generate_auto_menu_items) .find_each(&:generate_auto_menu_items) end |