rails-footnotes 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2cef699250d373d045cef743a70b3f49c46fc82c
4
+ data.tar.gz: e6143856c34a3ae3201a9f0e2ba503b8caecade8
5
+ SHA512:
6
+ metadata.gz: afb6c7f76465de26af156ee3bce87b54942fd499b3c8c5615b9029406cc517e27385e428bda91784e75eac6fb35029fa4bd9ea3c3ad9be5d15252eda82df5249
7
+ data.tar.gz: ee1985e69b29e36833dce2dfa455334ff8a981ea9f171a54c2ff5f81de52a8f07616a9fa59c38919ba7e6d23b2a10129ce23c2bffa1cdb90668f3e4fdda3d79c
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == Footnotes v4.0.1
2
+ * Fix bad count for log note
3
+ * More robust initializer (thanks kayhide)
4
+ * Ability to lock the notes on the top right instead of the footer (thanks joshuapaling)
5
+ * More readable notes (thanks joshuapaling)
1
6
  == Footnotes v4.0.0
2
7
  * Drop support for ruby 1.8
3
8
  * Drop support for rails < 3.2
@@ -10,7 +10,7 @@ your backtrace lines.
10
10
 
11
11
  == Installation
12
12
 
13
- NOTE: Since this branch aims Rails 3.2+ support, if you want to use footnotes with Rails 2.3 you should use this branch:
13
+ NOTE: Since this branch aims for Rails 3.2+ support, if you want to use footnotes with Rails 2.3 you should use this branch:
14
14
 
15
15
  https://github.com/josevalim/rails-footnotes/tree/rails2
16
16
 
@@ -36,9 +36,9 @@ This will create an initializer with default config and some examples.
36
36
  controller.action_name == 'edit' }
37
37
  end
38
38
 
39
- === Editors links
39
+ === Editor links
40
40
 
41
- If you are not using Textmate as text editor, MacVim and Sublime Text 2 are also compatible.
41
+ Textmate, MacVim and Sublime Text 2 are compatible.
42
42
 
43
43
  *MacVim*
44
44
 
@@ -46,9 +46,9 @@ In the rails-footnotes initializer do :
46
46
 
47
47
  f.prefix = 'mvim://open?url=file://%s&line=%d&column=%d'
48
48
 
49
- Where you are going to choose a prefix compatible with your text editor. The %s is
49
+ Here you need to choose a prefix compatible with your text editor. The %s is
50
50
  replaced by the name of the file, the first %d is replaced by the line number and
51
- the second %d is replaced by the column.
51
+ the second %d is replaced by the column number.
52
52
 
53
53
  Take note that the order in which the file name (%s), line number (%d) and column number (%d) appears is important.
54
54
  We assume that they appear in that order. "foo://line=%d&file=%s" (%d precedes %s) would throw out an error.
@@ -74,6 +74,15 @@ by turning footnotes stylesheet off:
74
74
 
75
75
  f.no_style = true
76
76
 
77
+ You can also lock the footnotes to the top of the window, hidden by default, and accessible
78
+ via a small button fixed to the top-right of your browser:
79
+
80
+ f.lock_top_right = true
81
+
82
+ To set the font-size for the footnotes:
83
+
84
+ f.font_size = '13px'
85
+
77
86
  Another option is to allow multiple notes to be opened at the same time:
78
87
 
79
88
  f.multiple_notes = true
@@ -87,7 +96,7 @@ Finally, you can control which notes you want to show. The default are:
87
96
  Creating your notes to integrate with Footnotes is easy.
88
97
 
89
98
  1. Create a Footnotes::Notes::YourExampleNote class
90
- 2. Implement the necessary methods (check abstract_note.rb file in lib/notes)
99
+ 2. Implement the necessary methods (check abstract_note.rb[link:lib/rails-footnotes/abstract_note.rb] file in lib/rails-footnotes)
91
100
  3. Append your example note in Footnotes::Filter.notes array (usually at the end of your environment file or in the initializer):
92
101
 
93
102
  For example, to create a note that shows info about the user logged in your application you just have to do:
@@ -127,10 +136,10 @@ Then put in your environment, add in your initializer:
127
136
 
128
137
  f.notes += [:current_user]
129
138
 
130
- == Display of the notes
139
+ == Footnote position
131
140
 
132
141
  By default the notes will be showed at the bottom of your page (appended just before </body>).
133
- If you'd like these notes on a different place (perhaps for aesthetical reasons) you can edit one of your views and add:
142
+ If you'd like the footnote, to be at a different place (perhaps for aesthetical reasons) you can edit one of your views and add:
134
143
  <div id="footnotes_holder"></div>
135
144
  at an appropriate place, your notes will now appear inside div#footnotes_holder
136
145
 
@@ -1,4 +1,4 @@
1
- Footnotes.setup do |f|
1
+ defined?(Footnotes) && Footnotes.setup do |f|
2
2
  # Wether or not to enable footnotes
3
3
  f.enabled = Rails.env.development?
4
4
  # You can also use a lambda / proc to conditionally toggle footnotes
@@ -16,6 +16,12 @@ Footnotes.setup do |f|
16
16
  # Disable style :
17
17
  # f.no_style = true
18
18
 
19
+ # Lock notes to top right :
20
+ # f.lock_top_right = true
21
+
22
+ # Change font size :
23
+ # f.font_size = '11px'
24
+
19
25
  # Allow to open multiple notes :
20
26
  # f.multiple_notes = true
21
27
  end
@@ -29,6 +29,12 @@ module Footnotes
29
29
 
30
30
  delegate :multiple_notes, :to => Filter
31
31
  delegate :multiple_notes=, :to => Filter
32
+
33
+ delegate :lock_top_right, :to => Filter
34
+ delegate :lock_top_right=, :to => Filter
35
+
36
+ delegate :font_size, :to => Filter
37
+ delegate :font_size=, :to => Filter
32
38
  end
33
39
 
34
40
  def self.run!
@@ -3,6 +3,8 @@ module Footnotes
3
3
  @@no_style = false
4
4
  @@multiple_notes = false
5
5
  @@klasses = []
6
+ @@lock_top_right = false
7
+ @@font_size = '11px'
6
8
 
7
9
  # Default link prefix is textmate
8
10
  @@prefix = 'txmt://open?url=file://%s&amp;line=%d&amp;column=%d'
@@ -16,7 +18,9 @@ module Footnotes
16
18
  # :notes => Class variable that holds the notes to be processed
17
19
  # :prefix => Prefix appended to FootnotesLinks
18
20
  # :multiple_notes => Set to true if you want to open several notes at the same time
19
- cattr_accessor :no_style, :notes, :prefix, :multiple_notes
21
+ # :lock_top_right => Lock a btn to toggle notes to the top right of the browser
22
+ # :font_size => CSS font-size property
23
+ cattr_accessor :no_style, :notes, :prefix, :multiple_notes, :lock_top_right, :font_size
20
24
 
21
25
  class << self
22
26
  include Footnotes::EachWithRescue
@@ -136,18 +140,34 @@ module Footnotes
136
140
 
137
141
  def insert_styles
138
142
  #TODO More customizable(reset.css, from file etc.)
143
+ if @@lock_top_right
144
+ extra_styles = <<-STYLES
145
+ #footnotes_debug {position: fixed; top: 0px; right: 0px; width: 100%; z-index: 10000; margin-top: 0;}
146
+ #footnotes_debug #toggle_footnotes {position: absolute; right: 0; top: 0; background: #fff; border: 1px solid #ccc; color: #9b1b1b; font-size: 20px; text-align: center; padding: 8px; opacity: 0.9;}
147
+ #footnotes_debug #toggle_footnotes:hover {opacity: 1;}
148
+ #footnotes_debug #all_footnotes {display: none; padding: 15px; background: #fff; box-shadow: 0 0 5px rgba(0,0,0,0.4);}
149
+ #footnotes_debug fieldset > div {max-height: 500px; overflow: scroll;}
150
+ STYLES
151
+ else
152
+ extra_styles = <<-STYLES
153
+ #footnotes_debug #toggle_footnotes {display: none;}
154
+ STYLES
155
+ end
139
156
  insert_text :before, /<\/head>/i, <<-HTML
140
157
  <!-- Footnotes Style -->
141
158
  <style type="text/css">
142
- #footnotes_debug {font-size: 11px; font-weight: normal; margin: 2em 0 1em 0; text-align: center; color: #444; line-height: 16px;}
159
+ #footnotes_debug {font-size: #{@@font_size}; font-family: Consolas, monaco, monospace; font-weight: normal; margin: 2em 0 1em 0; text-align: center; color: #444; line-height: 16px; background: #fff;}
143
160
  #footnotes_debug th, #footnotes_debug td {color: #444; line-height: 18px;}
144
161
  #footnotes_debug a {color: #9b1b1b; font-weight: inherit; text-decoration: none; line-height: 18px;}
145
- #footnotes_debug table {text-align: center;}
146
- #footnotes_debug table td {padding: 0 5px;}
162
+ #footnotes_debug table {text-align: left; width: 100%;table-layout: fixed;}
163
+ #footnotes_debug table td {padding: 5px; border-bottom: 1px solid #ccc;}
164
+ #footnotes_debug table th {padding: 5px; border-bottom: 1px solid #ccc;}
165
+ #footnotes_debug table tr:nth-child(2n) td {background: #eee;}
147
166
  #footnotes_debug tbody {text-align: left;}
148
167
  #footnotes_debug .name_values td {vertical-align: top;}
149
168
  #footnotes_debug legend {background-color: #fff;}
150
169
  #footnotes_debug fieldset {text-align: left; border: 1px dashed #aaa; padding: 0.5em 1em 1em 1em; margin: 1em 2em; color: #444; background-color: #FFF;}
170
+ #{extra_styles}
151
171
  /* Aditional Stylesheets */
152
172
  #{@notes.map(&:stylesheet).compact.join("\n")}
153
173
  </style>
@@ -158,13 +178,19 @@ module Footnotes
158
178
  def insert_footnotes
159
179
  # Fieldsets method should be called first
160
180
  content = fieldsets
161
-
181
+ element_style = ''
182
+ if @@lock_top_right
183
+ element_style = 'style="display: none;"'
184
+ end
162
185
  footnotes_html = <<-HTML
163
186
  <!-- Footnotes -->
164
187
  <div style="clear:both"></div>
165
188
  <div id="footnotes_debug">
166
- #{links}
167
- #{content}
189
+ <a id="toggle_footnotes" href="#" onclick="Footnotes.toggle('all_footnotes'); return false;">fn</a>
190
+ <div id="all_footnotes" #{element_style}>
191
+ #{links}
192
+ #{content}
193
+ </div>
168
194
  <script type="text/javascript">
169
195
  var Footnotes = function() {
170
196
 
@@ -19,18 +19,22 @@ module Footnotes
19
19
  end
20
20
 
21
21
  def title
22
- "Log (#{log.count("\n")})"
22
+ "Log (#{log.count})"
23
23
  end
24
24
 
25
25
  def content
26
- result = escape(log.gsub(/\e\[.+?m/, '')).gsub("\n", '<br />')
26
+ result = '<table>'
27
+ log.each do |l|
28
+ result << "<tr><td>#{l.gsub(/\e\[.+?m/, '')}</td></tr>"
29
+ end
30
+ result << '</table>'
27
31
  # Restore formatter
28
32
  Rails.logger = self.class.original_logger
29
33
  result
30
34
  end
31
35
 
32
36
  def log
33
- self.class.logs.join("\n")
37
+ self.class.logs
34
38
  end
35
39
 
36
40
  end
@@ -33,18 +33,25 @@ module Footnotes
33
33
  end
34
34
 
35
35
  def content
36
- html = ''
36
+ html = '<table>'
37
37
  self.events.each_with_index do |event, index|
38
38
  sql_links = []
39
39
  sql_links << "<a href=\"javascript:Footnotes.toggle('qtrace_#{index}')\" style=\"color:#00A;\">trace</a>"
40
40
 
41
41
  html << <<-HTML
42
- <b id="qtitle_#{index}">#{escape(event.type.to_s.upcase)}</b> (#{sql_links.join(' | ')})<br />
43
- <span id="sql_#{index}">#{print_query(event.payload[:sql])}</span><br />
44
- #{print_name_and_time(event.payload[:name], event.duration / 1000.0)}&nbsp;
45
- <p id="qtrace_#{index}" style="display:none;">#{parse_trace(event.trace)}</p><br />
42
+ <tr>
43
+ <td>
44
+ <b id="qtitle_#{index}">#{escape(event.type.to_s.upcase)}</b> (#{sql_links.join(' | ')})
45
+ <p id="qtrace_#{index}" style="display:none;">#{parse_trace(event.trace)}</p><br />
46
+ </td>
47
+ <td>
48
+ <span id="sql_#{index}">#{print_query(event.payload[:sql])}</span>
49
+ </td>
50
+ <td>#{print_name_and_time(event.payload[:name], event.duration / 1000.0)}</td>
51
+ </tr>
46
52
  HTML
47
53
  end
54
+ html << '</table>'
48
55
  return html
49
56
  end
50
57
 
@@ -1,3 +1,3 @@
1
1
  module Footnotes
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
5
- prerelease:
4
+ version: 4.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Roman V. Babenko
@@ -13,54 +12,48 @@ authors:
13
12
  autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
- date: 2014-03-23 00:00:00.000000000 Z
15
+ date: 2014-05-13 00:00:00.000000000 Z
17
16
  dependencies:
18
17
  - !ruby/object:Gem::Dependency
19
18
  name: rails
20
19
  requirement: !ruby/object:Gem::Requirement
21
- none: false
22
20
  requirements:
23
- - - ! '>='
21
+ - - '>='
24
22
  - !ruby/object:Gem::Version
25
23
  version: '3.2'
26
24
  type: :runtime
27
25
  prerelease: false
28
26
  version_requirements: !ruby/object:Gem::Requirement
29
- none: false
30
27
  requirements:
31
- - - ! '>='
28
+ - - '>='
32
29
  - !ruby/object:Gem::Version
33
30
  version: '3.2'
34
31
  - !ruby/object:Gem::Dependency
35
32
  name: rspec-rails
36
33
  requirement: !ruby/object:Gem::Requirement
37
- none: false
38
34
  requirements:
39
- - - ! '>='
35
+ - - '>='
40
36
  - !ruby/object:Gem::Version
41
37
  version: '0'
42
38
  type: :development
43
39
  prerelease: false
44
40
  version_requirements: !ruby/object:Gem::Requirement
45
- none: false
46
41
  requirements:
47
- - - ! '>='
42
+ - - '>='
48
43
  - !ruby/object:Gem::Version
49
44
  version: '0'
50
45
  - !ruby/object:Gem::Dependency
51
46
  name: capybara
52
47
  requirement: !ruby/object:Gem::Requirement
53
- none: false
54
48
  requirements:
55
- - - ! '>='
49
+ - - '>='
56
50
  - !ruby/object:Gem::Version
57
51
  version: '0'
58
52
  type: :development
59
53
  prerelease: false
60
54
  version_requirements: !ruby/object:Gem::Requirement
61
- none: false
62
55
  requirements:
63
- - - ! '>='
56
+ - - '>='
64
57
  - !ruby/object:Gem::Version
65
58
  version: '0'
66
59
  description: Every Rails page has footnotes that gives information about your application
@@ -127,27 +120,26 @@ files:
127
120
  - spec/views/partials/index.html.erb
128
121
  homepage: http://github.com/josevalim/rails-footnotes
129
122
  licenses: []
123
+ metadata: {}
130
124
  post_install_message:
131
125
  rdoc_options: []
132
126
  require_paths:
133
127
  - lib
134
128
  required_ruby_version: !ruby/object:Gem::Requirement
135
- none: false
136
129
  requirements:
137
- - - ! '>='
130
+ - - '>='
138
131
  - !ruby/object:Gem::Version
139
132
  version: '0'
140
133
  required_rubygems_version: !ruby/object:Gem::Requirement
141
- none: false
142
134
  requirements:
143
- - - ! '>='
135
+ - - '>='
144
136
  - !ruby/object:Gem::Version
145
137
  version: '0'
146
138
  requirements: []
147
139
  rubyforge_project: rails-footnotes
148
- rubygems_version: 1.8.23
140
+ rubygems_version: 2.2.2
149
141
  signing_key:
150
- specification_version: 3
142
+ specification_version: 4
151
143
  summary: Every Rails page has footnotes that gives information about your application
152
144
  and links back to your editor.
153
145
  test_files:
@@ -165,3 +157,4 @@ test_files:
165
157
  - spec/spec_helper.rb
166
158
  - spec/views/partials/_foo.html.erb
167
159
  - spec/views/partials/index.html.erb
160
+ has_rdoc: