Sha256: 87d26b5b0606d633b0a3ff3f311675062913f9eae02bf44fa51756fc5e8fdad6

Contents?: true

Size: 1.21 KB

Versions: 33

Compression:

Stored size: 1.21 KB

Contents

module BreadcrumbsHelper

  def breadcrumbs(e, extra=nil)
    breadcrumbs0(e.navigable_name, e, extra, 'last')
  end

  def home_breadcrumb
    "<li class='mu-breadcrumb-list-item brand '>#{breadcrumb_home_link}</li>".html_safe
  end

  def breadcrumb_home_link
    if Organization.current.breadcrumb_image_url.present?
      link_to image_tag(Organization.current.breadcrumb_image_url, class: "da mu-breadcrumb-img"), root_path
    else
      link_to "<i class='da da-mumuki' aria-label=#{t(:home)}></i>".html_safe, root_path
    end
  end

  def breadcrumb_item_class(last)
    "class='mu-breadcrumb-list-item #{last}'"
  end

  def breadcrumb_list_item(last, item)
    "<li #{breadcrumb_item_class(last)}>#{h item}</li>".html_safe
  end

  private

  def breadcrumbs_for_linkable(e, extra=nil, last='')
    breadcrumbs0(link_to_path_element(e), e, extra, last)
  end

  def breadcrumbs0(base, e, extra, last)
    return "#{breadcrumbs_for_linkable(e)} #{breadcrumb_list_item(last, extra)}".html_safe if extra

    if e.navigation_end?
      "#{home_breadcrumb} #{breadcrumb_list_item(last, base)}".html_safe
    else
      "#{breadcrumbs_for_linkable(e.navigable_parent)} #{breadcrumb_list_item(last, base)}".html_safe
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
mumuki-laboratory-7.0.4 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.3 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.2 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.7 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.6 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.5 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.1 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-7.0.0 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.4 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.3 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.2 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.1 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.7.0 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.6.1 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.6.0 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.5.1 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.5.0 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.4.2 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.4.1 app/helpers/breadcrumbs_helper.rb
mumuki-laboratory-6.4.0 app/helpers/breadcrumbs_helper.rb