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

mhartl / rails-footnotes forked from henrik/rails-footnotes

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 5
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (2)
  • Wiki (1)
  • Graphs
  • Branch: mhartl

click here to add a description

click here to add a homepage

  • Branches (2)
    • master
    • mhartl ✓
  • Tags (2)
    • v3.2
    • v3.0
Sending Request…
Enable Donations

Pledgie Donations

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

Every Rails page has footnotes that link give request information and link back to your source via TextMate [extracted from Rails TextMate bundle project] — Read more

  cancel

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

This URL has Read+Write access

Changed 'initializer' to 'loader' to fix an Ultrasphinx incompatibility 
mhartl (author)
Mon Jul 14 17:36:18 -0700 2008
commit  9bf8344b2d9ece09ff301dfc4e500e00fd46b9bc
tree    8da542530bfb2f0de62006ed439095e8fac1a1e4
parent  15e2cb7661a752659bb057ae13df57a07fce55fe
rails-footnotes /
name age
history
message
file CHANGELOG Loading commit data...
file README.markdown
file Rakefile
file init.rb
directory lib/
directory templates/
directory test/
README.markdown

Footnotes plugin for Rails (v3.2.1)

If you are developing in Rails you should know the plugin!

It displays footnotes in your application for easy debugging, such as sessions, request parameters, cookies, log tail, filter chain and routes.

Even more, it contains links to open files directly in textmate. And if Rails get an error, it appends Textmate links to backtrace file lines.

Installation

The newest versions of the plugin only works in Rails 2.1 and above. Scroll down to check how to install early versions.

If you just want a static copy of the plugin:

cd myapp
git clone git://github.com/drnic/rails-footnotes.git vendor/plugins/footnotes
rm -rf vendor/plugins/footnotes/.git

If you are using Git for your own app, then you could use Git sub-modules or the tool Braid.

Early versions

If you are running on Rails 2.0.x or Rails 1.x, you should use Footnotes v3.0:

cd myapp
git clone git://github.com/drnic/rails-footnotes.git vendor/plugins/footnotes
cd vendor/plugins/footnotes
git checkout v3.0
rm -rf ./.git

Remember that in Rails 1.x, after filters appear first than before filters in the Filters tab.

Usage

  • Footnotes are applied in all actions under development. If You want to change this behaviour, check the loader.rb file.

  • Some features only work by default if you are under MacOSX and using Textmate. If your editor supports out-of-the-box opening files like Textmate, e.g. txmt://open?url=file://path/to/file, you can put in your environment file the following line:

Footnotes::Filter.prefix = "editor://open?file://"

If it doesn't, you can enable this behavior in few steps. I've written a post about it here.

  • If you want to use your own stylesheet, you can disable the Footnotes stylesheet with:

Footnotes::Filter.no_style = true

  • Footnotes are appended at the end of the page, but if your page has a div with id "footnotes_holder", Footnotes will be inserted into this div.

  • If you want to open multiple notes at the same time, just put in your enviroment:

Footnotes::Filter.multiple_notes = true

  • Finally, you can cherry pick which notes you want to use, simply doing:

Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :queries, :log, :general]

Creating your own notes

Create your notes to integrate with Footnotes is easy.

  1. Create a Footnotes::Notes::YoursExampleNote class

  2. Implement the necessary methods (check abstract_note.rb file in lib/notes)

  3. Append yours example note in Footnotes::Filter.notes (usually at the end of your environment file or an initializer):

Footnotes::Filter.notes += [:yours_example]

To create a note that shows info about the user logged in your application (@current_user) you just have to do:

module Footnotes
  module Notes
    class CurrentUserNote < AbstractNote
      # Always receives a controller
      #
      def initialize(controller)
        @current_user = controller.instance_variable_get("@current_user")
      end

      # Specifies the symbol that represent this note
      # This is the one you will have to add to Footnotes::Filter.notes
      #
      def self.to_sym
        :current_user
      end

      # The name that will appear as link
      #
      def title
        'Current User'
      end

      # The name that will appear as legend in fieldsets
      #
      def legend
        "Current user: #{@current_user.name}"
      end
      
      # This Note is only valid if we actually found an user
      # If it's not valid, it won't be displayed
      #
      def valid?
        @current_user
      end

      # The fieldset content
      #
      def content
        escape(@current_user.inspect)
      end
    end
  end
end

Then put in your environment:

Footnotes::Filter.notes += [:current_user]

Who?

Current Developer (v3.0 and above)

José Valim (jose.valim@gmail.com) http://josevalim.blogspot.com/

Original Author (v2.0)

Duane Johnson (duane.johnson@gmail.com) http://blog.inquirylabs.com/

License

See 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