Module: EffectivePages

Includes:
EffectiveGem
Defined in:
lib/effective_pages.rb,
lib/effective_pages/engine.rb,
lib/effective_pages/version.rb,
lib/generators/effective_pages/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Engine

Constant Summary collapse

VERSION =
'3.10.1'.freeze

Class Method Summary collapse

Class Method Details

.banners?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/effective_pages.rb', line 58

def self.banners?
  !!banners
end

.carousels?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/effective_pages.rb', line 62

def self.carousels?
  carousels.kind_of?(Array) && carousels.present?
end

.config_keysObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/effective_pages.rb', line 8

def self.config_keys
  [
    :pages_table_name, :page_sections_table_name, :page_banners_table_name, :carousel_items_table_name, :alerts_table_name, :permalinks_table_name, :tags_table_name, :taggings_table_name,
    :pages_path, :excluded_pages, :layouts_path, :excluded_layouts,
    :site_og_image, :site_og_image_width, :site_og_image_height,
    :site_title, :site_title_suffix, :fallback_meta_description, :google_analytics_code,
    :silence_missing_page_title_warnings, :silence_missing_meta_description_warnings, :silence_missing_canonical_url_warnings,
    :use_effective_roles, :layout, :max_menu_depth, :banners_hint_text, :carousels_hint_text, :banners_force_randomize,

    # Booleans
    :banners,

    # Hashes
    :menus, :carousels
  ]
end

.layoutsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/effective_pages.rb', line 38

def self.layouts
  return [] if layouts_path.blank?

  view_paths = defined?(Tenant) ? Tenant.view_paths : ApplicationController.view_paths

  view_paths.map { |path| Dir[File.join(path, layouts_path, '**')] }.flatten.map do |file|
    name = File.basename(file).split('.').first
    next if name.starts_with?('_')
    next if name.include?('mailer')
    next if Array(EffectivePages.excluded_layouts).map { |str| str.to_s }.include?(name)
    name
  end.compact.sort
end

.max_menu_depthObject



52
53
54
55
56
# File 'lib/effective_pages.rb', line 52

def self.max_menu_depth
  depth = config[:max_menu_depth] || 2
  raise('only depths 2 and 3 are supported') unless [2, 3].include?(depth)
  depth
end

Returns:

  • (Boolean)


66
67
68
# File 'lib/effective_pages.rb', line 66

def self.menus?
  menus.kind_of?(Array) && menus.present?
end

.templatesObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/effective_pages.rb', line 27

def self.templates
  view_paths = defined?(Tenant) ? Tenant.view_paths : ApplicationController.view_paths

  view_paths.map { |path| Dir[File.join(path, pages_path, '**')] }.flatten.map do |file|
    name = File.basename(file).split('.').first
    next if name.starts_with?('_')
    next if Array(EffectivePages.excluded_pages).map { |str| str.to_s }.include?(name)
    name
  end.compact.sort
end