Module: Skyline::Rendering::Helpers::BreadCrumbHelper
- Included in:
- Renderer::Helpers
- Defined in:
- lib/skyline/rendering/helpers/bread_crumb_helper.rb
Instance Method Summary collapse
-
#bread_crumb(bc, options = {}) ⇒ Array<Array>
Helper to easily create breadcrumbs that are cut off in the middle.
Instance Method Details
#bread_crumb(bc, options = {}) ⇒ Array<Array>
Helper to easily create breadcrumbs that are cut off in the middle.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/skyline/rendering/helpers/bread_crumb_helper.rb', line 12 def bread_crumb(bc,={}) if bc.kind_of? Skyline::ArticleVersion page = bc bc = bc.page.nesting.map{|p| [p.published_publication_data.andand.,p.url]} bc[-1][0] = page.data. end if [:max_length] && bc.size > 1 # always display the last page b = [bc.pop] length = b[-1][0].size # then try to 'add' the first page if it fits first = nil if length + bc[0][0].to_s.size <= [:max_length] first = bc.shift length += first[0].to_s.size end # try to add pages in between starting from the 2nd to last page and going back as long as it fits bc.reverse.each do |p| if length + p[0].to_s.size <= [:max_length] b.unshift(p) length += p[0].to_s.size else b.unshift(nil) break end end b.unshift(first) if first b else bc end end |