Module: Caboose::PagesHelper

Defined in:
app/helpers/caboose/pages_helper.rb

Instance Method Summary collapse

Instance Method Details

#ab_testing_analytics_codeObject



23
24
25
# File 'app/helpers/caboose/pages_helper.rb', line 23

def ab_testing_analytics_code
  return "var _gaq = _gaq || [];\n_gaq.push(['_setCustomVar', 1, 'caboose_ab_variants', #{Caboose.json(AbTesting.analytics_string)}]);"            
end


42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/caboose/pages_helper.rb', line 42

def nav_link(p, css_class = nil, style = nil) 
  str = "<a "
  str << "class='#{css_class}' " if css_class
  str << "style='#{style}' " if style
  if p.redirect_url && p.redirect_url.strip.length > 0
    str << "href='#{p.redirect_url}' target='_blank'"
  else
    str << "href='/#{p.uri}'"
  end
  str << ">#{p.title}</a>"
  return str
end

#pages_list(page) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/caboose/pages_helper.rb', line 3

def pages_list(page)
  str = "<ul>"
  str << pages_list_helper(page)      
  str << "</ul>"
  return str
end

#pages_list_helper(page) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/caboose/pages_helper.rb', line 10

def pages_list_helper(page)
  str = "<li><a href='/admin/pages/#{page.id}/content'>#{page.title}</a>"
  if page.children && page.children.count > 0
    str << "<ul>"
    page.children.each do |p|
      str << pages_list_helper(p)
    end
    str << "</ul>"
  end
  str << "</li>"
  return str
end

#pages_roles_with_prefix(top_roles, prefix) ⇒ Object



27
28
29
30
31
32
# File 'app/helpers/caboose/pages_helper.rb', line 27

def pages_roles_with_prefix(top_roles, prefix)
  arr = []
  top_roles.each do |r|        
    arr = pages_roles_with_prefix_helper(arr, r, prefix, "")
  end
end

#pages_roles_with_prefix_helper(arr, role, prefix, str) ⇒ Object



34
35
36
37
38
39
40
# File 'app/helpers/caboose/pages_helper.rb', line 34

def pages_roles_with_prefix_helper(arr, role, prefix, str)      
  arr << "#{str}#{role.name}"
  role.children.each do |r|
    arr = pages_roles_with_prefix_helper(arr, r, prefix, "#{prefix}#{str}")
  end
  return arr
end