Module: Caboose::PagesHelper
- Defined in:
- app/helpers/caboose/pages_helper.rb
Instance Method Summary collapse
- #ab_testing_analytics_code ⇒ Object
- #pages_list(page) ⇒ Object
- #pages_list_helper(page) ⇒ Object
- #pages_roles_with_prefix(top_roles, prefix) ⇒ Object
- #pages_roles_with_prefix_helper(arr, role, prefix, str) ⇒ Object
Instance Method Details
#ab_testing_analytics_code ⇒ Object
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 |
#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}/edit'>#{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 |