Class: Pageflow::Site

Inherits:
ApplicationRecord show all
Defined in:
app/models/pageflow/site.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Object



63
64
65
# File 'app/models/pageflow/site.rb', line 63

def self.ransackable_associations(_auth_object = nil)
  %w[account]
end

.ransackable_attributes(_auth_object = nil) ⇒ Object



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

def self.ransackable_attributes(_auth_object = nil)
  %w[name]
end

Instance Method Details

#cname_domainObject



28
29
30
# File 'app/models/pageflow/site.rb', line 28

def cname_domain
  cname.split('.').pop(2).join('.')
end

#display_nameObject



16
17
18
# File 'app/models/pageflow/site.rb', line 16

def display_name
  name.presence || I18n.t('pageflow.admin.sites.default_name')
end

#existing_and_potential_entry_templatesObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/pageflow/site.rb', line 36

def existing_and_potential_entry_templates
  entry_type_names = Pageflow.config_for().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_templateObject



32
33
34
# File 'app/models/pageflow/site.rb', line 32

def first_paged_entry_template
  entry_templates.find_or_initialize_by(entry_type_name: 'paged')
end

#hostObject



24
25
26
# File 'app/models/pageflow/site.rb', line 24

def host
  Pageflow.config.site_url_options(self)&.dig(:host)
end

#name_with_account_prefixObject



20
21
22
# File 'app/models/pageflow/site.rb', line 20

def 
  [.name, name].compact.join(' - ')
end

#theme_nameObject

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.



55
56
57
# File 'app/models/pageflow/site.rb', line 55

def theme_name
  first_paged_entry_template.theme_name
end