termvana 0.2.0.beta2 → 0.2.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -5,3 +5,4 @@
5
5
  * build simple site
6
6
  _ fix timeout error when you run a long command and then other commands
7
7
  * more specs for CD - home dir, expanded paths, CDPATH, multiple terminals
8
+ _ show home dir
@@ -11,6 +11,10 @@ class Termvana::WebsocketAction < Cramp::Websocket
11
11
 
12
12
  def opened_conn
13
13
  @environment = Termvana::Environment.new(:env => {"HOME" => ENV['HOME']})
14
+ # Setup
15
+ Dir.chdir(@environment.fullpath(@environment.cwd))
16
+ @environment.env["PWD"] = @environment.cwd = Dir.pwd
17
+
14
18
  @environment.messenger do |message|
15
19
  render message.to_s
16
20
  end
@@ -7,6 +7,9 @@ module Termvana
7
7
  dir = request[1] || "~"
8
8
  Dir.chdir(environment.fullpath(dir))
9
9
  environment.env["PWD"] = environment.cwd = Dir.pwd
10
+ # Send system env update to JS
11
+ respond_with(:data => {:environment => environment}, :type => :system)
12
+ # Terminate with null message
10
13
  finish
11
14
  end
12
15
  end
@@ -0,0 +1,15 @@
1
+ module Termvana
2
+ class LoadEnvironmentCommand < Command
3
+ type :builtin
4
+ response :system
5
+ name "load_environment"
6
+ def call
7
+ respond_with(:data => {:environment => environment})
8
+ respond_with(:null)
9
+ end
10
+ end
11
+ end
12
+
13
+ Termvana::CommandProcessor.register(Termvana::LoadEnvironmentCommand)
14
+
15
+
@@ -12,14 +12,20 @@ module Termvana
12
12
  end
13
13
  end
14
14
 
15
- def respond_with(opts = {})
16
- if opts == :null
17
- environment.send_message Termvana::Response.new
15
+ def respond_with(*args)
16
+ opts = args.extract_options!
17
+ opts[:message] ||= args.shift if args.first.is_a? String
18
+
19
+ if args.first == :null
20
+ opts = {}
18
21
  elsif data = opts.delete(:text)
19
- environment.send_message Termvana::Response.new(:message => data)
22
+ opts[:message] ||= data
20
23
  elsif data = opts.delete(:error)
21
- environment.send_message Termvana::Response.new(:message => data, :type => :error)
24
+ opts[:message] ||= data
25
+ opts[:type] = :error
22
26
  end
27
+ opts[:type] ||= self.class.response
28
+ environment.send_message Termvana::Response.new(opts)
23
29
  end
24
30
 
25
31
 
@@ -2,6 +2,7 @@ module Termvana
2
2
  class Response
3
3
  include Virtus
4
4
  attribute :message, String, :default => ""
5
+ attribute :data, Hash
5
6
  attribute :type, Symbol, :default => :output
6
7
 
7
8
  def to_s
@@ -18,7 +18,8 @@ body .nirvana_warning {
18
18
  }
19
19
 
20
20
  html {
21
- height: 100%;
21
+ background-color: transparent;
22
+
22
23
  }
23
24
  body {
24
25
  background: #000;
@@ -26,17 +27,70 @@ body {
26
27
  padding: 0;
27
28
  margin: 0;
28
29
  height: 100%;
30
+ overflow-y: hidden;
31
+
32
+ }
33
+ ::-webkit-scrollbar {
34
+ width: 10px;
35
+ height: 10px;
36
+ }
37
+
38
+ ::-webkit-scrollbar-button:start:decrement,
39
+ ::-webkit-scrollbar-button:end:increment {
40
+ height: 30px;
41
+ display: block;
42
+ background-color: transparent;
43
+ }
44
+
45
+ ::-webkit-scrollbar-track-piece {
46
+ background-color: #3b3b3b;
47
+ -webkit-border-radius: 6px;
48
+ }
49
+
50
+ ::-webkit-scrollbar-thumb:vertical {
51
+ height: 50px;
52
+ background-color: #666;
53
+ border: 1px solid #eee;
54
+ -webkit-border-radius: 6px;
55
+ }
56
+
57
+ footer{
58
+ position: fixed;
59
+ bottom: 0;
60
+ height: 30px;
61
+ font-size: smaller;
62
+ font-family: "BitStream Vera Sans Mono", "Lucida Console", monospace;
63
+ width: 100%;
64
+ background-color: #336699;
65
+ background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0), rgba(10, 20, 60, 0.7));
66
+ background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0), rgba(10, 20, 60, 0.7));
67
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(0, 0, 0, 0)), color-stop(1, rgba(10, 20, 60, 0.7)));
68
+ background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(10, 20, 60, 0.7));
69
+ background-image: linear-gradient(top, rgba(0, 0, 0, 0), rgba(10, 20, 60, 0.7));
70
+ }
71
+
72
+ footer div{
73
+ margin: 6px 8px;
29
74
  }
30
75
 
76
+
31
77
  .termkitCommandView {
32
78
  font-family: "BitStream Vera Sans", "Lucida Grande", "Helvetica", Arial, sans-serif;
33
79
  font-size: 70%;
34
- padding: 1em;
80
+ height: 100%;
81
+ position: absolute;
82
+ top: 0;
83
+ left: 0;
84
+ bottom: 0;
85
+ right: 10px;
86
+ overflow-y: scroll;
87
+ overflow-x: hidden;
35
88
  }
36
89
 
37
90
  #terminal {
38
91
  background: #000;
39
- min-height: 100%;
92
+ padding: 1em;
93
+ padding-bottom: 50px;
40
94
  }
41
95
 
42
96
  .nirvana_exception::-webkit-scrollbar {
@@ -24,13 +24,19 @@
24
24
  $.ws().send(JSON.stringify({full_command: val}));
25
25
  }
26
26
  });
27
+
27
28
  $(window).click(function(){ $('#input').focus(); });
28
29
  });
29
30
  </script>
30
31
  </head>
31
- <body class="termkitCommandView">
32
- <form id="terminal">
33
- <input id='input' type='text'>
34
- </form>
32
+ <body>
33
+ <section class="termkitCommandView">
34
+ <form id="terminal">
35
+ <input id='input' type='text'>
36
+ </form>
37
+ </section>
38
+ <footer>
39
+ <div id="current_working_dir"></div>
40
+ </footer>
35
41
  </body>
36
42
  </html>
@@ -67,7 +67,7 @@
67
67
  $("code", node).append($("<pre>").text(str));
68
68
  screen.append(node);
69
69
 
70
- return $('body').scrollTop($('body').attr('scrollHeight'));
70
+ return $('.termkitCommandView').scrollTop($('.termkitCommandView').height());
71
71
  },
72
72
  disable: function() {
73
73
  $('#'+prompt_id).hide();
@@ -3,7 +3,10 @@
3
3
  alert("This browser does NOT support websockets and thus termvana fail :(");
4
4
  }
5
5
  if(window.WebSocket) var ws = new WebSocket("ws://"+window.location.host+"/socket");
6
- else if(window.MozWebSocket) var ws = new MozWebSocket("ws://"+window.location.host+"/socket");
6
+ else if(window.MozWebSocket) var ws = new MozWebSocket("ws://"+window.location.host+"/socket");
7
+ ws.onopen = function(e){
8
+ ws.send(JSON.stringify({full_command: "load_environment"}));
9
+ }
7
10
  ws.onmessage = function(e) {
8
11
  var data = e.data;
9
12
  data = JSON.parse(data);
@@ -12,8 +15,13 @@
12
15
  $.readline.finishCompletion(completions);
13
16
  } else {
14
17
 
15
- console.log("Got message of ", data.message, data);
16
- $.repl.logResult(data.message);
18
+ if(data.type == "system"){
19
+ if(data['data'] && data['data']['environment'])
20
+ $('#current_working_dir').text(data.data.environment.cwd);
21
+ }
22
+ else{
23
+ $.repl.logResult(data.message);
24
+ }
17
25
  }
18
26
  };
19
27
  ws.onclose = function() {
@@ -26,5 +34,5 @@
26
34
  };
27
35
 
28
36
  $.ws = function() { return ws };
29
- $.ws.nirvanaComplete = function(val) { ws.send(':AUTOCOMPLETE: '+val); };
37
+ $.ws.nirvanaComplete = function(val) { console.log("No auto complete yet") };
30
38
  })(jQuery);
@@ -1,3 +1,3 @@
1
1
  module Termvana
2
- VERSION = '0.2.0.beta2'
2
+ VERSION = '0.2.0.beta3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termvana
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.beta2
4
+ version: 0.2.0.beta3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-17 00:00:00.000000000Z
12
+ date: 2011-09-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cramp
16
- requirement: &2152839680 !ruby/object:Gem::Requirement
16
+ requirement: &2152810580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152839680
24
+ version_requirements: *2152810580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thin
27
- requirement: &2152839220 !ruby/object:Gem::Requirement
27
+ requirement: &2152810040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152839220
35
+ version_requirements: *2152810040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2152838800 !ruby/object:Gem::Requirement
38
+ requirement: &2152809600 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152838800
46
+ version_requirements: *2152809600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: http_router
49
- requirement: &2152838340 !ruby/object:Gem::Requirement
49
+ requirement: &2152809100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2152838340
57
+ version_requirements: *2152809100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: async-rack
60
- requirement: &2152837920 !ruby/object:Gem::Requirement
60
+ requirement: &2152808620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2152837920
68
+ version_requirements: *2152808620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: virtus
71
- requirement: &2152837480 !ruby/object:Gem::Requirement
71
+ requirement: &2152808200 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *2152837480
79
+ version_requirements: *2152808200
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: activesupport
82
- requirement: &2152837060 !ruby/object:Gem::Requirement
82
+ requirement: &2152807680 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *2152837060
90
+ version_requirements: *2152807680
91
91
  description: A ruby web shell that has autocompletion and readline behavior. It uses
92
92
  websockets, repl.js, readline.js and ripl for the shell engine.
93
93
  email: therabidbanana@gmail.com
@@ -102,6 +102,7 @@ files:
102
102
  - lib/termvana/app/actions/websocket_action.rb
103
103
  - lib/termvana/app/command_processor.rb
104
104
  - lib/termvana/app/commands/cd.rb
105
+ - lib/termvana/app/commands/load_environment.rb
105
106
  - lib/termvana/app/commands/set.rb
106
107
  - lib/termvana/app/models/command.rb
107
108
  - lib/termvana/app/models/environment.rb