Giter Site home page Giter Site logo

zachinglis / crummy Goto Github PK

View Code? Open in Web Editor NEW
359.0 359.0 84.0 182 KB

Tasty breadcrumbs! Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.

Home Page: http://zachinglis.com

License: MIT License

Shell 7.38% Ruby 83.64% JavaScript 0.83% CoffeeScript 0.82% CSS 0.63% HTML 3.90% Sass 0.66% SCSS 0.31% Haml 1.82%

crummy's Introduction

crummy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

crummy's Issues

Empty attributes

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>

Some translations do not work in add_crumb

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)

duplicate breadcrumbs

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

Manual passing with "add_crumb" results with additional, auto-generated elements

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?

Render more HTML inside the HTML list links (e.g. dropdown lists)

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!

html_list_separator is never used

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.

Calling Html_Safe By Default

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.

Gem install instructions mention Formtastic

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"

Rails 6.1: ActionView::Template::Error: can't modify frozen Hash

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?

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

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 }

"Seperator"

It would be bettter to call parameter 'separator', not 'seperator'.

Placing separator outside of li

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!

controller level add_crumb() fails

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:inadd_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:inevaluate_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'

explicitly calling url_for is necessary?

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).

li class

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

Finding the route automatically not working for one.

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 methodfoo_path' for #<Crummy::StandardRenderer:0x000001037ef640 @_routes=nil>'`

Manually entering it works.

Reversed breadcrumb.

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?

global settings don't work for rails 3

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 methodconfigure' called for Crummy:Module (NoMethodError)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.