Module: Enjoy::Models::Page

Extended by:
ActiveSupport::Concern
Includes:
Enableable, Enjoy::Model, Seoable, SitemapDataField, ManualSlug
Included in:
Page
Defined in:
lib/enjoy/models/page.rb

Constant Summary

Constants included from SitemapDataField

SitemapDataField::FIELDS

Constants included from Seoable

Seoable::FIELDS, Seoable::LOCALIZED_FIELDS

Instance Method Summary collapse

Methods included from Seoable

#get_og_title, #og_image_jcrop_options, #page_title

Methods included from ManualSlug::ActiveRecord

#text_slug, #text_slug=

Methods included from ManualSlug::Mongoid

#text_slug, #text_slug=

Instance Method Details

#clean_regexpObject



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

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

#get_fullpathObject



33
34
35
# File 'lib/enjoy/models/page.rb', line 33

def get_fullpath
  redirect.blank? ? fullpath : redirect
end

#has_content?Boolean

Returns:

  • (Boolean)


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

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

#is_current?(url) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
62
# File 'lib/enjoy/models/page.rb', line 56

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


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

def nav_options
  {highlights_on: clean_regexp}
end

#page_contentObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/enjoy/models/page.rb', line 41

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

#page_h1Object



26
27
28
29
30
31
# File 'lib/enjoy/models/page.rb', line 26

def page_h1
  _ret = seo ? seo.h1 : nil
  _ret = name   if _ret.blank?
  _ret = title  if _ret.blank?
  _ret
end

#regexp_prefixObject



64
65
66
# File 'lib/enjoy/models/page.rb', line 64

def regexp_prefix
  ""
end