Skip to content

Commit

Permalink
Extract the style options into config.web_console.style
Browse files Browse the repository at this point in the history
  • Loading branch information
gsamokovarov committed Sep 3, 2013
1 parent 06eeaf8 commit 88d39b1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% WebConsole.config.instance_eval do %>
<% WebConsole.config.style.instance_eval do %>
body { color: <%= colors.foreground %>; background: <%= colors.background %>; margin: 0; padding: 0; }

.terminal { float: left; overflow: hidden; font: <%= font %>; }
Expand Down
2 changes: 1 addition & 1 deletion app/views/web_console/console_sessions/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
var config = {
terminal: {
colors: <%= raw WebConsole.config.colors.to_json %>
colors: <%= raw WebConsole.config.style.colors.to_json %>
},

transport: {
Expand Down
9 changes: 6 additions & 3 deletions lib/web_console/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ class Engine < ::Rails::Engine
config.web_console = ActiveSupport::OrderedOptions.new.tap do |c|
c.automount = true
c.command = nil
c.colors = 'light'
c.default_mount_path = '/console'
c.font = 'large DejaVu Sans Mono, Liberation Mono, monospace'
c.timeout = 0.seconds
c.term = 'xterm-color'
c.whitelisted_ips = '127.0.0.1'

c.style = ActiveSupport::OrderedOptions.new.tap do |s|
s.colors = 'light'
s.font = 'large DejaVu Sans Mono, Liberation Mono, monospace'
end
end

initializer 'web_console.add_default_route' do |app|
Expand Down Expand Up @@ -53,7 +56,7 @@ def (c.whitelisted_ips).include?(ip)
end

initializer 'web_console.process_colors' do
config.web_console.tap do |c|
config.web_console.style.tap do |c|
case colors = c.colors
when Symbol, String
c.colors = Colors[colors] || Colors.default
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Application < Rails::Application
config.web_console.timeout = 45.seconds
end

config.web_console.colors =
config.web_console.style.colors =
if ENV['SOLARIZED_LIGHT']
'solarized_light'
elsif ENV['SOLARIZED_DARK']
Expand Down

0 comments on commit 88d39b1

Please sign in to comment.