web-console-rails3 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +1 -1
- data/Rakefile +1 -1
- data/app/assets/javascripts/web_console/application.js +0 -1
- data/app/assets/javascripts/web_console/console_sessions.js +177 -3
- data/app/assets/stylesheets/web_console/application.css +0 -1
- data/app/assets/stylesheets/web_console/console_sessions.css.erb +6 -0
- data/app/controllers/web_console/application_controller.rb +1 -6
- data/app/views/web_console/console_sessions/index.html.erb +11 -5
- data/lib/{web_console/backport/active_model.rb → active_model/model.rb} +0 -0
- data/lib/assets/javascripts/web_console.js +22 -183
- data/lib/web_console.rb +1 -9
- data/lib/web_console/colors.rb +86 -0
- data/lib/web_console/colors/light.rb +24 -0
- data/lib/web_console/colors/solarized.rb +47 -0
- data/lib/web_console/colors/tango.rb +24 -0
- data/lib/web_console/colors/xterm.rb +24 -0
- data/lib/web_console/engine.rb +34 -12
- data/lib/web_console/engine.rb.orig +75 -0
- data/lib/web_console/slave.rb +19 -1
- data/lib/web_console/version.rb +1 -1
- data/test/dummy/config/application.rb +13 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +275 -29309
- data/test/dummy/log/test.log +16 -2337
- data/test/dummy/tmp/cache/assets/C3D/0C0/sprockets%2Fb01666017530b122ba58894b59b1551b +0 -0
- data/test/dummy/tmp/cache/assets/C5D/870/sprockets%2F9695d21699b362bcc13260e71b679474 +0 -0
- data/test/dummy/tmp/cache/assets/C79/7C0/sprockets%2F831cb415f919c0a15d95e148020953f2 +0 -0
- data/test/dummy/tmp/cache/assets/CB7/870/sprockets%2F5358761e3329e2a4655ee7c0fd2609b5 +0 -0
- data/test/dummy/tmp/cache/assets/CD0/9A0/sprockets%2F61b95b7833a131f56a2096a3d2ba0c94 +0 -0
- data/test/dummy/tmp/cache/assets/CDA/480/sprockets%2F26eb073018913d788d2ee3f5151eea04 +0 -0
- data/test/dummy/tmp/cache/assets/CE1/850/sprockets%2Fb962434bbb22f17db956b8091c975f30 +0 -0
- data/test/dummy/tmp/cache/assets/D0C/EE0/sprockets%2F3fdf5762c392175ad2cba21454e5b972 +0 -0
- data/test/dummy/tmp/cache/assets/D42/180/sprockets%2F4af57a79abba3d4790ba1e7157f41939 +0 -0
- data/test/dummy/tmp/cache/assets/D54/E60/sprockets%2F8abf0788cb7dc878ea82239456149bed +0 -0
- data/test/dummy/tmp/cache/assets/D5F/7E0/sprockets%2F26c1c2c6ba96ba84abf150e402d677c3 +0 -0
- data/test/dummy/tmp/cache/assets/D66/680/sprockets%2Fe0ba18d897f0c45f5e66b003c5ebd061 +0 -0
- data/test/dummy/tmp/cache/assets/D66/AE0/sprockets%2F25c91de251a8ab43652dc2ef55e2a29d +0 -0
- data/test/dummy/tmp/cache/assets/DA7/470/sprockets%2F65bb61bf1edac19c0666e89b667d23ff +0 -0
- data/test/dummy/tmp/cache/assets/DA9/F60/sprockets%2Fa95e444e8dca0e1a586dcef972b623f7 +0 -0
- data/test/dummy/tmp/cache/assets/DAC/A90/sprockets%2F2015f79881b518e9cdcdaf8dfb3e46c5 +0 -0
- data/test/web_console/colors_test.rb +58 -0
- data/vendor/assets/javascripts/term.js +5726 -0
- metadata +110 -117
- data/app/assets/stylesheets/web_console/console_sessions.css +0 -0
- data/test/dummy/config/application.rb.orig +0 -58
- data/test/dummy/tmp/cache/assets/C9E/AD0/sprockets%2F4a42d8916f3fa47867445f696497a92c +0 -0
- data/test/dummy/tmp/cache/assets/CA7/D70/sprockets%2F3e9e32bbc8c81a93002555265a36a852 +0 -0
- data/test/dummy/tmp/cache/assets/CBD/6E0/sprockets%2F3293dfc0984076f0e8371a9e7640f4a8 +0 -0
- data/test/dummy/tmp/cache/assets/CD0/FC0/sprockets%2Fbb2777627d42a216f3d9ced4322040b3 +0 -0
- data/test/dummy/tmp/cache/assets/CFA/E30/sprockets%2F35be1d26565dc0310c29f1a5e2f62f10 +0 -0
- data/test/dummy/tmp/cache/assets/D1D/FD0/sprockets%2Fa4a5ffe670666ce3d8d59179905201ef +0 -0
- data/test/dummy/tmp/cache/assets/D21/6B0/sprockets%2F9e242803fe56d6305274ff7e6487deda +0 -0
- data/test/dummy/tmp/cache/assets/D22/980/sprockets%2Fce6aa94ad2bc107104c0540f62c5128c +0 -0
- data/test/dummy/tmp/cache/assets/D29/380/sprockets%2F92f1a0450bc4bea3364a07be42b4f645 +0 -0
- data/test/dummy/tmp/cache/assets/D3E/380/sprockets%2F434d98c8380bb9daf43810155aaf68ba +0 -0
- data/test/dummy/tmp/cache/assets/D66/940/sprockets%2F6151175b6ad4f9bab0c7e2b508e7b70f +0 -0
- data/test/dummy/tmp/cache/assets/D69/670/sprockets%2Fc6b4a05846fd1b98fe9252ecdd1601c0 +0 -0
- data/test/dummy/tmp/cache/assets/D69/710/sprockets%2Ff67078d4b979a58c97feede196f6b385 +0 -0
- data/test/dummy/tmp/cache/assets/D90/B30/sprockets%2Fe03fe93eb7fe888c9d21ee62816596ff +0 -0
- data/test/dummy/tmp/cache/assets/D95/C40/sprockets%2F09cb0a274209abf0391cbfce6ee67b82 +0 -0
- data/test/dummy/tmp/cache/assets/D9B/A30/sprockets%2Fc3436b3fe5da7c2456f26e2ae36da6c5 +0 -0
- data/test/dummy/tmp/cache/assets/D9F/400/sprockets%2F7f60332f86073dc8ed80b4c2a9dfcbe1 +0 -0
- data/test/dummy/tmp/cache/assets/DAE/8C0/sprockets%2Fa9b8f7bc5ca2efe658a13d7f4609c729 +0 -0
- data/test/dummy/tmp/cache/assets/DB3/0C0/sprockets%2F689fb998e2a7add3e00db88df254c87a +0 -0
- data/test/dummy/tmp/cache/assets/DD4/440/sprockets%2Fa33d646ac00d8bc87a4a496af6eed96f +0 -0
- data/test/dummy/tmp/cache/assets/DDB/890/sprockets%2F5ed566ca9fafd1b82373ffea2a8d8681 +0 -0
- data/test/dummy/tmp/cache/assets/E5A/C40/sprockets%2F164cfa0fd9eb1ec1acdfaa278c83e9c5 +0 -0
- data/vendor/assets/javascripts/vt100.js +0 -4408
- data/vendor/assets/stylesheets/vt100.css +0 -272
data/lib/web_console.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'rails/version'
|
2
1
|
require 'active_support/lazy_load_hooks'
|
3
2
|
require 'web_console/engine'
|
3
|
+
require 'web_console/colors'
|
4
4
|
require 'web_console/slave'
|
5
5
|
|
6
6
|
module WebConsole
|
@@ -11,11 +11,3 @@ module WebConsole
|
|
11
11
|
|
12
12
|
ActiveSupport.run_load_hooks(:web_console, self)
|
13
13
|
end
|
14
|
-
|
15
|
-
if Rails::VERSION::MAJOR == 3
|
16
|
-
# ActiveModel::Model is not defined in Rails 3. Use a backported version.
|
17
|
-
require 'web_console/backport/active_model'
|
18
|
-
|
19
|
-
# Explicitly require strong_parameters to make sure the users won't have to.
|
20
|
-
require 'strong_parameters'
|
21
|
-
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
2
|
+
|
3
|
+
module WebConsole
|
4
|
+
# = Colors
|
5
|
+
#
|
6
|
+
# Manages the creation and serialization of terminal color themes.
|
7
|
+
#
|
8
|
+
# Colors is a subclass of +Array+ and it stores a collection of CSS color
|
9
|
+
# values, to be used from the client-side terminal.
|
10
|
+
#
|
11
|
+
# You can specify 8 or 16 colors and additional +background+ and +foreground+
|
12
|
+
# colors. If not explicitly specified, +background+ and +foreground+ are
|
13
|
+
# considered to be the first and the last of the given colors.
|
14
|
+
class Colors < Array
|
15
|
+
class << self
|
16
|
+
# Registry of color themes mapped to a name.
|
17
|
+
#
|
18
|
+
# Don't manually alter the registry. Use WebConsole::Colors.register_theme
|
19
|
+
# for adding entries.
|
20
|
+
def themes
|
21
|
+
@@themes ||= {}.with_indifferent_access
|
22
|
+
end
|
23
|
+
|
24
|
+
# Register a color theme into the color themes registry.
|
25
|
+
#
|
26
|
+
# Registration maps a name and Colors instance.
|
27
|
+
#
|
28
|
+
# If a block is given, it would be yielded with a new Colors instance to
|
29
|
+
# populate the theme colors in.
|
30
|
+
#
|
31
|
+
# If a Colors instance is already instantiated it can be passed directly
|
32
|
+
# as the second (_colors_) argument. In this case, if a block is given,
|
33
|
+
# it won't be executed.
|
34
|
+
def register_theme(name, colors = nil)
|
35
|
+
themes[name] = colors || new.tap { |c| yield c }
|
36
|
+
end
|
37
|
+
|
38
|
+
# The default colors theme.
|
39
|
+
def default
|
40
|
+
self[:light]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Shortcut for WebConsole::Colors.themes#[].
|
44
|
+
def [](name)
|
45
|
+
themes[name]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
alias :add :<<
|
50
|
+
|
51
|
+
# Background color getter and setter.
|
52
|
+
#
|
53
|
+
# If called without arguments it acts like a getter. Otherwise it acts like
|
54
|
+
# a setter.
|
55
|
+
#
|
56
|
+
# The default background color will be the first entry in the colors theme.
|
57
|
+
def background(value = nil)
|
58
|
+
@background = value unless value.nil?
|
59
|
+
@background ||= self.first
|
60
|
+
end
|
61
|
+
|
62
|
+
alias :background= :background
|
63
|
+
|
64
|
+
# Foreground color getter and setter.
|
65
|
+
#
|
66
|
+
# If called without arguments it acts like a getter. Otherwise it acts like
|
67
|
+
# a setter.
|
68
|
+
#
|
69
|
+
# The default foreground color will be the last entry in the colors theme.
|
70
|
+
def foreground(value = nil)
|
71
|
+
@foreground = value unless value.nil?
|
72
|
+
@foreground ||= self.last
|
73
|
+
end
|
74
|
+
|
75
|
+
alias :foreground= :foreground
|
76
|
+
|
77
|
+
def to_json
|
78
|
+
(dup << background << foreground).to_a.to_json
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
require 'web_console/colors/light'
|
84
|
+
require 'web_console/colors/xterm'
|
85
|
+
require 'web_console/colors/tango'
|
86
|
+
require 'web_console/colors/solarized'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module WebConsole
|
2
|
+
Colors.register_theme(:light) do |c|
|
3
|
+
c.add '#000000'
|
4
|
+
c.add '#cd0000'
|
5
|
+
c.add '#00cd00'
|
6
|
+
c.add '#cdcd00'
|
7
|
+
c.add '#0000ee'
|
8
|
+
c.add '#cd00cd'
|
9
|
+
c.add '#00cdcd'
|
10
|
+
c.add '#e5e5e5'
|
11
|
+
|
12
|
+
c.add '#7f7f7f'
|
13
|
+
c.add '#ff0000'
|
14
|
+
c.add '#00ff00'
|
15
|
+
c.add '#ffff00'
|
16
|
+
c.add '#5c5cff'
|
17
|
+
c.add '#ff00ff'
|
18
|
+
c.add '#00ffff'
|
19
|
+
c.add '#ffffff'
|
20
|
+
|
21
|
+
c.background '#ffffff'
|
22
|
+
c.foreground '#000000'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module WebConsole
|
2
|
+
Colors.register_theme(:solarized_dark) do |c|
|
3
|
+
c.add '#073642'
|
4
|
+
c.add '#dc322f'
|
5
|
+
c.add '#859900'
|
6
|
+
c.add '#b58900'
|
7
|
+
c.add '#268bd2'
|
8
|
+
c.add '#d33682'
|
9
|
+
c.add '#2aa198'
|
10
|
+
c.add '#eee8d5'
|
11
|
+
|
12
|
+
c.add '#002b36'
|
13
|
+
c.add '#cb4b16'
|
14
|
+
c.add '#586e75'
|
15
|
+
c.add '#657b83'
|
16
|
+
c.add '#839496'
|
17
|
+
c.add '#6c71c4'
|
18
|
+
c.add '#93a1a1'
|
19
|
+
c.add '#fdf6e3'
|
20
|
+
|
21
|
+
c.background '#002b36'
|
22
|
+
c.foreground '#657b83'
|
23
|
+
end
|
24
|
+
|
25
|
+
Colors.register_theme(:solarized_light) do |c|
|
26
|
+
c.add '#073642'
|
27
|
+
c.add '#dc322f'
|
28
|
+
c.add '#859900'
|
29
|
+
c.add '#b58900'
|
30
|
+
c.add '#268bd2'
|
31
|
+
c.add '#d33682'
|
32
|
+
c.add '#2aa198'
|
33
|
+
c.add '#eee8d5'
|
34
|
+
|
35
|
+
c.add '#002b36'
|
36
|
+
c.add '#cb4b16'
|
37
|
+
c.add '#586e75'
|
38
|
+
c.add '#657b83'
|
39
|
+
c.add '#839496'
|
40
|
+
c.add '#6c71c4'
|
41
|
+
c.add '#93a1a1'
|
42
|
+
c.add '#fdf6e3'
|
43
|
+
|
44
|
+
c.background '#fdf6e3'
|
45
|
+
c.foreground '#657b83'
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module WebConsole
|
2
|
+
Colors.register_theme(:tango) do |c|
|
3
|
+
c.add '#2e3436'
|
4
|
+
c.add '#cc0000'
|
5
|
+
c.add '#4e9a06'
|
6
|
+
c.add '#c4a000'
|
7
|
+
c.add '#3465a4'
|
8
|
+
c.add '#75507b'
|
9
|
+
c.add '#06989a'
|
10
|
+
c.add '#d3d7cf'
|
11
|
+
|
12
|
+
c.add '#555753'
|
13
|
+
c.add '#ef2929'
|
14
|
+
c.add '#8ae234'
|
15
|
+
c.add '#fce94f'
|
16
|
+
c.add '#729fcf'
|
17
|
+
c.add '#ad7fa8'
|
18
|
+
c.add '#34e2e2'
|
19
|
+
c.add '#eeeeec'
|
20
|
+
|
21
|
+
c.background '#2e3436'
|
22
|
+
c.foreground '#eeeeec'
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module WebConsole
|
2
|
+
Colors.register_theme(:xterm) do |c|
|
3
|
+
c.add '#000000'
|
4
|
+
c.add '#cd0000'
|
5
|
+
c.add '#00cd00'
|
6
|
+
c.add '#cdcd00'
|
7
|
+
c.add '#0000ee'
|
8
|
+
c.add '#cd00cd'
|
9
|
+
c.add '#00cdcd'
|
10
|
+
c.add '#e5e5e5'
|
11
|
+
|
12
|
+
c.add '#7f7f7f'
|
13
|
+
c.add '#ff0000'
|
14
|
+
c.add '#00ff00'
|
15
|
+
c.add '#ffff00'
|
16
|
+
c.add '#5c5cff'
|
17
|
+
c.add '#ff00ff'
|
18
|
+
c.add '#00ffff'
|
19
|
+
c.add '#ffffff'
|
20
|
+
|
21
|
+
c.background '#000000'
|
22
|
+
c.foreground '#ffffff'
|
23
|
+
end
|
24
|
+
end
|
data/lib/web_console/engine.rb
CHANGED
@@ -2,6 +2,10 @@ require 'ipaddr'
|
|
2
2
|
require 'active_support/core_ext/numeric/time'
|
3
3
|
require 'rails/engine'
|
4
4
|
|
5
|
+
# Those are required for Rails 3 compatibility.
|
6
|
+
require 'strong_parameters'
|
7
|
+
require 'active_model/model'
|
8
|
+
|
5
9
|
module WebConsole
|
6
10
|
class Engine < ::Rails::Engine
|
7
11
|
isolate_namespace WebConsole
|
@@ -11,7 +15,13 @@ module WebConsole
|
|
11
15
|
c.command = nil
|
12
16
|
c.default_mount_path = '/console'
|
13
17
|
c.timeout = 0.seconds
|
18
|
+
c.term = 'xterm-color'
|
14
19
|
c.whitelisted_ips = '127.0.0.1'
|
20
|
+
|
21
|
+
c.style = ActiveSupport::OrderedOptions.new.tap do |s|
|
22
|
+
s.colors = 'light'
|
23
|
+
s.font = 'large DejaVu Sans Mono, Liberation Mono, monospace'
|
24
|
+
end
|
15
25
|
end
|
16
26
|
|
17
27
|
initializer 'web_console.add_default_route' do |app|
|
@@ -25,17 +35,18 @@ module WebConsole
|
|
25
35
|
end
|
26
36
|
|
27
37
|
initializer 'web_console.process_whitelisted_ips' do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
config.web_console.tap do |c|
|
39
|
+
# Ensure that it is an array of IPAddr instances and it is defaulted to
|
40
|
+
# 127.0.0.1 if not precent. Only unique entries are left in the end.
|
41
|
+
c.whitelisted_ips = Array(c.whitelisted_ips).map do |ip|
|
42
|
+
ip.is_a?(IPAddr) ? ip : IPAddr.new(ip.presence || '127.0.0.1')
|
43
|
+
end.uniq
|
44
|
+
|
45
|
+
# IPAddr instances can cover whole networks, so simplify the #include?
|
46
|
+
# check for the most common case.
|
47
|
+
def (c.whitelisted_ips).include?(ip)
|
48
|
+
ip.is_a?(IPAddr) ? super : any? { |net| net.include?(ip.to_s) }
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
41
52
|
|
@@ -43,7 +54,18 @@ module WebConsole
|
|
43
54
|
config.web_console.tap do |c|
|
44
55
|
# +Rails.root+ is not available while we set the default values of the
|
45
56
|
# other options. Default it during initialization.
|
46
|
-
c.command =
|
57
|
+
c.command = 'rails console' if c.command.blank?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
initializer 'web_console.process_colors' do
|
62
|
+
config.web_console.style.tap do |c|
|
63
|
+
case colors = c.colors
|
64
|
+
when Symbol, String
|
65
|
+
c.colors = Colors[colors] || Colors.default
|
66
|
+
else
|
67
|
+
c.colors = Colors.new(colors)
|
68
|
+
end
|
47
69
|
end
|
48
70
|
end
|
49
71
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
require 'active_support/core_ext/numeric/time'
|
3
|
+
require 'rails/engine'
|
4
|
+
|
5
|
+
<<<<<<< HEAD
|
6
|
+
# Those are required for Rails 3 compatibility.
|
7
|
+
require 'strong_parameters'
|
8
|
+
require 'active_model/model'
|
9
|
+
=======
|
10
|
+
>>>>>>> 0bca90aa29cdad3a02e366681e005a574449caa8
|
11
|
+
|
12
|
+
module WebConsole
|
13
|
+
class Engine < ::Rails::Engine
|
14
|
+
isolate_namespace WebConsole
|
15
|
+
|
16
|
+
config.web_console = ActiveSupport::OrderedOptions.new.tap do |c|
|
17
|
+
c.automount = true
|
18
|
+
c.command = nil
|
19
|
+
c.default_mount_path = '/console'
|
20
|
+
c.timeout = 0.seconds
|
21
|
+
c.term = 'xterm-color'
|
22
|
+
c.whitelisted_ips = '127.0.0.1'
|
23
|
+
|
24
|
+
c.style = ActiveSupport::OrderedOptions.new.tap do |s|
|
25
|
+
s.colors = 'light'
|
26
|
+
s.font = 'large DejaVu Sans Mono, Liberation Mono, monospace'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
initializer 'web_console.add_default_route' do |app|
|
31
|
+
# While we don't need the route in the test environment, we define it
|
32
|
+
# there as well, so we can easily test it.
|
33
|
+
if config.web_console.automount && (Rails.env.development? || Rails.env.test?)
|
34
|
+
app.routes.append do
|
35
|
+
mount WebConsole::Engine => app.config.web_console.default_mount_path
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
initializer 'web_console.process_whitelisted_ips' do
|
41
|
+
config.web_console.tap do |c|
|
42
|
+
# Ensure that it is an array of IPAddr instances and it is defaulted to
|
43
|
+
# 127.0.0.1 if not precent. Only unique entries are left in the end.
|
44
|
+
c.whitelisted_ips = Array(c.whitelisted_ips).map do |ip|
|
45
|
+
ip.is_a?(IPAddr) ? ip : IPAddr.new(ip.presence || '127.0.0.1')
|
46
|
+
end.uniq
|
47
|
+
|
48
|
+
# IPAddr instances can cover whole networks, so simplify the #include?
|
49
|
+
# check for the most common case.
|
50
|
+
def (c.whitelisted_ips).include?(ip)
|
51
|
+
ip.is_a?(IPAddr) ? super : any? { |net| net.include?(ip.to_s) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
initializer 'web_console.process_command' do
|
57
|
+
config.web_console.tap do |c|
|
58
|
+
# +Rails.root+ is not available while we set the default values of the
|
59
|
+
# other options. Default it during initialization.
|
60
|
+
c.command = ('rails console').to_s if c.command.blank?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
initializer 'web_console.process_colors' do
|
65
|
+
config.web_console.style.tap do |c|
|
66
|
+
case colors = c.colors
|
67
|
+
when Symbol, String
|
68
|
+
c.colors = Colors[colors] || Colors.default
|
69
|
+
else
|
70
|
+
c.colors = Colors.new(colors)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/web_console/slave.rb
CHANGED
@@ -14,7 +14,9 @@ module WebConsole
|
|
14
14
|
attr_reader :pid
|
15
15
|
|
16
16
|
def initialize(command = WebConsole.config.command, options = {})
|
17
|
-
|
17
|
+
using_term(options[:term] || WebConsole.config.term) do
|
18
|
+
@output, @input, @pid = PTY.spawn(command.to_s)
|
19
|
+
end
|
18
20
|
configure(options)
|
19
21
|
end
|
20
22
|
|
@@ -102,6 +104,22 @@ module WebConsole
|
|
102
104
|
|
103
105
|
private
|
104
106
|
|
107
|
+
LOCK = Mutex.new
|
108
|
+
|
109
|
+
def using_term(term)
|
110
|
+
if term.nil?
|
111
|
+
yield
|
112
|
+
else
|
113
|
+
LOCK.synchronize do
|
114
|
+
begin
|
115
|
+
(previous_term, ENV['TERM'] = ENV['TERM'], term) and yield
|
116
|
+
ensure
|
117
|
+
ENV['TERM'] = previous_term
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
105
123
|
def dispose_with(signal, options = {})
|
106
124
|
Process.kill(signal, @pid)
|
107
125
|
Process.detach(@pid)
|
data/lib/web_console/version.rb
CHANGED
@@ -49,6 +49,19 @@ module Dummy
|
|
49
49
|
# For long-polling 45 seconds timeout seems reasonable.
|
50
50
|
config.web_console.timeout = 45.seconds
|
51
51
|
end
|
52
|
+
|
53
|
+
config.web_console.style.colors =
|
54
|
+
if ENV['SOLARIZED_LIGHT']
|
55
|
+
'solarized_light'
|
56
|
+
elsif ENV['SOLARIZED_DARK']
|
57
|
+
'solarized_dark'
|
58
|
+
elsif ENV['TANGO']
|
59
|
+
'tango'
|
60
|
+
elsif ENV['XTERM']
|
61
|
+
'xterm'
|
62
|
+
else
|
63
|
+
'light'
|
64
|
+
end
|
52
65
|
end
|
53
66
|
end
|
54
67
|
|
Binary file
|