zachinglis / crummy

Tasty breadcrumbs! Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
http://zachinglis.com
MIT License
358 stars 82 forks source link

Last crumb is linked - but it should not. It's connected with 'with_microdata' #36

Closed adam-pl closed 11 years ago

adam-pl commented 11 years ago

I'm dissapointed of linking last crumb with using "with_microdata".

How to fix it: just modify "crumb_to_html" method like that:

def crumb_to_html(crumb, links, first_class, last_class, is_first, is_last, with_microdata)
  html_classes = []
  html_classes << first_class if is_first
  html_classes << last_class if is_last
  name, url = crumb
  can_link = url && links && !is_last
  html_content = can_link ? link_to(name, url) : content_tag(:span, name)
  if with_microdata
    item_title = content_tag(:span, name, :itemprop => "title")
    html_options = {:itemscope => true, :itemtype => data_definition_url("Breadcrumb")}
    html_content = can_link ? link_to(item_title, url, :class => html_classes, :itemprop => "url") : item_title
    content_tag(:div, html_content, html_options)
  else
    can_link ? link_to(name, url, :class => html_classes) : name
  end
end

Now works for me.

Btw. I prefer "Breadcrumbs On Rails" to "Crummy" because: a) it checks every crumb if it is current_page. If not then it's not linked :-) b) adding crumbs is much simplier:

add_crumber 'home', :root_path

vs

add_crumb( 'home') { |instance| instance.send :root_path }
andrew commented 11 years ago

@adam-pl can you send that change as a pull request?

adam-pl commented 11 years ago

I did it. I was my first time.