rails-footnotes 3.6.7 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +6 -2
- data/Gemfile +12 -0
- data/Gemfile.lock +83 -0
- data/README +26 -18
- data/Rakefile +5 -30
- data/lib/rails-footnotes.rb +16 -17
- data/lib/rails-footnotes/backtracer.rb +4 -2
- data/lib/rails-footnotes/footnotes.rb +43 -24
- data/lib/rails-footnotes/notes/controller_note.rb +1 -1
- data/lib/rails-footnotes/notes/files_note.rb +1 -1
- data/lib/rails-footnotes/notes/filters_note.rb +3 -3
- data/lib/rails-footnotes/notes/layout_note.rb +2 -2
- data/lib/rails-footnotes/notes/log_note.rb +1 -1
- data/lib/rails-footnotes/notes/partials_note.rb +1 -1
- data/lib/rails-footnotes/notes/queries_note.rb +3 -3
- data/lib/rails-footnotes/notes/routes_note.rb +11 -7
- data/lib/rails-footnotes/version.rb +3 -0
- data/rails-footnotes.gemspec +29 -0
- data/test/footnotes_test.rb +13 -5
- data/test/notes/abstract_note_test.rb +2 -2
- data/test/test_helper.rb +3 -2
- metadata +71 -22
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
tags
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== Footnotes v3.7.0
|
2
|
+
* Migrate to Bundler
|
3
|
+
* Support only Rails3
|
4
|
+
|
1
5
|
== Footnotes v3.6.7
|
2
6
|
* fixed log_note error - long overdue (thanks to many including Moritz Heidkamp)
|
3
7
|
* 1.9: ignore more assigns (thanks to justin case)
|
@@ -14,7 +18,7 @@
|
|
14
18
|
* pre rails 2.3 support fixes (thanks to tobias)
|
15
19
|
* better disabling of query notes (thanks to tobias)
|
16
20
|
* fixed variable assignment escaping (thanks to gdelvino)
|
17
|
-
* fixed cookie value escaping (thanks to indirect)
|
21
|
+
* fixed cookie value escaping (thanks to indirect)
|
18
22
|
* Turn off footnotes with a parameter footnotes=false (thanks to indirect)
|
19
23
|
|
20
24
|
== Footnotes v3.6
|
@@ -50,7 +54,7 @@
|
|
50
54
|
== Footnotes v3.2.1
|
51
55
|
* Added some tests;
|
52
56
|
* Redefined Footnotes CSS and Javascripts to use concise names.
|
53
|
-
|
57
|
+
|
54
58
|
== Footnotes v3.2
|
55
59
|
* Now you can easily add your own notes;
|
56
60
|
* Added numbers to tabs;
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rails-footnotes (3.6.7)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
abstract (1.0.0)
|
10
|
+
actionmailer (3.0.5)
|
11
|
+
actionpack (= 3.0.5)
|
12
|
+
mail (~> 2.2.15)
|
13
|
+
actionpack (3.0.5)
|
14
|
+
activemodel (= 3.0.5)
|
15
|
+
activesupport (= 3.0.5)
|
16
|
+
builder (~> 2.1.2)
|
17
|
+
erubis (~> 2.6.6)
|
18
|
+
i18n (~> 0.4)
|
19
|
+
rack (~> 1.2.1)
|
20
|
+
rack-mount (~> 0.6.13)
|
21
|
+
rack-test (~> 0.5.7)
|
22
|
+
tzinfo (~> 0.3.23)
|
23
|
+
activemodel (3.0.5)
|
24
|
+
activesupport (= 3.0.5)
|
25
|
+
builder (~> 2.1.2)
|
26
|
+
i18n (~> 0.4)
|
27
|
+
activerecord (3.0.5)
|
28
|
+
activemodel (= 3.0.5)
|
29
|
+
activesupport (= 3.0.5)
|
30
|
+
arel (~> 2.0.2)
|
31
|
+
tzinfo (~> 0.3.23)
|
32
|
+
activeresource (3.0.5)
|
33
|
+
activemodel (= 3.0.5)
|
34
|
+
activesupport (= 3.0.5)
|
35
|
+
activesupport (3.0.5)
|
36
|
+
arel (2.0.9)
|
37
|
+
autotest-growl (0.2.9)
|
38
|
+
builder (2.1.2)
|
39
|
+
erubis (2.6.6)
|
40
|
+
abstract (>= 1.0.0)
|
41
|
+
i18n (0.5.0)
|
42
|
+
mail (2.2.15)
|
43
|
+
activesupport (>= 2.3.6)
|
44
|
+
i18n (>= 0.4.0)
|
45
|
+
mime-types (~> 1.16)
|
46
|
+
treetop (~> 1.4.8)
|
47
|
+
mime-types (1.16)
|
48
|
+
mocha (0.9.12)
|
49
|
+
polyglot (0.3.1)
|
50
|
+
rack (1.2.2)
|
51
|
+
rack-mount (0.6.13)
|
52
|
+
rack (>= 1.0.0)
|
53
|
+
rack-test (0.5.7)
|
54
|
+
rack (>= 1.0)
|
55
|
+
rails (3.0.5)
|
56
|
+
actionmailer (= 3.0.5)
|
57
|
+
actionpack (= 3.0.5)
|
58
|
+
activerecord (= 3.0.5)
|
59
|
+
activeresource (= 3.0.5)
|
60
|
+
activesupport (= 3.0.5)
|
61
|
+
bundler (~> 1.0)
|
62
|
+
railties (= 3.0.5)
|
63
|
+
railties (3.0.5)
|
64
|
+
actionpack (= 3.0.5)
|
65
|
+
activesupport (= 3.0.5)
|
66
|
+
rake (>= 0.8.7)
|
67
|
+
thor (~> 0.14.4)
|
68
|
+
rake (0.8.7)
|
69
|
+
redgreen (1.2.2)
|
70
|
+
thor (0.14.6)
|
71
|
+
treetop (1.4.9)
|
72
|
+
polyglot (>= 0.3.1)
|
73
|
+
tzinfo (0.3.25)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
ruby
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
autotest-growl
|
80
|
+
mocha
|
81
|
+
rails (>= 3.0.5)
|
82
|
+
rails-footnotes!
|
83
|
+
redgreen
|
data/README
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
Rails Footnotes
|
2
2
|
License: MIT
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.7.0
|
4
4
|
|
5
5
|
You can also read this README in pretty html at the GitHub project Wiki page
|
6
6
|
|
7
7
|
http://wiki.github.com/josevalim/rails-footnotes
|
8
8
|
|
9
|
-
|
10
9
|
Description
|
11
10
|
-----------
|
12
11
|
|
@@ -21,28 +20,42 @@ your backtrace lines.
|
|
21
20
|
Installation
|
22
21
|
------------
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
Since this branch aims Rails 3 support, if you want to use it with Rails 2.3 you should check this branch:
|
24
|
+
|
25
|
+
https://github.com/josevalim/rails-footnotes/tree/rails2
|
26
26
|
|
27
|
-
|
27
|
+
Install Rails Footnotes is very easy.
|
28
|
+
|
29
|
+
Rails 2.x
|
28
30
|
|
29
31
|
In RAILS_ROOT/config/environments/development.rb (yes, you want it only in development):
|
30
32
|
|
31
|
-
|
33
|
+
gem "rails-footnotes", '< 3.7.0', :group => :development
|
32
34
|
|
33
|
-
|
35
|
+
Rails 3.x
|
34
36
|
|
35
|
-
|
37
|
+
gem 'rails-footnotes', '>= 3.7', :group => :development
|
36
38
|
|
37
39
|
Configuration
|
38
40
|
-------------
|
39
41
|
|
42
|
+
For version greater then 3.7.0
|
43
|
+
|
44
|
+
If you want to add alternate logic to enable or disable footnotes,
|
45
|
+
add something like this to config/initializers/footnotes.rb:
|
46
|
+
|
47
|
+
if defined?(Footnotes) & Rails.env.development?
|
48
|
+
Footnotes.run! # first of all
|
49
|
+
|
50
|
+
# ... other init code
|
51
|
+
end
|
52
|
+
|
40
53
|
If you are not using Textmate as text editor, in your environment.rb or
|
41
54
|
in an initializer do:
|
42
55
|
|
43
|
-
|
44
|
-
|
45
|
-
|
56
|
+
Footnotes::Filter.prefix = 'mvim://open?url=file://%s&line=%d&column=%d'
|
57
|
+
|
58
|
+
for MacVim
|
46
59
|
|
47
60
|
Where you are going to choose a prefix compatible with your text editor. The %s is
|
48
61
|
replaced by the name of the file, the first %d is replaced by the line number and
|
@@ -63,11 +76,6 @@ If you have New Relic RPM installed, you may want to turn off query explains
|
|
63
76
|
|
64
77
|
Footnotes::Notes::QueriesNote.sql_explain = false
|
65
78
|
|
66
|
-
If you want to add alternate logic to enable or disable footnotes,
|
67
|
-
add something like this to environment.rb:
|
68
|
-
|
69
|
-
ENABLE_RAILS_FOOTNOTES=(Rails.env.production? == false)
|
70
|
-
|
71
79
|
Finally, you can control which notes you want to show. The default are:
|
72
80
|
|
73
81
|
Footnotes::Filter.notes = [:session, :cookies, :params, :filters, :routes, :env, :queries, :log, :general]
|
@@ -95,9 +103,9 @@ For example, to create a note that shows info about the user logged in your appl
|
|
95
103
|
@current_user = controller.instance_variable_get("@current_user")
|
96
104
|
end
|
97
105
|
|
98
|
-
#
|
106
|
+
# Returns the title that represents this note.
|
99
107
|
#
|
100
|
-
def
|
108
|
+
def title
|
101
109
|
"Current user: #{@current_user.name}"
|
102
110
|
end
|
103
111
|
|
data/Rakefile
CHANGED
@@ -1,28 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
2
3
|
require 'rake/testtask'
|
3
4
|
require 'rake/rdoctask'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
Jeweler::Tasks.new do |s|
|
8
|
-
s.name = "rails-footnotes"
|
9
|
-
s.version = "3.6.7"
|
10
|
-
s.rubyforge_project = "rails-footnotes"
|
11
|
-
s.summary = "Every Rails page has footnotes that gives information about your application and links back to your editor."
|
12
|
-
s.email = "keenan@thebrocks.net"
|
13
|
-
s.homepage = "http://github.com/josevalim/rails-footnotes"
|
14
|
-
s.description = "Every Rails page has footnotes that gives information about your application and links back to your editor."
|
15
|
-
s.authors = ['Keenan Brock']
|
16
|
-
s.files = FileList["[A-Z]*", "{lib}/**/*"]
|
17
|
-
end
|
18
|
-
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
22
|
-
end
|
6
|
+
desc 'Default: run tests'
|
7
|
+
task :default => :test
|
23
8
|
|
24
9
|
desc 'Run tests for Footnotes.'
|
25
10
|
Rake::TestTask.new(:test) do |t|
|
11
|
+
t.libs << 'test'
|
26
12
|
t.pattern = 'test/**/*_test.rb'
|
27
13
|
t.verbose = true
|
28
14
|
end
|
@@ -36,14 +22,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
36
22
|
rdoc.rdoc_files.include('MIT-LICENSE')
|
37
23
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
24
|
end
|
39
|
-
|
40
|
-
begin
|
41
|
-
require 'metric_fu'
|
42
|
-
MetricFu::Configuration.run do |config|
|
43
|
-
#skipping: churn, :stats
|
44
|
-
config.metrics = [:saikuro, :flog, :flay, :reek, :roodi, :rcov]
|
45
|
-
# config.graphs = [:flog, :flay, :reek, :roodi, :rcov]
|
46
|
-
config.rcov[:rcov_opts] << "-Itest"
|
47
|
-
end
|
48
|
-
rescue LoadError
|
49
|
-
end
|
data/lib/rails-footnotes.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
end
|
4
|
-
if ENABLE_RAILS_FOOTNOTES
|
5
|
-
dir = File.dirname(__FILE__)
|
6
|
-
require File.join(dir, 'rails-footnotes', 'footnotes')
|
7
|
-
require File.join(dir, 'rails-footnotes', 'backtracer')
|
8
|
-
|
9
|
-
# Load all notes
|
10
|
-
#
|
11
|
-
Dir[File.join(dir, 'rails-footnotes', 'notes', '*.rb')].sort.each do |note|
|
12
|
-
require note
|
13
|
-
end
|
14
|
-
|
1
|
+
module Footnotes
|
2
|
+
|
15
3
|
# The footnotes are applied by default to all actions. You can change this
|
16
4
|
# behavior commenting the after_filter line below and putting it in Your
|
17
5
|
# application. Then you can cherrypick in which actions it will appear.
|
18
6
|
#
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
module RailsFootnotesExtension
|
8
|
+
def self.included(base)
|
9
|
+
base.prepend_before_filter Footnotes::BeforeFilter
|
10
|
+
base.after_filter Footnotes::AfterFilter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.run!
|
15
|
+
require 'rails-footnotes/footnotes'
|
16
|
+
require 'rails-footnotes/backtracer'
|
17
|
+
|
18
|
+
Dir[File.join(File.dirname(__FILE__), 'rails-footnotes', 'notes', '*.rb')].each { |note| require note }
|
19
|
+
|
20
|
+
ActionController::Base.send(:include, RailsFootnotesExtension)
|
22
21
|
end
|
23
22
|
end
|
@@ -9,7 +9,7 @@ module Footnotes
|
|
9
9
|
|
10
10
|
def add_links_to_backtrace(lines)
|
11
11
|
lines.collect do |line|
|
12
|
-
expanded = line.gsub('#{RAILS_ROOT}',
|
12
|
+
expanded = line.gsub('#{RAILS_ROOT}', Rails.root)
|
13
13
|
if match = expanded.match(/^(.+):(\d+):in/) || match = expanded.match(/^(.+):(\d+)\s*$/)
|
14
14
|
file = File.expand_path(match[1])
|
15
15
|
line_number = match[2]
|
@@ -31,4 +31,6 @@ module Footnotes
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
if Rails.version < '3.0'
|
35
|
+
Exception.send :include, Footnotes::Extensions::Exception
|
36
|
+
end
|
@@ -1,4 +1,21 @@
|
|
1
1
|
module Footnotes
|
2
|
+
class BeforeFilter
|
3
|
+
# Method called to start the notes
|
4
|
+
# It's a before filter prepend in the controller
|
5
|
+
def self.filter(controller)
|
6
|
+
Footnotes::Filter.start!(controller)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class AfterFilter
|
11
|
+
# Method that calls Footnotes to attach its contents
|
12
|
+
def self.filter(controller)
|
13
|
+
filter = Footnotes::Filter.new(controller)
|
14
|
+
filter.add_footnotes!
|
15
|
+
filter.close!(controller)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
2
19
|
class Filter
|
3
20
|
@@no_style = false
|
4
21
|
@@multiple_notes = false
|
@@ -25,20 +42,6 @@ module Footnotes
|
|
25
42
|
cattr_accessor :no_style, :notes, :prefix, :multiple_notes
|
26
43
|
|
27
44
|
class << self
|
28
|
-
# Method called to start the notes
|
29
|
-
# It's a before filter prepend in the controller
|
30
|
-
#
|
31
|
-
def before(controller)
|
32
|
-
Footnotes::Filter.start!(controller)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Method that calls Footnotes to attach its contents
|
36
|
-
#
|
37
|
-
def after(controller)
|
38
|
-
filter = Footnotes::Filter.new(controller)
|
39
|
-
filter.add_footnotes!
|
40
|
-
filter.close!(controller)
|
41
|
-
end
|
42
45
|
|
43
46
|
# Calls the class method start! in each note
|
44
47
|
# Sometimes notes need to set variables or clean the environment to work properly
|
@@ -77,7 +80,7 @@ module Footnotes
|
|
77
80
|
# Logs the error using specified title and format
|
78
81
|
#
|
79
82
|
def log_error(title, exception)
|
80
|
-
|
83
|
+
Rails.logger.error "#{title}: #{exception}\n#{exception.backtrace.join("\n")}"
|
81
84
|
end
|
82
85
|
|
83
86
|
# If none argument is sent, simply return the prefix.
|
@@ -138,11 +141,24 @@ module Footnotes
|
|
138
141
|
end
|
139
142
|
|
140
143
|
def performed_render?
|
141
|
-
@controller.instance_variable_get(:@performed_render)
|
144
|
+
@controller.instance_variable_get(:@performed_render) || # rails 2.x
|
145
|
+
(@controller.respond_to?(:performed?) && @controller.performed?) # rails3, will break on redirect??
|
142
146
|
end
|
143
147
|
|
144
148
|
def valid_format?
|
145
|
-
|
149
|
+
if @template # Rails 2.x
|
150
|
+
[:html,:rhtml,:xhtml,:rxhtml].include?(@template.send(template_format_method.to_sym).to_sym)
|
151
|
+
else # Rails 3
|
152
|
+
@controller.response.content_type == 'text/html'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def template_format_method
|
157
|
+
if @template.respond_to?(:template_format)
|
158
|
+
return 'template_format'
|
159
|
+
else
|
160
|
+
return 'format'
|
161
|
+
end
|
146
162
|
end
|
147
163
|
|
148
164
|
def valid_content_type?
|
@@ -167,17 +183,18 @@ module Footnotes
|
|
167
183
|
#
|
168
184
|
|
169
185
|
def insert_styles
|
186
|
+
#TODO More customizable(reset.css, from file etc.)
|
170
187
|
insert_text :before, /<\/head>/i, <<-HTML
|
171
188
|
<!-- Footnotes Style -->
|
172
189
|
<style type="text/css">
|
173
|
-
#footnotes_debug {margin: 2em 0 1em 0; text-align: center; color: #444; line-height: 16px;}
|
190
|
+
#footnotes_debug {font-size: 11px; font-weight: normal; margin: 2em 0 1em 0; text-align: center; color: #444; line-height: 16px;}
|
174
191
|
#footnotes_debug th, #footnotes_debug td {color: #444; line-height: 18px;}
|
175
|
-
#footnotes_debug a {
|
192
|
+
#footnotes_debug a {color: #9b1b1b; font-weight: inherit; text-decoration: none; line-height: 18px;}
|
176
193
|
#footnotes_debug table {text-align: center;}
|
177
194
|
#footnotes_debug table td {padding: 0 5px;}
|
178
195
|
#footnotes_debug tbody {text-align: left;}
|
179
196
|
#footnotes_debug .name_values td {vertical-align: top;}
|
180
|
-
#footnotes_debug legend {background-color: #
|
197
|
+
#footnotes_debug legend {background-color: #fff;}
|
181
198
|
#footnotes_debug fieldset {text-align: left; border: 1px dashed #aaa; padding: 0.5em 1em 1em 1em; margin: 1em 2em; color: #444; background-color: #FFF;}
|
182
199
|
/* Aditional Stylesheets */
|
183
200
|
#{@notes.map(&:stylesheet).compact.join("\n")}
|
@@ -242,7 +259,7 @@ module Footnotes
|
|
242
259
|
HTML
|
243
260
|
|
244
261
|
placeholder = /<div[^>]+id=['"]footnotes_holder['"][^>]*>/i
|
245
|
-
if @body =~ placeholder
|
262
|
+
if @controller.response.body =~ placeholder
|
246
263
|
insert_text :after, placeholder, footnotes_html
|
247
264
|
else
|
248
265
|
insert_text :before, /<\/body>/i, footnotes_html
|
@@ -325,15 +342,17 @@ module Footnotes
|
|
325
342
|
def insert_text(position, pattern, new_text)
|
326
343
|
index = case pattern
|
327
344
|
when Regexp
|
328
|
-
if match = @body.match(pattern)
|
345
|
+
if match = @controller.response.body.match(pattern)
|
329
346
|
match.offset(0)[position == :before ? 0 : 1]
|
330
347
|
else
|
331
|
-
@body.size
|
348
|
+
@controller.response.body.size
|
332
349
|
end
|
333
350
|
else
|
334
351
|
pattern
|
335
352
|
end
|
336
|
-
@body
|
353
|
+
newbody = @controller.response.body
|
354
|
+
newbody.insert index, new_text
|
355
|
+
@controller.response.body = newbody
|
337
356
|
end
|
338
357
|
|
339
358
|
# Instance each_with_rescue method
|
@@ -36,7 +36,7 @@ module Footnotes
|
|
36
36
|
end
|
37
37
|
#raise "File not found"
|
38
38
|
else
|
39
|
-
@controller_filename=File.join(File.expand_path(
|
39
|
+
@controller_filename=File.join(File.expand_path(Rails.root), 'app', 'controllers', "#{controller_name}.rb").sub('/controllers/controllers/', '/controllers/')
|
40
40
|
end
|
41
41
|
@controller_filename
|
42
42
|
end
|
@@ -32,7 +32,7 @@ module Footnotes
|
|
32
32
|
def parse_files!
|
33
33
|
@files.collect! do |filename|
|
34
34
|
if filename =~ %r{^/}
|
35
|
-
full_filename = File.join(File.expand_path(
|
35
|
+
full_filename = File.join(File.expand_path(Rails.root), 'public', filename)
|
36
36
|
%[<a href="#{Footnotes::Filter.prefix(full_filename, 1, 1)}">#{filename}</a>]
|
37
37
|
else
|
38
38
|
%[<a href="#{filename}">#{filename}</a>]
|
@@ -20,9 +20,9 @@ module Footnotes
|
|
20
20
|
# Get controller filter chain
|
21
21
|
#
|
22
22
|
def parse_filters
|
23
|
-
return @controller.class.filter_chain.collect do |filter|
|
24
|
-
[parse_method(filter.method), filter.type.inspect, controller_filtered_actions(filter).inspect]
|
25
|
-
end
|
23
|
+
return [] # TODO @controller.class.filter_chain.collect do |filter|
|
24
|
+
# [parse_method(filter.method), filter.type.inspect, controller_filtered_actions(filter).inspect]
|
25
|
+
# end
|
26
26
|
end
|
27
27
|
|
28
28
|
# This receives a filter, creates a mock controller and check in which
|
@@ -16,12 +16,12 @@ module Footnotes
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def valid?
|
19
|
-
prefix? &&
|
19
|
+
prefix? && nil#@controller.active_layout TODO doesn't work with Rails 3
|
20
20
|
end
|
21
21
|
|
22
22
|
protected
|
23
23
|
def filename
|
24
|
-
File.join(File.expand_path(
|
24
|
+
File.join(File.expand_path(Rails.root), 'app', 'layouts', "#{@controller.active_layout.to_s.underscore}").sub('/layouts/layouts/', '/views/layouts/')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -25,7 +25,7 @@ module Footnotes
|
|
25
25
|
unless @log
|
26
26
|
@log = @@log.join('')
|
27
27
|
@@log = []
|
28
|
-
if rindex = @log.rindex('Processing '+@controller.
|
28
|
+
if rindex = @log.rindex('Processing '+@controller.class.name+'#'+@controller.action_name)
|
29
29
|
@log = @log[rindex..-1]
|
30
30
|
end
|
31
31
|
end
|
@@ -16,7 +16,7 @@ module Footnotes
|
|
16
16
|
def content
|
17
17
|
rows = partials.map do |filename|
|
18
18
|
href = Footnotes::Filter.prefix(filename,1,1)
|
19
|
-
shortened_name=filename.gsub(File.join(
|
19
|
+
shortened_name=filename.gsub(File.join(Rails.root,"app/views/"),"")
|
20
20
|
[%{<a href="#{href}">#{shortened_name}</a>},"#{@partial_times[filename].sum}ms",@partial_counts[filename]]
|
21
21
|
end
|
22
22
|
mount_table(rows.unshift(%w(Partial Time Count)), :summary => "Partials for #{title}")
|
@@ -71,7 +71,7 @@ module Footnotes
|
|
71
71
|
ActiveRecord::ConnectionAdapters::AbstractAdapter.send :include, Footnotes::Extensions::AbstractAdapter
|
72
72
|
ActiveRecord::ConnectionAdapters.local_constants.each do |adapter|
|
73
73
|
next unless adapter =~ /.*[^Abstract]Adapter$/
|
74
|
-
next if adapter =~ /
|
74
|
+
next if adapter =~ /(SQLite|Salesforce)Adapter$/
|
75
75
|
eval("ActiveRecord::ConnectionAdapters::#{adapter}").send :include, Footnotes::Extensions::QueryAnalyzer
|
76
76
|
self.loaded = true
|
77
77
|
end
|
@@ -91,7 +91,7 @@ module Footnotes
|
|
91
91
|
def parse_trace(trace)
|
92
92
|
trace.map do |t|
|
93
93
|
s = t.split(':')
|
94
|
-
%[<a href="#{escape(Footnotes::Filter.prefix("#{
|
94
|
+
%[<a href="#{escape(Footnotes::Filter.prefix("#{Rails.root.to_s}/#{s[0]}", s[1].to_i, 1))}">#{escape(t)}</a><br />]
|
95
95
|
end.join
|
96
96
|
end
|
97
97
|
|
@@ -136,7 +136,7 @@ module Footnotes
|
|
136
136
|
|
137
137
|
# Strip, select those ones from app and reject first two, because they
|
138
138
|
# are from the plugin
|
139
|
-
@trace = Kernel.caller.collect(&:strip).select{|i| i.gsub!(/^#{
|
139
|
+
@trace = Kernel.caller.collect(&:strip).select{|i| i.gsub!(/^#{Rails.root}\//im, '') }[2..-1]
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
@@ -18,21 +18,25 @@ module Footnotes
|
|
18
18
|
|
19
19
|
protected
|
20
20
|
def parse_routes
|
21
|
-
routes_with_name =
|
21
|
+
routes_with_name = Rails.application.routes.named_routes.to_a.flatten
|
22
22
|
|
23
|
-
return
|
23
|
+
return Rails.application.routes.filtered_routes(:controller => @controller.controller_path).collect do |route|
|
24
24
|
# Catch routes name if exists
|
25
25
|
i = routes_with_name.index(route)
|
26
26
|
name = i ? routes_with_name[i-1].to_s : ''
|
27
27
|
|
28
28
|
# Catch segments requirements
|
29
29
|
req = {}
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if Rails.version < '3.0'
|
31
|
+
route.segments.each do |segment|
|
32
|
+
next unless segment.is_a?(ActionController::Routing::DynamicSegment) && segment.regexp
|
33
|
+
req[segment.key.to_sym] = segment.regexp
|
34
|
+
end
|
35
|
+
[escape(name), route.segments.join, route.requirements.reject{|key,value| key == :controller}.inspect, req.inspect]
|
36
|
+
else
|
37
|
+
req = route.conditions
|
38
|
+
[escape(name), route.conditions.keys.join, route.requirements.reject{|key,value| key == :controller}.inspect, req.inspect]
|
33
39
|
end
|
34
|
-
|
35
|
-
[escape(name), route.segments.join, route.requirements.reject{|key,value| key == :controller}.inspect, req.inspect]
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rails-footnotes/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rails-footnotes"
|
7
|
+
s.version = Footnotes::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Keenan Brock"]
|
10
|
+
s.email = ["keenan@thebrocks.net"]
|
11
|
+
s.homepage = "http://github.com/josevalim/rails-footnotes"
|
12
|
+
s.summary = %q{Every Rails page has footnotes that gives information about your application and links back to your editor.}
|
13
|
+
s.description = %q{Every Rails page has footnotes that gives information about your application and links back to your editor.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "rails-footnotes"
|
16
|
+
|
17
|
+
s.add_dependency "rails", ">= 3.0.0"
|
18
|
+
|
19
|
+
s.add_development_dependency "autotest"
|
20
|
+
s.add_development_dependency "redgreen"
|
21
|
+
s.add_development_dependency "mocha"
|
22
|
+
s.add_development_dependency "rails", ">= 3.0.0"
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
end
|
29
|
+
|
data/test/footnotes_test.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
require 'action_controller'
|
4
4
|
require 'action_controller/test_case'
|
5
|
-
require 'action_controller/test_process'
|
6
5
|
|
7
6
|
class FootnotesController < ActionController::Base; attr_accessor :template, :performed_render; end
|
8
7
|
|
@@ -20,6 +19,7 @@ class FootnotesTest < Test::Unit::TestCase
|
|
20
19
|
@controller.request = ActionController::TestRequest.new
|
21
20
|
@controller.response = ActionController::TestResponse.new
|
22
21
|
@controller.response.body = $html.dup
|
22
|
+
@controller.params = {}
|
23
23
|
|
24
24
|
Footnotes::Filter.notes = [ :test ]
|
25
25
|
Footnotes::Filter.multiple_notes = false
|
@@ -81,8 +81,8 @@ class FootnotesTest < Test::Unit::TestCase
|
|
81
81
|
def test_notes_are_initialized
|
82
82
|
footnotes_perform!
|
83
83
|
test_note = @footnotes.instance_variable_get('@notes').first
|
84
|
-
|
85
|
-
|
84
|
+
assert_equal 'Footnotes::Notes::TestNote', test_note.class.name
|
85
|
+
assert_equal :test, test_note.to_sym
|
86
86
|
end
|
87
87
|
|
88
88
|
def test_notes_links
|
@@ -173,12 +173,20 @@ class FootnotesTest < Test::Unit::TestCase
|
|
173
173
|
# Then we call add_footnotes!
|
174
174
|
#
|
175
175
|
def footnotes_perform!
|
176
|
-
|
176
|
+
template_expects('html')
|
177
177
|
@controller.performed_render = true
|
178
178
|
|
179
179
|
Footnotes::Filter.start!(@controller)
|
180
180
|
@footnotes.add_footnotes!
|
181
181
|
end
|
182
|
+
|
183
|
+
def template_expects(format)
|
184
|
+
if @controller.template.respond_to?(:template_format)
|
185
|
+
@controller.template.expects(:template_format).returns(format)
|
186
|
+
else
|
187
|
+
@controller.template.expects(:format).returns(format)
|
188
|
+
end
|
189
|
+
end
|
182
190
|
end
|
183
191
|
|
184
192
|
$html = <<HTML
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class AbstractNoteTest < Test::Unit::TestCase
|
4
4
|
def setup
|
@@ -78,7 +78,7 @@ class AbstractNoteTest < Test::Unit::TestCase
|
|
78
78
|
assert_equal '', @note.send(:mount_table,[['h1','h2','h3']], :class => 'table')
|
79
79
|
|
80
80
|
tab = <<-TABLE
|
81
|
-
<table class="table">
|
81
|
+
<table class="table" >
|
82
82
|
<thead><tr><th>H1</th></tr></thead>
|
83
83
|
<tbody><tr><td>r1c1</td></tr></tbody>
|
84
84
|
</table>
|
data/test/test_helper.rb
CHANGED
@@ -5,5 +5,6 @@ require 'mocha'
|
|
5
5
|
ENV['RAILS_ENV'] = 'test'
|
6
6
|
|
7
7
|
require 'active_support'
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require 'active_support/all' unless Class.respond_to?(:cattr_accessor)
|
9
|
+
require 'rails-footnotes/footnotes'
|
10
|
+
require 'rails-footnotes/notes/abstract_note'
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-footnotes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 3
|
8
|
-
- 6
|
9
|
-
- 7
|
10
|
-
version: 3.6.7
|
4
|
+
prerelease:
|
5
|
+
version: 3.7.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Keenan Brock
|
@@ -15,20 +10,78 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-03-19 00:00:00 +02:00
|
19
14
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rails
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.0.0
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: autotest
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: redgreen
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: mocha
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rails
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
22
71
|
description: Every Rails page has footnotes that gives information about your application and links back to your editor.
|
23
|
-
email:
|
72
|
+
email:
|
73
|
+
- keenan@thebrocks.net
|
24
74
|
executables: []
|
25
75
|
|
26
76
|
extensions: []
|
27
77
|
|
28
|
-
extra_rdoc_files:
|
29
|
-
|
78
|
+
extra_rdoc_files: []
|
79
|
+
|
30
80
|
files:
|
81
|
+
- .gitignore
|
31
82
|
- CHANGELOG
|
83
|
+
- Gemfile
|
84
|
+
- Gemfile.lock
|
32
85
|
- MIT-LICENSE
|
33
86
|
- README
|
34
87
|
- Rakefile
|
@@ -54,6 +107,8 @@ files:
|
|
54
107
|
- lib/rails-footnotes/notes/session_note.rb
|
55
108
|
- lib/rails-footnotes/notes/stylesheets_note.rb
|
56
109
|
- lib/rails-footnotes/notes/view_note.rb
|
110
|
+
- lib/rails-footnotes/version.rb
|
111
|
+
- rails-footnotes.gemspec
|
57
112
|
- test/footnotes_test.rb
|
58
113
|
- test/notes/abstract_note_test.rb
|
59
114
|
- test/test_helper.rb
|
@@ -62,8 +117,8 @@ homepage: http://github.com/josevalim/rails-footnotes
|
|
62
117
|
licenses: []
|
63
118
|
|
64
119
|
post_install_message:
|
65
|
-
rdoc_options:
|
66
|
-
|
120
|
+
rdoc_options: []
|
121
|
+
|
67
122
|
require_paths:
|
68
123
|
- lib
|
69
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -71,23 +126,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
126
|
requirements:
|
72
127
|
- - ">="
|
73
128
|
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
|
-
segments:
|
76
|
-
- 0
|
77
129
|
version: "0"
|
78
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
131
|
none: false
|
80
132
|
requirements:
|
81
133
|
- - ">="
|
82
134
|
- !ruby/object:Gem::Version
|
83
|
-
hash: 3
|
84
|
-
segments:
|
85
|
-
- 0
|
86
135
|
version: "0"
|
87
136
|
requirements: []
|
88
137
|
|
89
138
|
rubyforge_project: rails-footnotes
|
90
|
-
rubygems_version: 1.
|
139
|
+
rubygems_version: 1.5.0
|
91
140
|
signing_key:
|
92
141
|
specification_version: 3
|
93
142
|
summary: Every Rails page has footnotes that gives information about your application and links back to your editor.
|