Class: Pageflow::Site
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pageflow::Site
- Defined in:
- app/models/pageflow/site.rb
Overview
rubocop:todo Style/Documentation
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
- .ransackable_attributes(_auth_object = nil) ⇒ Object
Instance Method Summary collapse
- #build_root_permalink_directory ⇒ Object
- #cname_domain ⇒ Object
- #display_name ⇒ Object
- #display_title ⇒ Object
- #existing_and_potential_entry_templates ⇒ Object
- #first_paged_entry_template ⇒ Object
- #host ⇒ Object
- #name_with_account_prefix ⇒ Object
- #root_entry ⇒ Object
- #root_permalink_directory ⇒ Object
-
#theme_name ⇒ Object
deprecated
Deprecated.
Depending on what you need this for, consider
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
84 85 86 |
# File 'app/models/pageflow/site.rb', line 84 def self.ransackable_associations(_auth_object = nil) %w[account] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
80 81 82 |
# File 'app/models/pageflow/site.rb', line 80 def self.ransackable_attributes(_auth_object = nil) %w[name] end |
Instance Method Details
#build_root_permalink_directory ⇒ Object
39 40 41 |
# File 'app/models/pageflow/site.rb', line 39 def build_root_permalink_directory permalink_directories.build(path: '') end |
#cname_domain ⇒ Object
35 36 37 |
# File 'app/models/pageflow/site.rb', line 35 def cname_domain cname.split('.').pop(2).join('.') end |
#display_name ⇒ Object
19 20 21 |
# File 'app/models/pageflow/site.rb', line 19 def display_name name.presence || I18n.t('pageflow.admin.sites.default_name') end |
#display_title ⇒ Object
31 32 33 |
# File 'app/models/pageflow/site.rb', line 31 def display_title title.presence || cname_domain.presence end |
#existing_and_potential_entry_templates ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/models/pageflow/site.rb', line 57 def existing_and_potential_entry_templates entry_type_names = Pageflow.config_for(account).entry_types.map(&:name) allowed_existing_entry_templates = entry_templates.where(entry_type_name: entry_type_names) free_type_names = entry_type_names - allowed_existing_entry_templates.map(&:entry_type_name) potential_entry_templates = free_type_names.map do |type_name| entry_templates.build(entry_type_name: type_name) end allowed_existing_entry_templates + potential_entry_templates end |
#first_paged_entry_template ⇒ Object
53 54 55 |
# File 'app/models/pageflow/site.rb', line 53 def first_paged_entry_template entry_templates.find_or_initialize_by(entry_type_name: 'paged') end |
#host ⇒ Object
27 28 29 |
# File 'app/models/pageflow/site.rb', line 27 def host Pageflow.config.(self)&.dig(:host) end |
#name_with_account_prefix ⇒ Object
23 24 25 |
# File 'app/models/pageflow/site.rb', line 23 def name_with_account_prefix [account.name, name].compact.join(' - ') end |
#root_entry ⇒ Object
43 44 45 46 47 |
# File 'app/models/pageflow/site.rb', line 43 def root_entry return unless root_permalink_directory root_permalink_directory.permalinks.find_by_slug('')&.entry end |
#root_permalink_directory ⇒ Object
49 50 51 |
# File 'app/models/pageflow/site.rb', line 49 def root_permalink_directory permalink_directories.find_by_path('') end |
#theme_name ⇒ Object
Deprecated.
Depending on what you need this for, consider
scoping your code to an entry type or look at a specific entry’s theme name.
76 77 78 |
# File 'app/models/pageflow/site.rb', line 76 def theme_name first_paged_entry_template.theme_name end |