web-console 1.0.4 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of web-console might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.markdown +26 -247
- data/lib/action_dispatch/debug_exceptions.rb +115 -0
- data/lib/action_dispatch/exception_wrapper.rb +15 -0
- data/lib/action_dispatch/templates/rescues/_request_and_response.html.erb +34 -0
- data/lib/action_dispatch/templates/rescues/_request_and_response.text.erb +23 -0
- data/lib/action_dispatch/templates/rescues/_source.erb +27 -0
- data/lib/action_dispatch/templates/rescues/_trace.html.erb +76 -0
- data/lib/action_dispatch/templates/rescues/_trace.text.erb +15 -0
- data/lib/action_dispatch/templates/rescues/_web_console.html.erb +382 -0
- data/lib/action_dispatch/templates/rescues/diagnostics.html.erb +18 -0
- data/lib/action_dispatch/templates/rescues/diagnostics.text.erb +9 -0
- data/lib/action_dispatch/templates/rescues/layout.erb +162 -0
- data/lib/action_dispatch/templates/rescues/missing_template.html.erb +7 -0
- data/lib/action_dispatch/templates/rescues/missing_template.text.erb +3 -0
- data/lib/action_dispatch/templates/rescues/routing_error.html.erb +30 -0
- data/lib/action_dispatch/templates/rescues/routing_error.text.erb +11 -0
- data/lib/action_dispatch/templates/rescues/template_error.html.erb +22 -0
- data/lib/action_dispatch/templates/rescues/template_error.text.erb +8 -0
- data/lib/action_dispatch/templates/rescues/unknown_action.html.erb +6 -0
- data/lib/action_dispatch/templates/rescues/unknown_action.text.erb +3 -0
- data/lib/web_console.rb +17 -7
- data/lib/web_console/exception_extension.rb +22 -0
- data/lib/web_console/railtie.rb +15 -0
- data/lib/web_console/repl.rb +24 -0
- data/lib/web_console/repl_session.rb +90 -0
- data/lib/web_console/version.rb +1 -1
- data/lib/web_console/view_helpers.rb +21 -0
- data/test/action_pack/exception_wrapper_test.rb +26 -0
- data/test/dummy/app/controllers/exception_test_controller.rb +11 -0
- data/test/dummy/app/controllers/helper_test_controller.rb +5 -0
- data/test/dummy/app/views/helper_test/index.html.erb +220 -0
- data/test/dummy/app/views/layouts/application.html.erb +2 -0
- data/test/dummy/config/application.rb +0 -34
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +61270 -0
- data/test/dummy/log/test.log +3917 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/038461854af2e8bccdb29768efd4768f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0ec396634a5f6808b026257fd107c355 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/127a54171eea8d294e4673599861787d +0 -0
- data/{app/assets/stylesheets/web_console/application.css → test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/17c571144b4e44da39bddb2d2c412414 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1cb77d8cf661ccbc9de08f347c89b9f1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/204edd12a29660722d4e0d8de9bd6652 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2b96b037f3dfeccfe27113eb95b06ea1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2c853768baf811357d81d41bdfd05dcf +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/314d48e543146f617c4d3439a4d8d40d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/34f21019a876722b8c24a6da4f0ef50b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/{vendor/assets/javascripts/term.js → test/dummy/tmp/cache/assets/development/sprockets/36341e42f23669574fa1027d0958ff3e} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/44117154e909436e7eeaf10cdb18d2b4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/496864a905d53afd8e176f29500f96a8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/55b7b76605fdffe31d737d4ac1f1ef7b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5ac98782fe3dfd0a766f75ce1801f0a0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6088d6f344b38303cc8028057d69e0f9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/676dcf9b2d01b9dc7bd3183d8da88463 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/680381170dc160e358fc28076ea6886c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6ad7acc9a22fe2a67ec24a1fc866c20e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6bdb0d0c602e0e1bc304dc697e2cc6de +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6dc8d7aa69668fce85683aaad6615432 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6e4d5b32cc444226f6597198994ccd5e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/74db0ca5cb8c8c347c9131a3ff516748 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7999e525c88173c1beb785f002effc1d +0 -0
- data/{lib/assets/javascripts/web_console.js → test/dummy/tmp/cache/assets/development/sprockets/7a50a9e605754e99783de95715b976b0} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/806b0e33a2fe8e1245534345fa27c30a +0 -0
- data/{app/assets/javascripts/web_console/console_sessions.js → test/dummy/tmp/cache/assets/development/sprockets/8aa4c7aabff23c8089d41e9e54193483} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/90396626cba6cbec37e32038e6c54e76 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/976b28910aa72c90a3b30c6e940f51df +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/99e1bd7cbc437505bc8f07bc528c721c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/aaccf2c9ae2add0863c9a49e0042a097 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ae4677d24a79d9411f2fced5011d5807 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b2401118729720034b6f3eda0b4c5025 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c649837df826fc310cb80f1adafd6b8d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cac185d59612fae451a12df3fc21bb51 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cb0065359d3b5b296f71d673f4b276e9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cee8c6b09c33d2b276753e959712724e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d1f6e06bc2f112c4ec3a4c3f68351878 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d20d83fd7ffa378b1b2b901786d640f3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d38c7c3aa1e72b55769ccb3607641ef4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d6b85d8b0b5c569388b89e56e9f6fed7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d982412def520c434e2240eae6d29cf2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/df048a8b0897b9c04acdf59c8f95b18f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/df600f50f002512c95d93bcfbab891ed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e6d6b8bde546349764be7b44ffcf5807 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/eb25265794d2f7afd1684779d84efdac +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ee8826b12b7d9bfd717df950b58f82ab +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ef9824789c6ed3483590e0564a12e1d1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fc7201c6cbef32453aa4175c520c8eae +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/17c571144b4e44da39bddb2d2c412414 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/36341e42f23669574fa1027d0958ff3e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/55b7b76605fdffe31d737d4ac1f1ef7b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5ac98782fe3dfd0a766f75ce1801f0a0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/680381170dc160e358fc28076ea6886c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6ad7acc9a22fe2a67ec24a1fc866c20e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6e4d5b32cc444226f6597198994ccd5e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7a50a9e605754e99783de95715b976b0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8aa4c7aabff23c8089d41e9e54193483 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b2401118729720034b6f3eda0b4c5025 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cb0065359d3b5b296f71d673f4b276e9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d1f6e06bc2f112c4ec3a4c3f68351878 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d6b85d8b0b5c569388b89e56e9f6fed7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d982412def520c434e2240eae6d29cf2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/df048a8b0897b9c04acdf59c8f95b18f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e6d6b8bde546349764be7b44ffcf5807 +0 -0
- data/test/web_console/exception_extention_test.rb +16 -0
- data/test/web_console/repl_session_test.rb +32 -0
- data/test/web_console/repl_test.rb +26 -0
- metadata +191 -58
- data/app/assets/javascripts/web_console/application.js +0 -1
- data/app/assets/stylesheets/web_console/console_sessions.css.erb +0 -6
- data/app/controllers/web_console/application_controller.rb +0 -13
- data/app/controllers/web_console/console_sessions_controller.rb +0 -43
- data/app/helpers/web_console/application_helper.rb +0 -4
- data/app/helpers/web_console/console_session_helper.rb +0 -4
- data/app/models/web_console/console_session.rb +0 -96
- data/app/views/layouts/web_console/application.html.erb +0 -14
- data/app/views/web_console/console_sessions/index.html.erb +0 -15
- data/config/routes.rb +0 -11
- data/lib/assets/javascripts/web-console.js +0 -1
- data/lib/web_console/colors.rb +0 -87
- data/lib/web_console/colors/light.rb +0 -24
- data/lib/web_console/colors/monokai.rb +0 -24
- data/lib/web_console/colors/solarized.rb +0 -47
- data/lib/web_console/colors/tango.rb +0 -24
- data/lib/web_console/colors/xterm.rb +0 -24
- data/lib/web_console/engine.rb +0 -77
- data/lib/web_console/slave.rb +0 -139
- data/test/controllers/web_console/console_sessions_controller_test.rb +0 -95
- data/test/helpers/web_console/console_session_helper_test.rb +0 -6
- data/test/models/console_session_test.rb +0 -58
- data/test/web_console/colors_test.rb +0 -58
- data/test/web_console/engine_test.rb +0 -136
- data/test/web_console/slave_test.rb +0 -71
@@ -1 +0,0 @@
|
|
1
|
-
//= require_tree .
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<% WebConsole.config.style.instance_eval do %>
|
2
|
-
body { color: <%= colors.foreground %>; background: <%= colors.background %>; margin: 0; padding: 0; }
|
3
|
-
|
4
|
-
.terminal { float: left; overflow: hidden; font: <%= font %>; }
|
5
|
-
.terminal-cursor { color: <%= colors.background %>; background: <%= colors.foreground %>; }
|
6
|
-
<% end %>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module WebConsole
|
2
|
-
class ApplicationController < ActionController::Base
|
3
|
-
before_action :prevent_unauthorized_requests!
|
4
|
-
|
5
|
-
private
|
6
|
-
|
7
|
-
def prevent_unauthorized_requests!
|
8
|
-
unless request.remote_ip.in?(WebConsole.config.whitelisted_ips)
|
9
|
-
render nothing: true, status: :unauthorized
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require_dependency 'web_console/application_controller'
|
2
|
-
|
3
|
-
module WebConsole
|
4
|
-
class ConsoleSessionsController < ApplicationController
|
5
|
-
rescue_from ConsoleSession::Unavailable do |exception|
|
6
|
-
render json: exception, status: :gone
|
7
|
-
end
|
8
|
-
|
9
|
-
rescue_from ConsoleSession::Invalid do |exception|
|
10
|
-
render json: exception, status: :unprocessable_entity
|
11
|
-
end
|
12
|
-
|
13
|
-
def index
|
14
|
-
@console_session = ConsoleSession.create
|
15
|
-
end
|
16
|
-
|
17
|
-
def input
|
18
|
-
@console_session = ConsoleSession.find(params[:id])
|
19
|
-
@console_session.send_input(console_session_params[:input])
|
20
|
-
|
21
|
-
render nothing: true
|
22
|
-
end
|
23
|
-
|
24
|
-
def configuration
|
25
|
-
@console_session = ConsoleSession.find(params[:id])
|
26
|
-
@console_session.configure(console_session_params)
|
27
|
-
|
28
|
-
render nothing: true
|
29
|
-
end
|
30
|
-
|
31
|
-
def pending_output
|
32
|
-
@console_session = ConsoleSession.find(params[:id])
|
33
|
-
|
34
|
-
render json: { output: @console_session.pending_output }
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def console_session_params
|
40
|
-
params.permit(:id, :input, :width, :height)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
module WebConsole
|
2
|
-
# Manage and persist (in memory) WebConsole::Slave instances.
|
3
|
-
class ConsoleSession
|
4
|
-
include ActiveModel::Model
|
5
|
-
|
6
|
-
# In-memory storage for the console sessions. Session preservation is
|
7
|
-
# troubled on servers with multiple workers and threads.
|
8
|
-
INMEMORY_STORAGE = {}
|
9
|
-
|
10
|
-
# Base error class for ConsoleSession specific exceptions.
|
11
|
-
#
|
12
|
-
# Provides #to_json implementation, so all subclasses are JSON
|
13
|
-
# serializable.
|
14
|
-
class Error < StandardError
|
15
|
-
def to_json(*)
|
16
|
-
{ error: to_s }.to_json
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Raised when trying to find a session that is no longer in the in-memory
|
21
|
-
# session storage or when the slave process exited.
|
22
|
-
Unavailable = Class.new(Error)
|
23
|
-
|
24
|
-
# Raised when an operation transition to an invalid state.
|
25
|
-
Invalid = Class.new(Error)
|
26
|
-
|
27
|
-
class << self
|
28
|
-
# Finds a session by its pid.
|
29
|
-
#
|
30
|
-
# Raises WebConsole::ConsoleSession::Expired if there is no such session.
|
31
|
-
def find(pid)
|
32
|
-
INMEMORY_STORAGE[pid.to_i] or raise Unavailable, 'Session unavailable'
|
33
|
-
end
|
34
|
-
|
35
|
-
# Creates an already persisted consolse session.
|
36
|
-
#
|
37
|
-
# Use this method if you need to persist a session, without providing it
|
38
|
-
# any input.
|
39
|
-
def create
|
40
|
-
new.persist
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def initialize(attributes = {})
|
45
|
-
@slave = WebConsole::Slave.new
|
46
|
-
end
|
47
|
-
|
48
|
-
# Explicitly persist the model in the in-memory storage.
|
49
|
-
def persist
|
50
|
-
INMEMORY_STORAGE[pid] = self
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns true if the current session is persisted in the in-memory storage.
|
54
|
-
def persisted?
|
55
|
-
self == INMEMORY_STORAGE[pid]
|
56
|
-
end
|
57
|
-
|
58
|
-
# Returns an Enumerable of all key attributes if any is set, regardless if
|
59
|
-
# the object is persisted or not.
|
60
|
-
def to_key
|
61
|
-
[pid] if persisted?
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def delegate_and_call_slave_method(name, *args, &block)
|
67
|
-
# Cache the delegated method, so we don't have to hit #method_missing
|
68
|
-
# on every call.
|
69
|
-
define_singleton_method(name) do |*inner_args, &inner_block|
|
70
|
-
begin
|
71
|
-
@slave.public_send(name, *inner_args, &inner_block)
|
72
|
-
rescue ArgumentError => exc
|
73
|
-
raise Invalid, exc
|
74
|
-
rescue Slave::Closed => exc
|
75
|
-
raise Unavailable, exc
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Now call the method, since that's our most common use case. Delegate
|
80
|
-
# the method and than call it.
|
81
|
-
public_send(name, *args, &block)
|
82
|
-
end
|
83
|
-
|
84
|
-
def method_missing(name, *args, &block)
|
85
|
-
if @slave.respond_to?(name)
|
86
|
-
delegate_and_call_slave_method(name, *args, &block)
|
87
|
-
else
|
88
|
-
super
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def respond_to_missing?(name, include_all = false)
|
93
|
-
@slave.respond_to?(name) or super
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>WebConsole</title>
|
5
|
-
<%= stylesheet_link_tag "web_console/application", media: "all" %>
|
6
|
-
<%= javascript_include_tag "web_console/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
var config = {
|
3
|
-
terminal: {
|
4
|
-
colors: <%= raw WebConsole.config.style.colors.to_json %>
|
5
|
-
},
|
6
|
-
|
7
|
-
transport: {
|
8
|
-
url: {
|
9
|
-
input: "<%= web_console.input_console_session_path(@console_session) %>",
|
10
|
-
pendingOutput: "<%= web_console.pending_output_console_session_path(@console_session) %>",
|
11
|
-
configuration: "<%= web_console.configuration_console_session_path(@console_session) %>"
|
12
|
-
}
|
13
|
-
}
|
14
|
-
};
|
15
|
-
</script>
|
data/config/routes.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
//= require ./web_console
|
data/lib/web_console/colors.rb
DELETED
@@ -1,87 +0,0 @@
|
|
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/monokai'
|
85
|
-
require 'web_console/colors/solarized'
|
86
|
-
require 'web_console/colors/tango'
|
87
|
-
require 'web_console/colors/xterm'
|
@@ -1,24 +0,0 @@
|
|
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
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module WebConsole
|
2
|
-
Colors.register_theme(:monokai) do |c|
|
3
|
-
c.add '#1c1d19'
|
4
|
-
c.add '#d01b24'
|
5
|
-
c.add '#a7d32C'
|
6
|
-
c.add '#d8cf67'
|
7
|
-
c.add '#61b8d0'
|
8
|
-
c.add '#695abb'
|
9
|
-
c.add '#d53864'
|
10
|
-
c.add '#fefffe'
|
11
|
-
|
12
|
-
c.add '#1c1d19'
|
13
|
-
c.add '#d12a24'
|
14
|
-
c.add '#a7d32c'
|
15
|
-
c.add '#d8cf67'
|
16
|
-
c.add '#61b8d0'
|
17
|
-
c.add '#695abb'
|
18
|
-
c.add '#d53864'
|
19
|
-
c.add '#fefffe'
|
20
|
-
|
21
|
-
c.background '#1c1d19'
|
22
|
-
c.foreground '#fefffe'
|
23
|
-
end
|
24
|
-
end
|
@@ -1,47 +0,0 @@
|
|
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
|
@@ -1,24 +0,0 @@
|
|
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
|
@@ -1,24 +0,0 @@
|
|
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
|