redcar 0.12.1 → 0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +18 -0
- data/bin/redcar +1 -0
- data/lib/redcar.rb +4 -5
- data/lib/redcar/usage.rb +0 -1
- data/lib/redcar_quick_start.rb +3 -1
- data/plugins/application/lib/application.rb +1 -0
- data/plugins/application/lib/application/commands/treebook_commands.rb +11 -18
- data/plugins/application/lib/application/dialog.rb +1 -1
- data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +13 -5
- data/plugins/application/lib/application/global_state.rb +21 -0
- data/plugins/application/lib/application/menu/item.rb +37 -11
- data/plugins/application/lib/application/notebook.rb +12 -0
- data/plugins/application/lib/application/tree/mirror.rb +0 -11
- data/plugins/application/lib/application/window.rb +32 -7
- data/plugins/application_swt/lib/application_swt.rb +1 -1
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +35 -10
- data/plugins/application_swt/lib/application_swt/icon.rb +1 -1
- data/plugins/application_swt/lib/application_swt/menu.rb +47 -15
- data/plugins/application_swt/lib/application_swt/notebook.rb +11 -2
- data/plugins/application_swt/lib/application_swt/window.rb +37 -34
- data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +1 -1
- data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +9 -0
- data/plugins/declarations/lib/declarations.rb +31 -66
- data/plugins/declarations/lib/declarations/commands.rb +142 -0
- data/plugins/declarations/lib/declarations/file.rb +1 -1
- data/plugins/{outline_view → declarations}/spec/fixtures/some_project/javascript.js +0 -0
- data/plugins/{outline_view → declarations}/spec/fixtures/some_project/nothing_to_see.rb +0 -0
- data/plugins/{outline_view → declarations}/spec/fixtures/some_project/one_lonely_class.rb +0 -0
- data/plugins/{outline_view → declarations}/spec/fixtures/some_project/similar_names.rb +0 -0
- data/plugins/{outline_view → declarations}/spec/fixtures/some_project/something_fancy.rb +0 -0
- data/plugins/{outline_view → declarations}/spec/fixtures/some_project/trailing_space.rb +0 -0
- data/plugins/edit_view/lib/edit_view.rb +35 -2
- data/plugins/edit_view/lib/edit_view/commands/change_language_command.rb +31 -0
- data/plugins/edit_view/lib/edit_view/commands/language_settings_commands.rb +45 -0
- data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +11 -13
- data/plugins/key_bindings/lib/key_bindings.rb +6 -2
- data/plugins/project/lib/project.rb +27 -32
- data/plugins/project/lib/project/commands.rb +3 -88
- data/plugins/project/lib/project/dir_controller.rb +12 -18
- data/plugins/project/lib/project/dir_mirror.rb +20 -25
- data/plugins/project/lib/project/file_mirror.rb +10 -10
- data/plugins/project/lib/project/find_file_dialog.rb +20 -18
- data/plugins/project/lib/project/find_recent_dialog.rb +6 -3
- data/plugins/project/lib/project/{adapters/local.rb → local_filesystem.rb} +35 -35
- data/plugins/project/lib/project/manager.rb +21 -75
- data/plugins/project/lib/project/sub_project.rb +3 -3
- data/plugins/project/plugin.rb +0 -1
- data/plugins/project_search/lib/project_search/lucene_refresh.rb +0 -1
- data/plugins/redcar/plugin.rb +2 -2
- data/plugins/redcar/redcar.rb +34 -42
- data/plugins/ruby/lib/ruby/syntax_checker.rb +27 -7
- data/plugins/scm/lib/scm.rb +1 -12
- data/plugins/sessions/lib/sessions.rb +22 -0
- data/plugins/sessions/lib/sessions/cursor_saver.rb +162 -0
- data/plugins/sessions/lib/sessions/loader.rb +99 -0
- data/plugins/sessions/lib/sessions/memory.rb +59 -0
- data/plugins/sessions/plugin.rb +8 -0
- data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +2 -2
- data/plugins/syntax_check/lib/syntax_check.rb +2 -2
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +1 -3
- data/redcar.gemspec +1 -1
- metadata +195 -291
- data/plugins/connection_manager/lib/connection_manager.rb +0 -57
- data/plugins/connection_manager/lib/connection_manager/commands.rb +0 -14
- data/plugins/connection_manager/lib/connection_manager/connection_store.rb +0 -87
- data/plugins/connection_manager/lib/connection_manager/controller.rb +0 -100
- data/plugins/connection_manager/lib/connection_manager/filter_dialog.rb +0 -38
- data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +0 -93
- data/plugins/connection_manager/plugin.rb +0 -12
- data/plugins/connection_manager/views/index.html.erb +0 -284
- data/plugins/edit_view/lib/edit_view/info_speedbar.rb +0 -98
- data/plugins/outline_view/features/outline_view.feature +0 -79
- data/plugins/outline_view/features/project_outline.feature +0 -23
- data/plugins/outline_view/features/step_definitions/outline_steps.rb +0 -61
- data/plugins/outline_view/lib/outline_view.rb +0 -97
- data/plugins/outline_view/lib/outline_view/commands.rb +0 -19
- data/plugins/outline_view/plugin.rb +0 -10
- data/plugins/outline_view_swt/lib/outline_view_swt.rb +0 -79
- data/plugins/outline_view_swt/plugin.rb +0 -7
- data/plugins/project/lib/project/adapters/remote.rb +0 -96
- data/plugins/project/lib/project/adapters/remote_protocols/ftp.rb +0 -93
- data/plugins/project/lib/project/adapters/remote_protocols/protocol.rb +0 -94
- data/plugins/project/lib/project/adapters/remote_protocols/sftp.rb +0 -181
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
require 'connection_manager/commands'
|
4
|
-
require 'connection_manager/connection_store'
|
5
|
-
require 'connection_manager/controller'
|
6
|
-
require 'connection_manager/filter_dialog'
|
7
|
-
require 'connection_manager/private_key_store'
|
8
|
-
|
9
|
-
module Redcar
|
10
|
-
class ConnectionManager
|
11
|
-
CONNECTION_SUPER_CLASS ||= Struct.new(:name, :protocol, :host, :port, :user, :path)
|
12
|
-
|
13
|
-
def self.open_connection(c)
|
14
|
-
Project::Manager.connect_to_remote(c.protocol, c.host, c.user, c.path, PrivateKeyStore.paths)
|
15
|
-
end
|
16
|
-
|
17
|
-
class Connection < CONNECTION_SUPER_CLASS
|
18
|
-
def to_hash
|
19
|
-
{
|
20
|
-
"name" => name,
|
21
|
-
"host" => host,
|
22
|
-
"port" => port,
|
23
|
-
"user" => user,
|
24
|
-
"protocol" => protocol,
|
25
|
-
"path" => path
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class OpenRemoteFilter < Command
|
31
|
-
def execute
|
32
|
-
FilterDialog.new.open
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# def self.keymaps
|
37
|
-
# osx = Redcar::Keymap.build("main", :osx) do
|
38
|
-
# link "Cmd+P", OpenRemoteFilter
|
39
|
-
# end
|
40
|
-
# linwin = Redcar::Keymap.build("main", [:linux, :windows]) do
|
41
|
-
# link "Ctrl+P", OpenRemoteFilter
|
42
|
-
# end
|
43
|
-
# [osx, linwin]
|
44
|
-
# end
|
45
|
-
|
46
|
-
def self.menus
|
47
|
-
Menu::Builder.build do
|
48
|
-
sub_menu "Plugins" do
|
49
|
-
sub_menu "Connections", :priority => 36 do
|
50
|
-
item "Manage", OpenCommand
|
51
|
-
item "Remote Filter", OpenRemoteFilter
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ConnectionManager
|
4
|
-
|
5
|
-
class ConnectionStore
|
6
|
-
class ValidationFailedError < StandardError
|
7
|
-
def errors
|
8
|
-
@errors ||= []
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class AlreadyExistsError < StandardError
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :connections
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
@connections = load_connections
|
19
|
-
end
|
20
|
-
|
21
|
-
def find(name)
|
22
|
-
connections.detect { |c| c.name == name }
|
23
|
-
end
|
24
|
-
|
25
|
-
def add_connection(name, protocol, host, port, user, path)
|
26
|
-
if r = find(name)
|
27
|
-
raise AlreadyExistsError.new
|
28
|
-
end
|
29
|
-
|
30
|
-
validate_connection(name, protocol, host, port, user, path)
|
31
|
-
|
32
|
-
@connections << Connection.new(name, protocol, host, port, user, path)
|
33
|
-
|
34
|
-
save_connections
|
35
|
-
end
|
36
|
-
|
37
|
-
def update_connection(name, protocol, host, port, user, path)
|
38
|
-
connection = find(name)
|
39
|
-
|
40
|
-
validate_connection(name, protocol, host, port, user, path)
|
41
|
-
|
42
|
-
connection.name = name
|
43
|
-
connection.protocol = protocol
|
44
|
-
connection.host = host
|
45
|
-
connection.port = port
|
46
|
-
connection.user = user
|
47
|
-
connection.path = path
|
48
|
-
|
49
|
-
save_connections
|
50
|
-
end
|
51
|
-
|
52
|
-
def validate_connection(name, protocol, host, port, user, path)
|
53
|
-
validation_failed = ValidationFailedError.new
|
54
|
-
%w(name protocol host port user).each do |property|
|
55
|
-
value = eval(property)
|
56
|
-
validation_failed.errors << "#{property} cannot be blank" if !value || value.empty?
|
57
|
-
end
|
58
|
-
|
59
|
-
if validation_failed.errors.any?
|
60
|
-
raise validation_failed
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def delete_connection(name)
|
65
|
-
@connections.delete(find(name))
|
66
|
-
|
67
|
-
save_connections
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def load_connections
|
73
|
-
(storage["connections"] || []).map do |h|
|
74
|
-
Connection.new(h["name"], h["protocol"], h["host"], h["port"], h["user"], h["path"])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def save_connections
|
79
|
-
storage["connections"] = connections.map { |c| c.to_hash }
|
80
|
-
end
|
81
|
-
|
82
|
-
def storage
|
83
|
-
Redcar::Plugin::Storage.new('connection_manager')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ConnectionManager
|
4
|
-
|
5
|
-
class Controller
|
6
|
-
include Redcar::HtmlController
|
7
|
-
|
8
|
-
attr_reader :store, :private_key_store
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@store = ConnectionStore.new
|
12
|
-
@private_key_store = PrivateKeyStore.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def title
|
16
|
-
"Connections"
|
17
|
-
end
|
18
|
-
|
19
|
-
def index
|
20
|
-
rhtml = ERB.new(File.read(File.join(File.dirname(__FILE__), "..", "..", "views", "index.html.erb")))
|
21
|
-
rhtml.result(binding)
|
22
|
-
end
|
23
|
-
|
24
|
-
def add_connection(name, protocol, host, port, user, path)
|
25
|
-
store.add_connection(name, protocol, host, port, user, path)
|
26
|
-
|
27
|
-
success_response
|
28
|
-
rescue ConnectionStore::AlreadyExistsError
|
29
|
-
{
|
30
|
-
'success' => false,
|
31
|
-
'error' => "Connection #{name} already exists. Choose another name and try again."
|
32
|
-
}
|
33
|
-
rescue ConnectionStore::ValidationFailedError => e
|
34
|
-
validation_failed_response(e)
|
35
|
-
end
|
36
|
-
|
37
|
-
def update_connection(name, protocol, host, port, user, path)
|
38
|
-
store.update_connection(name, protocol, host, port, user, path)
|
39
|
-
|
40
|
-
success_response
|
41
|
-
rescue ConnectionStore::ValidationFailedError => e
|
42
|
-
validation_failed_response(e)
|
43
|
-
end
|
44
|
-
|
45
|
-
def delete_connection(name)
|
46
|
-
store.delete_connection(name)
|
47
|
-
|
48
|
-
success_response
|
49
|
-
end
|
50
|
-
|
51
|
-
def get_connection(name)
|
52
|
-
store.find(name).to_hash
|
53
|
-
end
|
54
|
-
|
55
|
-
def add_private_key_file(path)
|
56
|
-
private_key_store.add_private_key(path)
|
57
|
-
rescue PrivateKeyStore::ValidationError => e
|
58
|
-
validation_failed_response(e)
|
59
|
-
end
|
60
|
-
|
61
|
-
def remove_private_key_file(path)
|
62
|
-
private_key_store.remove_private_key(path)
|
63
|
-
end
|
64
|
-
|
65
|
-
def activate_connection(name)
|
66
|
-
connection = store.find(name)
|
67
|
-
Project::Manager.connect_to_remote(
|
68
|
-
connection.protocol, connection.host,
|
69
|
-
connection.user, connection.path,
|
70
|
-
PrivateKeyStore.paths
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def connections
|
77
|
-
store.connections
|
78
|
-
end
|
79
|
-
|
80
|
-
def auto_detected_private_key_files
|
81
|
-
PrivateKeyStore.auto_detected_keys
|
82
|
-
end
|
83
|
-
|
84
|
-
def private_key_files
|
85
|
-
private_key_store.paths
|
86
|
-
end
|
87
|
-
|
88
|
-
def success_response
|
89
|
-
{ 'success' => true }
|
90
|
-
end
|
91
|
-
|
92
|
-
def validation_failed_response(e)
|
93
|
-
{
|
94
|
-
'success' => false,
|
95
|
-
'error' => "Please fix the following errors:<ul>#{e.errors.map {|msg| "<li>#{msg}</li>"}}<ul>"
|
96
|
-
}
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Redcar
|
2
|
-
class ConnectionManager
|
3
|
-
class FilterDialog < FilterListDialog
|
4
|
-
MANAGER_NAME = "(Connection Manager)"
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
def update_list(query)
|
11
|
-
if query == ""
|
12
|
-
connection_names
|
13
|
-
else
|
14
|
-
filter_and_rank_by(connection_names, query, 1000)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def selected(text, _)
|
19
|
-
close
|
20
|
-
open_connection(text)
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def open_connection(name)
|
26
|
-
ConnectionManager.open_connection(store.find(name))
|
27
|
-
end
|
28
|
-
|
29
|
-
def store
|
30
|
-
ConnectionManager::ConnectionStore.new
|
31
|
-
end
|
32
|
-
|
33
|
-
def connection_names
|
34
|
-
["(Connection Manager)"] + store.connections.map {|con| con.name }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ConnectionManager
|
4
|
-
|
5
|
-
class PrivateKeyStore
|
6
|
-
def self.paths
|
7
|
-
auto_detected_keys + store_keys
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.auto_detected_keys
|
11
|
-
paths = []
|
12
|
-
default_key_globs.each do |default_key_glob|
|
13
|
-
Dir[default_key_glob].each do |filename|
|
14
|
-
unless File.directory?(filename) || !File.readable?(filename)
|
15
|
-
first = File.open(filename).read(100)
|
16
|
-
if first =~ /PRIVATE KEY/
|
17
|
-
paths << filename
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
paths
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.store_keys
|
26
|
-
PrivateKeyStore.new.paths
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.default_key_globs
|
30
|
-
[File.join(Redcar.home_dir, ".ssh", "*")]
|
31
|
-
end
|
32
|
-
|
33
|
-
class ValidationError < StandardError
|
34
|
-
def errors
|
35
|
-
@errors ||= []
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def initialize
|
40
|
-
@private_key_files = load_private_key_files
|
41
|
-
end
|
42
|
-
|
43
|
-
def paths
|
44
|
-
@private_key_files
|
45
|
-
end
|
46
|
-
|
47
|
-
def add_private_key(path)
|
48
|
-
path = File.expand_path(path)
|
49
|
-
validate_private_key(path)
|
50
|
-
|
51
|
-
@private_key_files << path
|
52
|
-
|
53
|
-
save_private_key_files
|
54
|
-
end
|
55
|
-
|
56
|
-
def remove_private_key(path)
|
57
|
-
path = File.expand_path(path)
|
58
|
-
@private_key_files.delete(path)
|
59
|
-
|
60
|
-
save_private_key_files
|
61
|
-
end
|
62
|
-
|
63
|
-
def validate_private_key(path)
|
64
|
-
validation_error = ValidationError.new
|
65
|
-
unless File.exist?(path) and File.file?(path)
|
66
|
-
validation_error.errors << "File not found."
|
67
|
-
raise validation_error
|
68
|
-
end
|
69
|
-
|
70
|
-
begin
|
71
|
-
Net::SSH::KeyFactory.load_private_key(path)
|
72
|
-
rescue OpenSSL::PKey::PKeyError
|
73
|
-
validation_error.errors << "File does not contain a private key."
|
74
|
-
raise validation_error
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def load_private_key_files
|
81
|
-
storage["private_keys"] || []
|
82
|
-
end
|
83
|
-
|
84
|
-
def save_private_key_files
|
85
|
-
storage["private_keys"] = @private_key_files
|
86
|
-
end
|
87
|
-
|
88
|
-
def storage
|
89
|
-
Redcar::Plugin::Storage.new('connection_manager')
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,284 +0,0 @@
|
|
1
|
-
|
2
|
-
<% jquery_path = File.expand_path(File.join(Redcar.root, %w(plugins html_view assets jquery-1.4.min.js))) %>
|
3
|
-
<% watermark = File.expand_path(File.join(Redcar.root, %w(plugins html_view views watermark-48.png))) %>
|
4
|
-
<% redcar_css = File.expand_path(File.join(Redcar.root, %w(plugins html_view views default.css))) %>
|
5
|
-
<script type="text/javascript" src="file://<%= jquery_path %>"></script>
|
6
|
-
<link rel="stylesheet" href="file://<%= redcar_css %>" type="text/css" media="screen">
|
7
|
-
<div id="top">
|
8
|
-
<img src="file://<%=watermark%>" id="watermark"/>
|
9
|
-
<h1>Connection Manager</h1>
|
10
|
-
</div>
|
11
|
-
<div class="main">
|
12
|
-
<h4>Connections</h4>
|
13
|
-
<div class="inset">
|
14
|
-
<div id='connections'>
|
15
|
-
<% if connections and connections.any? %>
|
16
|
-
<table id='table'>
|
17
|
-
<tr class='grey' style='font-weight:bold;'>
|
18
|
-
<th>Name</th>
|
19
|
-
<th>Protocol</th>
|
20
|
-
<th>Host</th>
|
21
|
-
<th>Port</th>
|
22
|
-
<th>User</th>
|
23
|
-
<th>Remote Path</th>
|
24
|
-
</tr>
|
25
|
-
|
26
|
-
<% connections.each do |c| %>
|
27
|
-
<tr id='row-<%= c.name %>'>
|
28
|
-
<td><a href='javascript:void(0);' class='activate connection-name'><%= c.name %></a></td>
|
29
|
-
<td><%= c.protocol %></td>
|
30
|
-
<td><%= c.host %></td>
|
31
|
-
<td><%= c.port %></td>
|
32
|
-
<td><%= c.user %></td>
|
33
|
-
<td><%= c.path %></td>
|
34
|
-
<td>
|
35
|
-
<a href='javascript:void(0);' class='delete'">Delete</a>
|
36
|
-
<a href='javascript:void(0);' class='modify'">Modify</a>
|
37
|
-
</td>
|
38
|
-
</tr>
|
39
|
-
<% end %>
|
40
|
-
</table>
|
41
|
-
<% else %>
|
42
|
-
<p>No connections</p>
|
43
|
-
<% end %>
|
44
|
-
<p>
|
45
|
-
<input id='add' type='button' value='Add Connection'>
|
46
|
-
</p>
|
47
|
-
</div>
|
48
|
-
<p>
|
49
|
-
<div id='add_div' style='display:none;'>
|
50
|
-
<div id='error' style='display:none;color:red;text-weight:bold;margin-bottom:20px;'></div>
|
51
|
-
<form id='new_connection'>
|
52
|
-
<input type='hidden' name='operation' id='operation'>
|
53
|
-
<table>
|
54
|
-
<tr class='grey'>
|
55
|
-
<th colspan=2><b><span id='conn_name'>New Connection</span></b></th>
|
56
|
-
</tr>
|
57
|
-
<tr><td>Name: </td><td><input size='30' type='text' name='name' id='name'></td></tr>
|
58
|
-
<tr>
|
59
|
-
<td>Protocol: </td>
|
60
|
-
<td>
|
61
|
-
<select name='protocol' id='protocol'>
|
62
|
-
<option></option>
|
63
|
-
<option>SFTP</option>
|
64
|
-
<option>FTP</option>
|
65
|
-
</select>
|
66
|
-
</td>
|
67
|
-
</tr>
|
68
|
-
<tr><td>Host: </td><td><input size="30" type='text' name='host' id='host'></td></tr>
|
69
|
-
<tr><td>Port: </td><td><input type='text' name='port' id='port' size=2></td></tr>
|
70
|
-
<tr><td>User: </td><td><input size="30" type='text' name='user' id='user'></td></tr>
|
71
|
-
<tr><td>Remote Path: </td><td><input size="30" type='text' name='path' id='path'></td></tr>
|
72
|
-
<tr>
|
73
|
-
<td colspan=2>
|
74
|
-
<input id='save' type='submit' value='Save'>
|
75
|
-
<input id='cancel' type='button' value='Cancel'>
|
76
|
-
</td>
|
77
|
-
</tr>
|
78
|
-
</table>
|
79
|
-
</form>
|
80
|
-
</div>
|
81
|
-
</p>
|
82
|
-
</div>
|
83
|
-
|
84
|
-
<h4>Private Keys</h4>
|
85
|
-
<div class="inset">
|
86
|
-
<div id="private-keys">
|
87
|
-
<div class="list">
|
88
|
-
<% if (private_key_files + auto_detected_private_key_files).any? %>
|
89
|
-
<table>
|
90
|
-
<% auto_detected_private_key_files.each do |private_key| %>
|
91
|
-
<tr>
|
92
|
-
<td><%= private_key %></td>
|
93
|
-
</tr>
|
94
|
-
<% end %>
|
95
|
-
<% private_key_files.each do |private_key| %>
|
96
|
-
<tr>
|
97
|
-
<td><%= private_key %></td>
|
98
|
-
<td>
|
99
|
-
<a href='javascript:void(0);' class='delete-key' data-name="<%= private_key %>">Delete</a>
|
100
|
-
</td>
|
101
|
-
</tr>
|
102
|
-
<% end %>
|
103
|
-
</table>
|
104
|
-
<% else %>
|
105
|
-
No private keys.
|
106
|
-
<% end %>
|
107
|
-
</div>
|
108
|
-
<br />
|
109
|
-
<input id='add-private-key-button' type='button' value='Add Private Key'>
|
110
|
-
|
111
|
-
<div id='add-private-key' style='display:none;'>
|
112
|
-
<div class='error' style='display:none;color:red;text-weight:bold;margin-bottom:20px;'></div>
|
113
|
-
|
114
|
-
<form id='add-private-key-form'>
|
115
|
-
<input type='hidden' name='operation' class='operation'>
|
116
|
-
<table>
|
117
|
-
<tr class='grey'>
|
118
|
-
<td colspan=2><b><span>New Private Key</span></b></td>
|
119
|
-
</tr>
|
120
|
-
<tr><td>Key file: </td><td><input size="30" type='text' class="path" name='path'></td></tr>
|
121
|
-
<tr>
|
122
|
-
<td colspan=2>
|
123
|
-
<input class='save' type='submit' value='Save'>
|
124
|
-
<input class='cancel' type='button' value='Cancel'>
|
125
|
-
</td>
|
126
|
-
</tr>
|
127
|
-
</table>
|
128
|
-
</form>
|
129
|
-
</div>
|
130
|
-
</div>
|
131
|
-
</div>
|
132
|
-
</div>
|
133
|
-
|
134
|
-
<script type="text/javascript">
|
135
|
-
$(document).ready(function() {
|
136
|
-
function showMain() {
|
137
|
-
$(':input','#new_connection')
|
138
|
-
.not(':button, :submit, :reset, :hidden')
|
139
|
-
.val('')
|
140
|
-
.removeAttr('checked')
|
141
|
-
.removeAttr('selected');
|
142
|
-
|
143
|
-
$('#add_div').hide();
|
144
|
-
$('#connections').show();
|
145
|
-
};
|
146
|
-
|
147
|
-
var PORTS = {
|
148
|
-
'FTP': 21, 'SFTP': 22
|
149
|
-
};
|
150
|
-
|
151
|
-
$('.delete').live('click', function() {
|
152
|
-
var name = $(this).parent().parent().find(".connection-name").text();
|
153
|
-
try {
|
154
|
-
if (confirm('Do you really want to delete connection ' + name + '?')) {
|
155
|
-
Controller.deleteConnection(name);
|
156
|
-
Controller.reloadIndex();
|
157
|
-
}
|
158
|
-
}
|
159
|
-
catch(err) {
|
160
|
-
alert("Error: " + err.message);
|
161
|
-
}
|
162
|
-
});
|
163
|
-
|
164
|
-
$('.modify').live('click', function() {
|
165
|
-
var name = $(this).parent().parent().find(".connection-name").text();
|
166
|
-
$('#error').html("");
|
167
|
-
$('#conn_name').text('Editing ' + name);
|
168
|
-
$('#connections').hide();
|
169
|
-
$('#add_div').show();
|
170
|
-
$('#protocol').focus();
|
171
|
-
$('#name').attr('disabled', 'disabled');
|
172
|
-
|
173
|
-
var data = Controller.getConnection(name);
|
174
|
-
if (data) {
|
175
|
-
$('#operation').val('update');
|
176
|
-
$('#name').val(name);
|
177
|
-
$('#protocol').val(data.protocol);
|
178
|
-
$('#host').val(data.host);
|
179
|
-
$('#port').val(data.port);
|
180
|
-
$('#user').val(data.user);
|
181
|
-
$('#path').val(data.path);
|
182
|
-
}
|
183
|
-
});
|
184
|
-
|
185
|
-
$('#protocol').change(function(e) {
|
186
|
-
$('#port').val(PORTS[$(this).val()]);
|
187
|
-
});
|
188
|
-
|
189
|
-
$('#add').click(function() {
|
190
|
-
$('#error').html("");
|
191
|
-
$('#conn_name').text('New Connection');
|
192
|
-
$('#operation').val('insert');
|
193
|
-
$('#connections').hide();
|
194
|
-
$('#add_div').show();
|
195
|
-
$('#name').focus();
|
196
|
-
});
|
197
|
-
|
198
|
-
$('#cancel').click(function() {
|
199
|
-
$('#error').html("");
|
200
|
-
showMain();
|
201
|
-
});
|
202
|
-
|
203
|
-
$("#new_connection").submit(function(e) {
|
204
|
-
try {
|
205
|
-
$('#name').removeAttr('disabled');
|
206
|
-
var name = $('#name').val();
|
207
|
-
var protocol = $('#protocol').val();
|
208
|
-
var host = $('#host').val();
|
209
|
-
var port = $('#port').val();
|
210
|
-
var user = $('#user').val();
|
211
|
-
var path = $('#path').val();
|
212
|
-
|
213
|
-
if ($('#operation').val() == 'insert') {
|
214
|
-
result = Controller.addConnection(name, protocol, host, port, user, path);
|
215
|
-
}
|
216
|
-
else {
|
217
|
-
result = Controller.updateConnection(name, protocol, host, port, user, path);
|
218
|
-
}
|
219
|
-
|
220
|
-
if (result.success === false) {
|
221
|
-
$('#error').html(result.error);
|
222
|
-
$('#error').show();
|
223
|
-
$('#name').focus();
|
224
|
-
}
|
225
|
-
else {
|
226
|
-
Controller.reloadIndex();
|
227
|
-
}
|
228
|
-
}
|
229
|
-
catch(err) {
|
230
|
-
alert("Error: " + error.message);
|
231
|
-
}
|
232
|
-
return false;
|
233
|
-
});
|
234
|
-
|
235
|
-
$(".activate").click(function(e) {
|
236
|
-
var name = $(this).parent().parent().find(".connection-name").text();
|
237
|
-
Controller.activateConnection(name);
|
238
|
-
});
|
239
|
-
|
240
|
-
$("#add-private-key-button").click(function() {
|
241
|
-
$("#add-private-key-button").hide();
|
242
|
-
$("#add-private-key").show();
|
243
|
-
$("#private-keys .list").hide();
|
244
|
-
});
|
245
|
-
|
246
|
-
$("#add-private-key-form .cancel").click(function() {
|
247
|
-
$("#add-private-key-button").show();
|
248
|
-
$("#add-private-key").hide();
|
249
|
-
$("#private-keys .list").show();
|
250
|
-
});
|
251
|
-
|
252
|
-
$("#add-private-key-form").submit(function(e) {
|
253
|
-
try {
|
254
|
-
var result = Controller.addPrivateKeyFile($("#add-private-key-form .path").val());
|
255
|
-
|
256
|
-
if (result.success === false) {
|
257
|
-
$('#add-private-key .error').html(result.error);
|
258
|
-
$('#add-private-key .error').show();
|
259
|
-
$('#add-private-key-form .path').focus();
|
260
|
-
}
|
261
|
-
else {
|
262
|
-
Controller.reloadIndex();
|
263
|
-
}
|
264
|
-
}
|
265
|
-
catch(err) {
|
266
|
-
alert("Error: " + error.message);
|
267
|
-
}
|
268
|
-
return false;
|
269
|
-
});
|
270
|
-
|
271
|
-
$("#private-keys .list .delete-key").click(function() {
|
272
|
-
var path = $(this).attr('data-name');
|
273
|
-
try {
|
274
|
-
Controller.removePrivateKeyFile(path);
|
275
|
-
Controller.reloadIndex();
|
276
|
-
}
|
277
|
-
catch(err) {
|
278
|
-
alert("Error: " + err.message);
|
279
|
-
}
|
280
|
-
});
|
281
|
-
|
282
|
-
});
|
283
|
-
|
284
|
-
</script>
|