Module: Goldencobra::NavigationHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/goldencobra/navigation_helper.rb
Instance Method Summary collapse
- #breadcrumb(options = {}) ⇒ Object
-
#navigation_menu(menue_id, options = {}) ⇒ Object
TODO: offset implementieren TODO: refactor method to make it easier to test.
Instance Method Details
#breadcrumb(options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/goldencobra/navigation_helper.rb', line 3 def (={}) id_name = ["id"] || "breadcrumb" class_name = ["class"] || "" if @article list = "" @article.path.each do |art| link_name = link_to(art., art.public_url) list << content_tag(:li, raw(link_name)) end content_list = content_tag(:ol, raw(list)) if id_name.present? result = content_tag(:nav, raw(content_list), id: "#{id_name}", class: "#{class_name}") else result = content_tag(:nav, raw(content_list), class: "#{class_name}") end return raw(result) end end |
#navigation_menu(menue_id, options = {}) ⇒ Object
TODO: offset implementieren TODO: refactor method to make it easier to test
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/helpers/goldencobra/navigation_helper.rb', line 30 def (, ={}) return "id can't be blank" if .blank? depth = [:depth] || 9999 offset = [:offset] || 0 class_name = [:class] || "" id_name = [:id] || "" = [:submenue_of_article] || "" current_article = [:current_article] || "" if .class == String if current_article.present? && current_article.public_url.present? = Goldencobra::Menue.active.where(target: current_article.public_url(false)).select{|a| a.path.map(&:title).join("/").include?()}.first if = Goldencobra::Menue.find_by_id(.path_ids[offset]) else return "" end elsif .present? && .public_url.present? = Goldencobra::Menue.active.where(target: .public_url).select{|a| a.path.map(&:title).join("/").include?()}.first else = Goldencobra::Menue.active.find_by_pathname() end else = Goldencobra::Menue.active.find_by_id() end return "" if .blank? current_depth = .ancestry_depth # Check for Permission begin if params.present? && params[:frontend_tags].present? && params[:frontend_tags].class != String && params[:frontend_tags][:format] && params[:frontend_tags][:format] == "email" #Wenn format email, dann gibt es keinen realen webseit besucher ability = Ability.new() else current_user.present? || current_visitor.present? operator = current_user || current_visitor ability = Ability.new(operator) end rescue ability = Ability.new() end return "" unless ability.can?(:read, ) content = "" if current_article.present? = .subtree.after_depth(current_depth) .to_depth(current_depth + depth) .active.includes(:permissions).includes(:image) else = .subtree.after_depth(current_depth + offset) .to_depth(current_depth + depth) .active.includes(:permissions).includes(:image) end = .to_a.delete_if{|a| !ability.can?(:read, a)} current_depth = 1 ().each do |root| content << (root, , , current_depth) end klass = [ class_name, depth, "navigation", .css_class.to_s.gsub(/[^\w\-]/, " ") ].join(" ").squeeze(" ").strip result = content_tag( :ul, raw(content), id: id_name.present? ? id_name.to_s : nil, class: klass ) raw(result) end |