forked from indirect/rails-footnotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
147 lines (98 loc) · 4.18 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Rails Footnotes
License: MIT
Version: 3.4.1
You can also read this README in pretty html at the GitHub project Wiki page
http://github.com/josevalim/rails-footnotes/wikis/home
Description
-----------
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, filter chain, routes, queries, etc.
Even more, it contains links to open files directly in your editor including
your backtrace lines.
Installation
------------
Install Rails Footnotes is very easy. If you are running on Rails 2.3 just run
the following:
gem sources -a http://gems.github.com
sudo gem install josevalim-rails-footnotes
In RAILS_ROOT/config/environments/development.rb (yes, you want it only in development):
config.gem "josevalim-rails-footnotes", :lib => "rails-footnotes", :source => "http://gems.github.com"
If you want it as plugin, just do:
script/plugin install git://github.com/josevalim/rails-footnotes.git
If you are running on Rails 2.2 or Rails 2.1 you should do:
cd myapp
git clone git://github.com/josevalim/rails-footnotes.git
cd vendor/plugins/rails-footnotes
git checkout VERSION_NUMBER
rm -rf ./.git
Where you should replace VERSION_NUMBER for "v3.3.2" for Rails 2.2 and "v3.2.2"
for Rails 2.1 (without the quotes).
Configuration
-------------
If you are not using Textmate as text editor, in your environment.rb or
in an initializer do:
if defined?(Footnotes)
Footnotes::Filter.prefix = 'txmt://open?url=file://%s&line=%d&column=%d'
end
Where you are going to choose a prefix compatible with your text editor. The %s is
replaced by the name of the file, the first %d is replaced by the line number and
the second %d is replaced by the column. You can also enable this behaviour in other
editors following the steps in the link below:
http://josevalim.blogspot.com/2008/06/textmate-protocol-behavior-on-any.html
By default, footnotes are appended at the end of the page with default stylesheet. If you want
to change their position, you can define a div with id "footnotes_holder" or define your own stylesheet
by turning footnotes stylesheet off:
Footnotes::Filter.no_style = true
Another option is to allow multiple notes to be opened at the same time:
Footnotes::Filter.multiple_notes = true
Finally, you can control which notes you want to show. The default are:
Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :env, :queries, :log, :general]
Creating your own notes
-----------------------
Create your notes to integrate with Footnotes is easy.
1. Create a Footnotes::Notes::YourExampleNote class
2. Implement the necessary methods (check abstract_note.rb file in lib/notes)
3. Append your example note in Footnotes::Filter.notes array (usually at the end of your environment file or in an initializer):
For example, to create a note that shows info about the user logged in your application you just have to do:
module Footnotes
module Notes
class CurrentUserNote < AbstractNote
# This method always receives a controller
#
def initialize(controller)
@current_user = controller.instance_variable_get("@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]
Bugs and Feedback
-----------------
If you discover any bugs, please send an e-mail to [email protected]
If you just want to give some positive feedback or drop a line, that's fine too! =)
Copyright (c) 2009 José Valim
http://www.pagestacker.com/
http://josevalim.blogspot.com/
Version 2.0
-----------
Until version 2.0, this plugin was created and maintained by:
Duane Johnson ([email protected])
http://blog.inquirylabs.com/