github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

zachinglis / crummy

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 100
    • 7
  • Source
  • Commits
  • Network (7)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Click here to lend your support to: crummy and make a donation at www.pledgie.com ! Edit Pledgie Setup

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Tasty breadcrumbs! — Read more

  cancel

http://zachinglis.com

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

require crummy in initializer 
netzpirat (author)
Wed Nov 18 02:10:33 -0800 2009
zachinglis (committer)
Thu Nov 19 01:51:18 -0800 2009
commit  5775b718e8d61f5f1d198711eff96b714fee34f6
tree    769d7c566618a8fb2112a0f937856379a30c0f95
parent  0f9d4bf2118450b0293d54e81c1d68c00cc42005
crummy /
name age
history
message
file .gitignore Thu Nov 19 01:51:17 -0800 2009 Ignore generated gemspec [netzpirat]
file MIT-LICENSE Wed Jun 25 08:11:42 -0700 2008 Created a barebones plugin [zachinglis]
file README.textile Thu Nov 19 01:51:16 -0800 2009 Adding jeweler/gemcutter tasks and making hanna... [netzpirat]
file Rakefile Thu Nov 19 01:51:16 -0800 2009 Adding jeweler/gemcutter tasks and making hanna... [netzpirat]
file VERSION Thu Nov 19 01:51:17 -0800 2009 Version bump to 0.1.0 [netzpirat]
file init.rb Wed Jun 25 10:58:06 -0700 2008 Basic code in place [zachinglis]
directory lib/ Thu Dec 18 14:21:07 -0800 2008 Allow to use symbols instead of always repeat t... [xjunior]
directory rails/ Thu Nov 19 01:51:18 -0800 2009 require crummy in initializer [netzpirat]
directory tasks/ Wed Jun 25 08:11:42 -0700 2008 Created a barebones plugin [zachinglis]
README.textile

Crummy

Introduction

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

Install

The gem is hosted on gemcutter, so if you haven’t already, add it as a gem source:

  
    gem sources -a http://gemcutter.org/
  

Then install the Formtastic gem:

  
    gem install crummy
  

You can also install it as a Rails plugin:

  
    script/plugin install git://github.com/zachinglis/crummy.git
  

Example

In your controllers you may add_crumb either like a before_filter or within a method (It is also available to views).

  
    class ApplicationController
      add_crumb "Home", '/'
    end
    
    class BusinessController < ApplicationController
      add_crumb("Businesses") { |instance| instance.send :businesses_path }
      add_crumb("Comments", :only => "comments") { |instance| instance.send :businesses_comments_path }
      before_filter :load_comment, :only => "show"
      add_crumb :comment, :only => "show"
  
      def show
        add_crumb @business.display_name, @business
      end
      
      def load_comment
        @comment = Comment.find(params[:id])
      end
    end
  

Then in your view:

  
    <%= render_crumbs %>
  

Options for render_crumb_

render_crumbs renders the list of crumbs as either html or xml

It takes 3 options

The output format. Can either be :xml or :html. Defaults to :html

:format => (:html|:xml)

The seperator text. It does not assume you want spaces on either side so you must specify. Defaults to &raquo; for :html and <crumb> for :xml

:seperator => string

Render links in the output. Defaults to true

:link => boolean

Examples

 
  render_crumbs                     #=> <a href="/">Home</a> &raquo; <a href="/businesses">Businesses</a>
  render_crumbs :seperator => ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
  render_crumbs :format => :xml     #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
 

A crumb with a nil link will just output plain text.

Notes

The variable set is set to @_crumbs as to not conflict with your code.

Todo

  • Port over rspecs from project to plugin (Fully tested in a project)
  • Accept instances of models as a single argument
  • Allow for variables in names. (The workaround is to do your own before_filter for that currently)

Credits

  • Zach Inglis
  • Rein Henrichs
  • Les Hill
  • Sandro Turriate
  • Przemysław Kowalczyk – feature ideas

Copyright © 2008 Zach Inglis, released under the MIT license

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server