public
Description: Every Rails page has footnotes that link give request information and link back to your source via TextMate [extracted from Rails TextMate bundle project]
Clone URL: git://github.com/drnic/rails-footnotes.git
Footnotes v3.2: Now you can easily add your notes
josevalim (author)
Thu Jun 05 07:55:24 -0700 2008
commit  f9a9e706a76ff3d0a7fbf340b2356f3eeed93824
tree    0fa5a59638d4cf9e3048c8a298b4fde5a47b700c
parent  0d10539dba6addab1ad8174d7c82b6f0ff39f80d
...
1
2
3
 
 
 
4
5
6
7
 
8
9
10
...
1
 
 
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,10 +1,12 @@
0
 TODO:
0
- * Use YAML files to load configuration files
0
- * Create a profiler tab
0
+ * Create ProfilerNote
0
+ * Create Rakefile
0
+ * Create Tests
0
   
0
 == Footnotes v3.2
0
 Author: José Valim (jose.valim@gmail.com)
0
 Site: http://www.pagestacker.com/
0
+ * Now you can easily add your own notes;
0
   * Added numbers to tabs;
0
   * Added Queries note;
0
   * Added MySQL Query Analyzer.
...
1
 
2
3
4
...
34
35
36
37
38
 
 
39
40
 
41
42
43
 
44
45
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
48
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
51
52
53
 
 
 
 
 
 
54
55
56
...
 
1
2
3
4
...
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
0
@@ -1,4 +1,4 @@
0
-Footnotes plugin for Rails (v3.1)
0
+Footnotes plugin for Rails (v3.2)
0
 ---------------------------------
0
 
0
 If you are developing in Rails you should know the plugin!
0
@@ -34,23 +34,92 @@ If you are running on Rails 2.0.x or Rails 1.x, you should use Footnotes v3.0:
0
 
0
 Remember that in Rails 1.x, after filters appear first than before filters in the Filters tab.
0
 
0
-Usage
0
-=====
0
+Usage notes
0
+===========
0
 
0
-Detailed info about usage can be found in init.rb
0
+* Footnotes are applied in all actions under development. If You want to change this behaviour, check the initializer.rb file.
0
 
0
-Original Author
0
-===============
0
+* Some features only work if you are under MacOSX. But if your editor support opening files like Textmate, e.g. txmt://open?url=file://, you can put in your environment file the following line:
0
 
0
-Duane Johnson (duane.johnson@gmail.com)
0
-http://blog.inquirylabs.com/
0
+ Footnotes::Filter.prefix = "editor://open?file://"
0
+
0
+Another option is to automatically register the protocol in your browser and/or OS. To do this in Firefox, please read: http://kb.mozillazine.org/Register_protocol
0
+
0
+* If you want to use your own stylesheet, you can disable the Footnotes stylesheet with:
0
+
0
+ Footnotes::Filter.no_style = true
0
+
0
+* Footnotes are appended at the end of the page, but if your page has a div with id "tm_footnotes", Footnotes will be inserted into this div.
0
+
0
+* Finally, you can cherry pick which notes you want to use, simply doing:
0
+
0
+ Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :queries, :log, :general]
0
+
0
+Creating your own notes
0
+=======================
0
+
0
+Create your notes to integrate with Footnotes is easy:
0
+
0
+# Create a Footnotes::Notes::YoursExampleNote class
0
+# Implement the necessary methods (check abstract_note.rb file in lib/notes)
0
+# Append yours example note in Footnotes::Filter.notes (usually at the end of your environment file or an initializer):
0
 
0
-Current developer
0
-=================
0
+ Footnotes::Filter.notes += [:yours_example]
0
+
0
+To create a note that shows info about the user logged in your application (@current_user) you just have to do this:
0
+
0
+ module Footnotes
0
+ module Notes
0
+ class CurrentUserNote < AbstractNote
0
+ # Always receives a controller
0
+ #
0
+ def initialize(controller)
0
+ @current_user = controller.instance_variable_get("@current_user")
0
+ end
0
+
0
+ # Specifies the symbol that represent this note
0
+ # This is the one you will have to add to Footnotes::Filter.notes
0
+ #
0
+ def self.to_sym
0
+ :current_user
0
+ end
0
+
0
+ # The name that will appear as link
0
+ # If title is nil, the other methods are not called
0
+ #
0
+ def title
0
+ 'Current User' if @current_user
0
+ end
0
+
0
+ # The name that will appear as legend in fieldsets
0
+ #
0
+ def legend
0
+ "Current user: #{@current_user.name}"
0
+ end
0
+
0
+ # The fieldset content
0
+ #
0
+ def content
0
+ escape(@current_user.inspect)
0
+ end
0
+ end
0
+ end
0
+ end
0
+
0
+ Footnotes::Filter.notes += [:current_user]
0
+
0
+Current Developer (v3.0 and above)
0
+==================================
0
 
0
 José Valim (jose.valim@gmail.com)
0
 http://josevalim.blogspot.com/
0
 
0
+Original Author (v2.0)
0
+======================
0
+
0
+Duane Johnson (duane.johnson@gmail.com)
0
+http://blog.inquirylabs.com/
0
+
0
 License
0
 =======
0
 
...
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
...
 
1
2
 
 
3
4
 
 
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
 
 
 
 
 
 
10
11
12
13
14
 
 
 
 
15
16
17
0
@@ -1,50 +1,16 @@
0
-# Footnotes is divided in five files:
0
+# Footnotes is divided in three main files:
0
 #
0
-# * textmate_footnotes.rb: Is the core and adds the debug options at the bottom
0
-# of each page;
0
+# * initialiazer.rb: Initialize the plugin and apply the footnotes as an after_filter;
0
 #
0
-# * textmate_initialiaze.rb: Initialize the plugin and apply the footnotes as an
0
-# after_filter;
0
+# * footnotes.rb: Is the core and adds the debug options at the bottom of each page;
0
 #
0
-# * textmate_links.rb: Provides links to open controller, layout, view and asset
0
-# files in textmate;
0
-#
0
-# * textmate_backtracer.rb: Append links to Textmate in backtrace pages.
0
-#
0
-# * textmate_analyzer.rb: Append explain queries in log when using MySQL.
0
-#
0
-# The footnotes are applied in all actions under development. If You want to
0
-# change this behaviour, check the textmate_initialize.rb file.
0
-#
0
-# And by default, the last two files are only loaded in MacOSX. If your editor
0
-# support opening files like Textmate, e.g. txmt://open?url=file://, you can put
0
-# in your environment file the following line:
0
-#
0
-# Footnotes::Filter.textmate_prefix = "editor://open?file://"
0
-#
0
-# If You want to use your own stylesheet, you can disable the Footnotes
0
-# stylesheet with:
0
-#
0
-# Footnotes::Filter.no_style = true
0
-#
0
-# Footnotes try to append at the end of the page, but if your page have a div
0
-# with id "tm_footnotes", Footnotes will be inserted into this div.
0
-#
0
-# In Footnotes 3.1, you also have the ability to cherry pick which notes do you
0
-# want to use, simply doing:
0
-#
0
-# Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :queries, :log, :general]
0
+# * backtracer.rb: Append links to tour favorite editor in backtrace pages.
0
 #
0
 if (ENV['RAILS_ENV'] == 'development')
0
- # Windows doesn't have 'uname', so rescue false
0
- ::MAC_OS_X = RUBY_PLATFORM.include?('darwin')
0
- require 'textmate_footnotes'
0
- require 'textmate_links'
0
- require 'textmate_analyzer'
0
- require 'textmate_initialize'
0
+ dir = File.dirname(__FILE__)
0
+ require File.join(dir,'lib','footnotes')
0
+ require File.join(dir,'lib','initializer')
0
+ require File.join(dir,'lib','backtracer')
0
 
0
- if ::MAC_OS_X
0
- Footnotes::Filter.textmate_prefix = 'txmt://open?url=file://'
0
- require 'textmate_backtracer'
0
- end
0
+ Footnotes::Filter.prefix ||= 'txmt://open?url=file://' if RUBY_PLATFORM.include?('darwin')
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.