canvas-lms/gems/canvas_crummy
Ryan Shaw 989ed93e6c add streaming templates: part 1
send the head tag before we start rendering
the rest of the response for the following
high traffic endpoints:

context#roster_user
courses#index
eportfolio_categories#show
eportfolio_entries#show
eportfolios#show
gradebooks#grade_summary
submissions#show

Change-Id: I2bb2e068c4c0633964aee05c27d3e6207e1cf472
Reviewed-on: https://gerrit.instructure.com/199707
Tested-by: Jenkins
QA-Review: Ryan Shaw <ryan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
2019-07-31 19:23:44 +00:00
..
lib add streaming templates: part 1 2019-07-31 19:23:44 +00:00
Gemfile bump simplecov, fixes SD-2056 2017-04-04 18:06:25 +00:00
LICENSE.txt da licença part 53 2017-05-01 21:06:11 +00:00
README.md da licença part 53 2017-05-01 21:06:11 +00:00
Rakefile convert crummy plugin to proper gem 2014-01-30 18:30:15 +00:00
canvas_crummy.gemspec don't use git to build vendored gem specification file list 2014-02-12 22:58:25 +00:00

README.md

h1. CanvasCrummy

This is a fork of an early version of the crummy gem. http://rubygems.org/gems/crummy

TODO: use a more current version of the gem instead of this forked one

h2. Introduction

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

h2. Install

The gem is hosted on gemcutter, so if you havent 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
  

h2. 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 %>
  

h2. 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 » for :html and for :xml

:seperator => string

Render links in the output. Defaults to +true+

:link => boolean

h3. Examples

 
  render_crumbs                     #=> Home » Businesses
  render_crumbs :seperator => ' | ' #=> Home | Businesses
  render_crumbs :format => :xml     #=> HomeBusinesses
 

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

h2. Notes

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

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

h2. Credits