zachinglis / crummy Goto Github PK
View Code? Open in Web Editor NEWTasty breadcrumbs! Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
Home Page: http://zachinglis.com
License: MIT License
Tasty breadcrumbs! Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
Home Page: http://zachinglis.com
License: MIT License
The markup contains empty attribute values for :id and :class. These attributes should not be included if nil.
<ul class="breadcrumbs" id=""><li class=""><a href="/">Home</a></li></ul>
Strange problem with translation in add_crumb.
FAIL:
add_crumb(I18n.t('my_profile'), :travels_path)
`@Mi perfil' is not allowed as an instance variable name
crummy (1.3) lib/crummy/action_controller.rb:32:in `instance_variable_get'
crummy (1.3) lib/crummy/action_controller.rb:32:in `block in add_crumb'
activesupport (3.1.1) lib/active_support/callbacks.rb:448:in `_run__124730010797531319__process_action__4462420772137569113__callbacks'
but with other string with translation it hasn't problem:
add_crumb(I18n.t('other_translation_that_works_too'), :travels_path)
I do not see where in the code the caching could happen but if I use a proc for the name of the crumb, it is only call the first time I need it, displaying wrong translation if I have changed locale since the first call.
Exemple :
add_crumb(lambda { |i| i.t(:home) }, :root_path)
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead.
if i use :
add_breadcrumb "Post Categories", :client_post_categories_path
or
add_breadcrumb ("Post Categories") {|ins| ins.client_post_categories_path}
first time i refresh the page, it's ok.
then i refresh again and again,
the breadthumb looks like:
Home << Post Categories << Post Categories << Post Categories << Post Categories << Post Categories
With Crummy 1.1.0, Rails 2.3.8 and Ruby 1.8.7 i have the follow error on line
= render_crumbs :seperator => ' '
undefined method `escape_once' for #Crummy::StandardRenderer
Hello,
I stumbled upon a very strange behaviour. What I want to do is to pass some breadcrumb elements and then render them at once with render_crumb:
add_crumb "All categories", url_for(page_params)
add_crumb "Some category", url_for(page_params)
When I check the @_crumbs variable content I get:
[["Alle Kategorien", "/catalog"], ["Some category", "/c/category"], ["Page", nil]]
Then when I want to render the breadcrumb in the view, I check it again and it contains:
[["Alle Kategorien", "/catalog"], ["Some category", "/c/category"], ["Page", nil], ["Some category", "/catalog/shops/1?filter=top"], ["Bestseller-Shops", nil]]
Any clue why these last two elements get into the breadcrumb automatically?
Hi:
Using bootstrap I've come up with a breadcrumb which contains dropdown lists at the same time. So with the current implementation I'm not sure it's possible to indicate what content goes inside the <a> link, aside from plain text. It would be neat to be able to indicate a template (view) partial.
If this is not already integrated. Is this something easy to achieve?
Cheers!
I see the html_list_separator
option in the README but cannot find where and how it's supposed to be used in the code.
Is it a work in progress ?
I'm trying to make crummy work with the twitter bootstrap and the separator seems to take place after the link, in a span
.
In standard_renderer.rb, html_safe is invoked by default .
Shouldn't this be up to the user to mark which strings are html safe?
Example:
add_crumb "safe".html_safe, '/'
add_crumb not_trusted.name, 'not_safe'
For now, it is possible to manually encode text passed into add_crumb, but this seems to go against the convention of encoding by default.
On line 17 README.textile says "Then install the Formtastic gem:"
I'm assuming this is supposed to say "Then install the Crummy gem:"
Might also be useful to add installation instructions like the ones that come with Hoptoud (modified to say crummy):
"Rails 2.x
Add the crummy gem to your app. In config/environment.rb:
config.gem 'crummy_notifier'
Then from your project's RAILS_ROOT, run:
rake gems:install
Once installed, you should vendor the crummy gem.
rake gems:unpack GEM=crummy"
I'm trying to upgrade from Rails 6.0 to 6.1 and suddenly I'm getting this error that seems related to crummy, though I can't figure out what's wrong:
ActionView::Template::Error (can't modify frozen Hash):
1: <%= render_crumbs :last_crumb_linked => false, :format => :html_list, :ul_class => 'breadcrumb', :last_class => 'active' %>
app/views/layouts/_breadcrumbs.html.erb:1
app/views/articles/edit.html.erb:2
If I comment out the render_crumbs
call in my template then the error goes away.
Ideas?
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 }
<a href="/">shop</a> » <a href="http://localhost:3000/sections/5">category</a>
It would be bettter to call parameter 'separator', not 'seperator'.
I think crummy should be using <ol>
instead of <ul>
. Breadcrumbs are in a very specific order and so using an "ordered" list seems appropriate.
I can make the PR if you wish.
When setting the format to html_list, the separator string is inserted after the closing li tag. Would it be possible instead to insert the separator after the link, inside of the li? This would make the html_list format render valid HTML as well as make it more compatible with Twitter bootstrap.
Thanks!
With a class level add_crumb defined as follows:
class UsersController < ApplicationController
add_crumb("User List", :except => [:index]) { |instance| instance.send :users_path }
...
end
I get following in latest master:
NoMethodError: undefined method map!' for "/users":String vendor/bundle/ruby/1.8/gems/crummy-1.3/lib/crummy/action_controller.rb:24:in
add_crumb'
vendor/bundle/ruby/1.8/gems/activesupport-2.3.12/lib/active_support/callbacks.rb:182:in call' vendor/bundle/ruby/1.8/gems/activesupport-2.3.12/lib/active_support/callbacks.rb:182:in
evaluate_method'
vendor/bundle/ruby/1.8/gems/activesupport-2.3.12/lib/active_support/callbacks.rb:166:in call' test/functional/users_controller_test.rb:22:in
__bind_1319836051_713591'
I'm getting the error arguments passed to url_for can't be handled. Please require routes or provide your own implementation
when my view uses <%= render_crumbs %>
My controller looks like this:
class SitesController < ApplicationController
before_action :set_site, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
add_crumb 'Sites', :sites_url
# GET /sites/1
# GET /sites/1.json
def show
add_crumb @site.title, @site
end
# ...
private
def set_site
@site = Site.find(params[:id])
end
end
I figured out that if I change:
add_crumb @site.title, @site
to
add_crumb @site.title, url_for(@site)
then it works.
But your README shows a similar example without using url_for
:
add_crumb @business.display_name, @business
Why is this?
New to rails & crummy (sorry if this is a dumb question).
Something like this:
= render_crumbs :format => :html_list, :ul_id => "crumbid", :ul_class => "crumbclass", :li_class => "liclass"
returns empty li class
this:
= render_crumbs :format => :html_list, :ul_id => "crumbid", :ul_class => "crumbclass", :li_class => "liclass", :first_class => "first", :last_class => "last"
retrurns li.first, li.liclass, li.last (for three crumbs)
active_li_class not working also
and if I install gem, it installs version 1.6.0 without microdata
Someone reported that add_crumb @foo.title, @foo
is not working for people due to the @foo not automatically resolving to the correct URL.
The error was: 'undefined method
foo_path' for #<Crummy::StandardRenderer:0x000001037ef640 @_routes=nil>'`
Manually entering it works.
I have a tree of categories. When I'm in the x level category the easiet way to build breadcrumb is to
create method that will add_crumb for given category and invoke it again with parent category.
This result with root category placed on the end of breadcrumb. Is there an option to reverse it while rendering?
Is it possible to render breadcrumps as html list:
`
???
This is not really an issue.
Maybe it's a good idea to add support for rich snippets ?
http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417
copy / pasting this from the readme into config/initializers/crummy.rb:
Crummy.configure do |config|
config.format = :xml
end
results in:
/Users/nlib/data/rdfnet/config/initializers/crummy.rb:1:in <top (required)>': private method
configure' called for Crummy:Module (NoMethodError)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.