Take the 2008 Git User's Survey and help out! [ hide ]

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
Search Repo:
This is a merge from the git repository hosted by Dr. Nic
http://github.com/drnic/ruby-on-rails-tmbundle/commit/7edadd1

== 1.90.0 2008-03-08

* Major Upgrade to Rails 2.0 - Initial release
* Ruby on Rails bundle maintenance has been taken over by Dr Nic Williams 
from its initial legendary creator Duane Johnson.
* Added so far:
  * Snippets/Commands for:
    * Tests
      * assert_select (ass)
      * assert_difference/assert_no_difference (asd/asnd)
      * GET+POST test method stubs (deftg+deftp)
      * posts(:) + Alt+Esc allows you to select a posts.yml fixture
    * Controllers
      * respond_to (rest) and respond_to(html) (Shift+Cmd+H)
      * 'Go To View' within a respond_to will use the format/wants type as 
      the default
      * REMOVED: render_component snippets
      * loggers - pass a block instead of raw string to save time if
        logging not used (e.g. production) [Stephen Touset]
      * redirect_to for resource paths (rep, repp, renp, renpp)
      * render :update (ru) [Simon Jefford]
    * Views
      * form_for and form_for(with errors) (ff,ffe)
      * Various form_for helpers in a drop-down list, e.g. f.text_field 
      (f.)
      * Various form_for helpers with own tab completion, e.g. 
      f.text_field (fftf)
      * link_to for resource paths (lip, lipp, linp, linpp)
      * <% end -%> (end)
      * for-loop (for)
      * link_to(@model.name, @model) (ltm)
    * Layouts
      * javascript_include_tag - jit
      * stylesheet_link_tag - slt
    * Models
      * has_many :though (hmt)
      * association snippets give better defaults (e.g. bt + hm)
      * validates_format_of (vf,vfif) [Dean Strelau]
      * validates_numericality_of (vn,vnif) [Tom Morris]
      * before/after callbacks (prefix bef/aft + 1st letter of words) [Sam 
      Granieri]
    * Migrations
      * Sexy Migrations now available as "t." snippets and 
      regular snippets [Lawrence Pit]
      * Migration classes have own textmate scope
      * Add/Remove Columns - the 'down' statements are in reverse
        order [Lawrence Pit, Daniel Kristensen]
      * Added 'Redo Last Migration' [Simon Jefford]
    * Functional Tests
      * assert_redirect_to for resource paths (artp, artpp, artnp, artnpp)

            * assert(assigns(:model)) (asg)
    * Routes
      * named routes, resources snippets (map, mapr, maprs)
      * catch_all (mapca) [Sam Granieri]
    * Active Support
      * cattr_accessor/mattr_accessor (crw/mrw) [Jacob Swanner]
      * returning (returning) [Jacob Swanner]
  * Language/Syntax
    * New keywords: rescue_from, alias_method_chain, alias_attribute, 
    delegate, respond_to [David Lowenfels, Jacob Swanner]
    * Added rb as a valid Rails file type [James Deville]
  * Commands
    * Auto-completion for Foxy Fixtures
    * html.erb is the default for new templates (backwards compatibility
      is being worked on too)
    * 'Go To XXX' - available for wide range of permutations.
      Fixtures -> Models; Models -> Controllers, etc
    * haml is a valid file extension [Steve Ross]
    * specify alternate default file extensions for: [Steve Ross]
      * javascript - ENV['RAILS_JS_EXT']
      * stylesheet - ENV['RAILS_CSS_EXT']
      * view - ENV['RAILS_VIEW_EXT']
    * 'Call Generate Script' now accesses all a project's generators
  * Plugins
    * Footnote
      * footnote-edge uses .erb for templates [Stephen Bannasch]
  * Internals
    * Rakefile - test runner [Steve Ross]
    * Added generator_test
    * Removed unnecessary misc_test
    * script/clean_bundle_file_names - rename non-os-agnostic file names 
    [Charles Roper]
  * Haml support [Lawrence Pit]

For thoughts and patches, email drnicwilliams@gmail.com


git-svn-id: 
http://macromates.com/svn/Bundles/trunk/Bundles/Ruby%20on%20Rails.tmbundle
/Support/plugins/footnotes-edge@9069 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
kevin (author)
Sat Mar 08 08:22:13 -0800 2008
commit  34ad6c6ca16a295b14d3a6fb5845767bb96eb479
tree    2b70232d1fd7f40382de51c739b52d71c739ddb2
parent  fa01a688cddc3b9b0db2540ad3948c7ae46da5d4
...
15
16
17
18
 
19
20
21
...
15
16
17
 
18
19
20
21
0
@@ -15,6 +15,6 @@ if (ENV['RAILS_ENV'] == 'development')
0
   ::MAC_OS_X = (`uname`.chomp == "Darwin") rescue false
0
   require 'textmate_footnotes'
0
   require 'textmate_initialize'
0
-
0
+
0
   require 'textmate_backtracer' if ::MAC_OS_X
0
 end
0
\ No newline at end of file
...
1
2
3
 
4
5
6
...
33
34
35
36
 
37
38
39
40
41
 
42
43
44
...
1
2
 
3
4
5
6
...
33
34
35
 
36
37
38
39
40
 
41
42
 
43
0
@@ -1,6 +1,6 @@
0
 class Exception
0
   alias :original_clean_backtrace :clean_backtrace
0
-
0
+
0
   def add_links_to_backtrace(lines)
0
     lines.collect do |line|
0
       expanded = line.gsub '#{RAILS_ROOT}', RAILS_ROOT
0
@@ -33,11 +33,10 @@ protected
0
   alias backtracer_original_template_path_for_local_rescue template_path_for_local_rescue
0
   def template_path_for_local_rescue(exception)
0
     if ActionView::TemplateError === exception
0
- File.dirname(__FILE__) + "/../templates/rescues/template_error.rhtml"
0
+ File.dirname(__FILE__) + "/../templates/rescues/template_error.erb"
0
     else
0
       backtracer_original_template_path_for_local_rescue(exception)
0
     end
0
   end
0
-
0
+
0
 end
0
-
0
\ No newline at end of file
...
15
16
17
18
 
19
20
 
21
22
23
24
25
26
 
27
28
29
...
31
32
33
34
 
35
36
37
...
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
...
115
116
117
118
 
119
120
121
122
 
123
124
125
126
 
127
128
129
...
136
137
138
139
 
140
141
 
142
143
144
145
 
146
147
148
...
182
183
184
185
 
186
187
188
...
198
199
200
201
 
202
203
204
...
218
219
220
221
 
222
223
224
...
250
251
252
253
 
254
255
256
...
15
16
17
 
18
19
 
20
21
22
23
24
25
 
26
27
28
29
...
31
32
33
 
34
35
36
37
...
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
...
115
116
117
 
118
119
120
121
 
122
123
124
125
 
126
127
128
129
...
136
137
138
 
139
140
 
141
142
143
144
 
145
146
147
148
...
182
183
184
 
185
186
187
188
...
198
199
200
 
201
202
203
204
...
218
219
220
 
221
222
223
224
...
250
251
252
 
253
254
255
256
0
@@ -15,15 +15,15 @@ class FootnoteFilter
0
   cattr_accessor :no_style, :abs_root, :textmate_prefix
0
   self.no_style = false
0
   self.textmate_prefix = "txmt://open?url=file://"
0
-
0
+
0
   attr_accessor :body, :abs_root
0
-
0
+
0
   def self.filter(controller)
0
     return if controller.render_without_footnotes
0
     filter = FootnoteFilter.new(controller)
0
     filter.add_footnotes!
0
   end
0
-
0
+
0
   def initialize(controller)
0
     @controller = controller
0
     @template = controller.instance_variable_get("@template")
0
@@ -31,7 +31,7 @@ class FootnoteFilter
0
     @extra_html = ""
0
     self.abs_root = File.expand_path(RAILS_ROOT)
0
   end
0
-
0
+
0
   def add_footnotes!
0
     if performed_render? and first_render?
0
       if ["html.erb", "haml", "rhtml", "rxhtml"].include?(template_extension) && (content_type =~ /html/ || content_type.nil?) && !xhr?
0
@@ -44,70 +44,70 @@ class FootnoteFilter
0
     # Discard footnotes if there are any problems
0
     RAILS_DEFAULT_LOGGER.error "Textmate Footnotes Exception: #{e}\n#{e.backtrace.join("\n")}"
0
   end
0
-
0
+
0
   # Some controller classes come with the Controller:: module and some don't
0
   # (anyone know why? -- Duane)
0
   def controller_filename
0
     File.join(abs_root, "app", "controllers", "#{@controller.class.to_s.underscore}.rb").
0
     sub('/controllers/controllers/', '/controllers/')
0
   end
0
-
0
+
0
   def controller_text
0
     @controller_text ||= IO.read(controller_filename)
0
   end
0
-
0
+
0
   def index_of_method
0
     (controller_text =~ /def\s+#{@controller.action_name}[\s\(]/)
0
   end
0
-
0
+
0
   def controller_line_number
0
     controller_text.line_from_index(index_of_method)
0
   end
0
-
0
+
0
   def performed_render?
0
     @controller.instance_variable_get("@performed_render")
0
   end
0
-
0
+
0
   def first_render?
0
     @template.respond_to?(:first_render) and @template.first_render
0
   end
0
-
0
+
0
   def xhr?
0
     @controller.request.xhr?
0
   end
0
-
0
+
0
   def template_path
0
     @template.first_render.sub(/\.(html\.erb|rhtml|rxhtml|rxml|rjs)$/, "")
0
   end
0
-
0
+
0
   def template_extension
0
     @template.first_render.scan(/\.(html\.erb|rhtml|rxhtml|rxml|rjs)$/).flatten.first ||
0
     @template.pick_template_extension(template_path).to_s
0
   end
0
-
0
+
0
   def template_file_name
0
     File.expand_path(@template.send(:full_template_path, template_path, template_extension))
0
   end
0
-
0
+
0
   def layout_file_name
0
     ["html.erb", "rhtml"].each do |extension|
0
       path = File.expand_path(@template.send(:full_template_path, @controller.active_layout, extension))
0
       return path if File.exist?(path)
0
     end
0
   end
0
-
0
+
0
   def content_type
0
     @controller.response.headers['Content-Type']
0
   end
0
-
0
+
0
   def stylesheet_files
0
     @stylesheet_files ||= @body.scan(/<link[^>]+href\s*=\s*['"]([^>?'"]+)/im).flatten
0
   end
0
-
0
+
0
   def javascript_files
0
     @javascript_files ||= @body.scan(/<script[^>]+src\s*=\s*['"]([^>?'"]+)/im).flatten
0
   end
0
-
0
+
0
   def controller_url
0
     escape(
0
       textmate_prefix +
0
@@ -115,15 +115,15 @@ class FootnoteFilter
0
       (index_of_method ? "&line=#{controller_line_number + 1}&column=3" : "")
0
     )
0
   end
0
-
0
+
0
   def view_url
0
     escape(textmate_prefix + template_file_name)
0
   end
0
-
0
+
0
   def layout_url
0
     escape(textmate_prefix + layout_file_name)
0
   end
0
-
0
+
0
   def insert_styles
0
     insert_text :before, /<\/head>/i, <<-HTML
0
     <!-- TextMate Footnotes Style -->
0
@@ -136,13 +136,13 @@ class FootnoteFilter
0
     <!-- End TextMate Footnotes Style -->
0
     HTML
0
   end
0
-
0
+
0
   def insert_footnotes
0
-
0
+
0
     def tm_footnotes_toggle(id)
0
       "s = document.getElementById('#{id}').style; if(s.display == 'none') { s.display = '' } else { s.display = 'none' }"
0
     end
0
-
0
+
0
     footnotes_html = <<-HTML
0
     <!-- TextMate Footnotes -->
0
     <div style="clear:both"></div>
0
@@ -182,7 +182,7 @@ class FootnoteFilter
0
       insert_text :before, /<\/body>/i, footnotes_html
0
     end
0
   end
0
-
0
+
0
   def textmate_links
0
     html = ""
0
     if ::MAC_OS_X
0
@@ -198,7 +198,7 @@ class FootnoteFilter
0
     end
0
     html
0
   end
0
-
0
+
0
   def asset_file_links(link_text, files)
0
     return '' if files.size == 0
0
     links = files.map do |filename|
0
@@ -218,7 +218,7 @@ class FootnoteFilter
0
     # Return the link that will open the 'extra html' div
0
     %{ | <a href="#" onclick="#{tm_footnotes_toggle('tm_footnotes_' + link_text.underscore.gsub(' ', '_') )}; return false">#{link_text}</a>}
0
   end
0
-
0
+
0
   def indent(indentation, text)
0
     lines = text.to_a
0
     initial_indentation = lines.first.scan(/^(\s+)/).flatten.first
0
@@ -250,7 +250,7 @@ class FootnoteFilter
0
       end
0
     @body.insert index, indent(indentation, new_text)
0
   end
0
-
0
+
0
   def escape(text)
0
     text.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;")
0
   end
...
5
6
7
8
 
9
10
11
...
14
15
16
17
 
18
19
20
21
 
22
23
24
25
 
26
27
28
29
 
30
31
32
33
 
34
35
36
...
40
41
42
43
 
44
45
46
...
54
55
56
57
 
58
59
60
61
 
62
63
64
...
5
6
7
 
8
9
10
11
...
14
15
16
 
17
18
19
20
 
21
22
23
24
 
25
26
27
28
 
29
30
31
32
 
33
34
35
36
...
40
41
42
 
43
44
45
46
...
54
55
56
 
57
58
59
60
 
61
62
63
64
0
@@ -5,7 +5,7 @@ RAILS_ROOT.replace File.dirname(__FILE__)
0
 
0
 class MockController
0
   attr_accessor :template, :session, :params, :cookies
0
-
0
+
0
   def initialize(body = "")
0
     @body = body
0
     @performed_render = true
0
@@ -14,23 +14,23 @@ class MockController
0
     @cookies = {}
0
     template
0
   end
0
-
0
+
0
   def template
0
     @template ||= MockTemplate.new(self)
0
   end
0
-
0
+
0
   def response
0
     @response ||= OpenStruct.new(:body => @body, :headers => {})
0
   end
0
-
0
+
0
   def first_render
0
     @body
0
   end
0
-
0
+
0
   def request
0
     @request ||= MockRequest.new(false)
0
   end
0
-
0
+
0
   def action_name
0
     @params[:action]
0
   end
0
@@ -40,7 +40,7 @@ class MockTemplate
0
   def initialize(controller)
0
     @controller = controller
0
   end
0
-
0
+
0
   def first_render
0
     "example.rhtml"
0
   end
0
@@ -54,11 +54,11 @@ class FootnoteFilter
0
   def controller_filename
0
     __FILE__
0
   end
0
-
0
+
0
   def template_file_name
0
     __FILE__
0
   end
0
-
0
+
0
   def layout_file_name
0
     __FILE__
0
   end
...
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
...
77
78
79
80
81
 
 
82
83
84
...
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
...
77
78
79
 
 
80
81
82
83
84
0
@@ -11,52 +11,52 @@ class TextmateFootnotesTest < Test::Unit::TestCase
0
     @controller = MockController.new $html.dup
0
     @footnote = FootnoteFilter.new(@controller)
0
   end
0
-
0
+
0
   def test_mock_controller
0
     index = @controller.response.body.index(/This is the HTML page/)
0
     assert_equal 334, index
0
   end
0
-
0
+
0
   def test_footnote_not_included_when_request_is_xhr
0
     @controller.request.xhr = true
0
     @footnote.add_footnotes!
0
     assert_equal $html, @controller.response.body
0
   end
0
-
0
+
0
   def test_footnote_not_included_when_content_type_is_javascript
0
     @controller.response.headers['Content-Type'] = 'text/javascript'
0
     @footnote.add_footnotes!
0
     assert_equal $html, @controller.response.body
0
   end
0
-
0
+
0
   def test_footnote_included_when_content_type_is_html
0
     @controller.response.headers['Content-Type'] = 'text/html'
0
     @footnote.add_footnotes!
0
     assert_not_equal $html, @controller.response.body
0
   end
0
-
0
+
0
   def test_footnote_included_when_content_type_is_nil
0
     @footnote.add_footnotes!
0
     assert_not_equal $html, @controller.response.body
0
   end
0
-
0
+
0
   def test_indent
0
     before = "text\n one\n two"
0
     after = " text\n one\n two"
0
-
0
+
0
     assert_equal after, @footnote.indent(2, before)
0
 
0
     before = " text\n one\n two"
0
     after = " text\n one\n two"
0
-
0
+
0
     assert_equal after, @footnote.indent(2, before)
0
 
0
     before = " text\none\ntwo"
0
     after = " text\n one\n two"
0
-
0
+
0
     assert_equal after, @footnote.indent(2, before)
0
   end
0
-
0
+
0
   def test_insert_text
0
     @footnote.insert_text :after, /<head>/, "Graffiti", 0
0
     after = " <head>Graffiti\n"
0
@@ -77,8 +77,8 @@ __END__
0
         <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
0
     </head>
0
     <body>
0
- <p>This is the HTML page. It works and is encoded just like any HTML page you
0
- have previously done. View <a href="htmltoxhtml2.htm">the XHTML version</a> of
0
+ <p>This is the HTML page. It works and is encoded just like any HTML page you
0
+ have previously done. View <a href="htmltoxhtml2.htm">the XHTML version</a> of
0
          this page to view the difference between HTML and XHTML.</p>
0
         <p>You will be glad to know that no changes need to be made to any of your CSS files.</p>
0
     </body>

Comments

    No one has commented yet.