Module: RocketCMS::Models::Page

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

Instance Method Summary collapse

Methods included from Seoable

admin, #get_og_title, #page_title, seo_config

Instance Method Details

#clean_regexpObject



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rocket_cms/models/page.rb', line 55

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



24
25
26
# File 'lib/rocket_cms/models/page.rb', line 24

def get_fullpath
  redirect.blank? ? fullpath : redirect
end

#has_content?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rocket_cms/models/page.rb', line 28

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

#is_current?(url) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
53
# File 'lib/rocket_cms/models/page.rb', line 47

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


68
69
70
# File 'lib/rocket_cms/models/page.rb', line 68

def nav_options
  {highlights_on: clean_regexp}
end

#page_contentObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rocket_cms/models/page.rb', line 32

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