Class: TuneupController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/tuneup_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.request_forgery_protection_optionsObject



9
10
11
12
13
# File 'lib/tuneup_controller.rb', line 9

def self.request_forgery_protection_options
  ApplicationController.request_forgery_protection_options || {}
rescue
  Hash.new
end

Instance Method Details

#assetObject



74
75
76
77
78
79
80
# File 'lib/tuneup_controller.rb', line 74

def asset
  filename = File.basename(params[:file])
  if filename =~ /css$/
    response.content_type = 'text/css'
  end
  send_file File.join(File.dirname(__FILE__) << "/../assets/#{filename}")
end

#offObject



86
87
88
# File 'lib/tuneup_controller.rb', line 86

def off
  collect false
end

#onObject



82
83
84
# File 'lib/tuneup_controller.rb', line 82

def on
  collect true
end

#registerObject



33
34
35
36
37
38
# File 'lib/tuneup_controller.rb', line 33

def register
  render :update do |page| 
    page << "$('tuneup-panel').hide();"
    page << %[new Insertion.Bottom('tuneup-content', "#{escape_javascript(render(:partial => 'tuneup/panel/register.html.erb'))}");]
  end
end

#sandboxObject



90
91
92
# File 'lib/tuneup_controller.rb', line 90

def sandbox
  
end

#showObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tuneup_controller.rb', line 15

def show
  session['fiveruns_tuneup_last_uri'] = params[:uri]
  debug_rjs = response.template.debug_rjs
  response.template.debug_rjs = false
  ActionController::Base.silence do
    render :update do |page|
      page << tuneup_reload_panel
    end
  end
  response.template.debug_rjs = debug_rjs
end

#signinObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/tuneup_controller.rb', line 41

def 
  if api_key = retrieve_api_key
    @config['api_key'] = api_key
    @config.save!
  end
  render :update do |page|
    if api_key
      page << "$('tuneup-save-link').replace('#{escape_javascript(link_to_upload)}');"
      page << redisplay_last_run(false)
    else
      page << tuneup_show_flash(:error,
                :header => "TuneUp encountered an error",
                :message => "Could not access your FiveRuns TuneUp account.")
    end
  end
end

#updateObject



27
28
29
30
31
# File 'lib/tuneup_controller.rb', line 27

def update
  @config.update(params[:config])
  @config.save!
  redirect_to :action => 'show'
end

#uploadObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/tuneup_controller.rb', line 58

def upload
  token = upload_run
  render :update do |page|
    if token
      link = link_to_function("here", tuneup_open_run(token))
      page << tuneup_show_flash(:notice,
                :header => 'Run Uploaded to TuneUp',
                :message => "View your run #{link}.")
    else
      page << tuneup_show_flash(:error,
                :header => "TuneUp encountered an error",
                :message => "Could not upload run to your FiveRuns TuneUp account.")
    end
  end
end