Class: Footnotes::Notes::EnvNote

Inherits:
AbstractNote show all
Defined in:
lib/sinatra-footnotes/notes/env_note.rb

Instance Method Summary collapse

Methods inherited from AbstractNote

close!, #has_fieldset?, included?, #javascript, #legend, #link, #onclick, #row, start!, #stylesheet, #title, title, #to_sym, to_sym, #valid?

Constructor Details

#initialize(controller) ⇒ EnvNote

Returns a new instance of EnvNote.



6
7
8
# File 'lib/sinatra-footnotes/notes/env_note.rb', line 6

def initialize(controller)
  @env = controller.request.env.dup
end

Instance Method Details

#contentObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sinatra-footnotes/notes/env_note.rb', line 10

def content
  env_data = @env.to_a.sort.unshift([:key, :value]).map do |k,v|
    case k
    when 'HTTP_COOKIE'
      # Replace HTTP_COOKIE for a link
      [k, '<a href="#" style="color:#009" onclick="Footnotes.hideAllAndToggle(\'cookies_debug_info\');return false;">See cookies on its tab</a>']
    else
      [k, escape(v.to_s)]
    end
  end

  # Create the env table
  mount_table(env_data)
end