Module: RocketCMS::Models::Page

Extended by:
ActiveSupport::Concern
Includes:
Enableable, ManualSlug, ElasticSearch, RocketCMS::Model, Seoable
Included in:
Page
Defined in:
lib/rocket_cms/models/page.rb

Instance Method Summary collapse

Methods included from ManualSlug

#text_slug, #text_slug=

Methods included from Seoable

admin, #get_og_title, #page_title, seo_config

Instance Method Details

#clean_regexpObject



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rocket_cms/models/page.rb', line 68

def clean_regexp
  if regexp.blank?
    /^#{Regexp.escape(fullpath)}$/
  else
    begin
      /#{regexp}/
    rescue
      # not a valid regexp - treat as literal search string
      /#{Regexp.escape(regexp)}/
    end
  end
end

#get_fullpathObject



37
38
39
# File 'lib/rocket_cms/models/page.rb', line 37

def get_fullpath
  redirect.blank? ? fullpath : redirect
end

#has_content?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/rocket_cms/models/page.rb', line 41

def has_content?
  @content_used.nil? && !content.blank?
end

#is_current?(url) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
64
65
66
# File 'lib/rocket_cms/models/page.rb', line 60

def is_current?(url)
  if fullpath == '/'
    url == '/'
  else
    url.match(clean_regexp)
  end
end


81
82
83
# File 'lib/rocket_cms/models/page.rb', line 81

def nav_options
  {highlights_on: clean_regexp}
end

#page_contentObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rocket_cms/models/page.rb', line 45

def page_content
  if @content_used.nil?
    @content_used = true
    if content.nil?
      ''
    else
      content.gsub(/\{\{(.*?)\}\}/) do
        Settings.get($1).val
      end
    end
  else
    ''
  end
end