ProctorU / ducktrails

Restful Breadcrumbs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🦆 Ducktrails

Automatically generates breadcrumbs based on routes.

Warning: This API is still alpha; we welcome PRs and ideas as issues.

Ducktails Theme

Usage

For basic applications using a restful architecture, ducktrails should generate the breadcrumbs automatically.

For example, if the uri is /users/#{user-id}/posts/#{post-id} Putting <%= breadcrumbs %> in the (erb) view.

Would render:

Home / All Users / user-name / All Posts / post-name

Simply include = breadcrumbs in your view. breadcrumbs takes a block argument. The block isn't required but if you want to set some objects for the uri resources (recommend) you can follow the guide below.

Resources are inferred and will be used to manipulate each URI segment. If a resource is not found, Ducktrails will fallback to the URI.

Possible keys for a breadcrumb resource are: resource, key, policy, collection_prefix. The key and collection prefix can be configured in the Ducktrails.rb initializer described below.

<%=breadcrumbs do
    {
      users: {
        resource: @user,
        key: :first_name,
        collection_prefix: 'Some'
      }
    }
  end
%>

Will output

Action Breadcrumb
index Home / Some Users
show Home / Some Users / Kevin
new Home / Some Users / New
edit Home /Some Users / Kevin / edit

Installation

Add this line to your application's Gemfile:

gem 'ducktrails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ducktrails

Configuration

Ducktrails provides a standard initializer file: Note: Currently ducktrails is the only template theme provided

Ducktrails.configure do |config|
  config.root_path = '/'
  config.home_name = 'Home'
  config.collection_prefix = 'All'
  config.default_key = :id
  config.theme = 'ducktrails'
end

Contributing

Please refer to each project's style guidelines and guidelines for submitting patches and additions. In general, we follow the "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. bundle
  4. Create the test db bundle exec rake --rakefile test/dummy/Rakefile db:setup
  5. bundle exec rake to test.
  6. Ensure your test coverage is A+
  7. Commit changes to your own branch
  8. Push your work back up to your fork
  9. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

License

The gem is available as open source under the terms of the MIT License.

About

Restful Breadcrumbs

License:MIT License


Languages

Language:Ruby 89.4%Language:JavaScript 4.6%Language:HTML 3.1%Language:CSS 2.9%