web-console 3.6.2 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +7 -0
- data/README.markdown +14 -7
- data/lib/web_console/templates/console.js.erb +104 -24
- data/lib/web_console/templates/error_page.js.erb +3 -5
- data/lib/web_console/templates/index.html.erb +4 -0
- data/lib/web_console/templates/regular_page.js.erb +24 -0
- data/lib/web_console/templates/style.css.erb +4 -3
- data/lib/web_console/version.rb +1 -1
- data/lib/web_console/view.rb +5 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0540ac7a81a49deaad0b10cd764ca4d02ca2e9a630ef6d775051dec6e5ef55
|
4
|
+
data.tar.gz: 80352b0d87ea7718cd08597c159d67edbafb2e5f9e46f674f48d1011a7118fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e954cedb636a015d9cb86ddc60e4e97e44f61df6d7eaac89144c2b7b39207883117186c81420d2e90719f42d9acc6d397842f6750600b04681db47093c4e506a
|
7
|
+
data.tar.gz: c091ef07d8462544f8f8367143a5b1ef8579a901cb1cfd88e463a2a37e3955f8c769f7a3206b2b4da442db27c3743a5e86ce9c69f82a6f954d1301d4e7629055
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 3.7.0
|
6
|
+
|
7
|
+
* [#263](https://github.com/rails/web-console/pull/263) Show binding changes ([@causztic])
|
8
|
+
* [#258](https://github.com/rails/web-console/pull/258) Support Ctrl-A, Ctrl-W and Ctrl-U ([@gsamokovarov])
|
9
|
+
* [#257](https://github.com/rails/web-console/pull/257) Always try to keep the console underneath the website content ([@gsamokovarov])
|
10
|
+
|
5
11
|
## 3.6.2
|
6
12
|
|
7
13
|
* [#255](https://github.com/rails/web-console/pull/255) Fix the truncated HTML body, because of wrong Content-Length header ([@timomeh])
|
@@ -131,3 +137,4 @@ go to 3.1.0 instead.
|
|
131
137
|
[@ybart]: https://github.com/ybart
|
132
138
|
[@fl0l0u]: https://github.com/fl0l0u
|
133
139
|
[@timomeh]: https://github.com/timomeh
|
140
|
+
[@causztic]: https://github.com/causztic
|
data/README.markdown
CHANGED
@@ -94,7 +94,7 @@ messages like the following is printed in the server logs:
|
|
94
94
|
> Cannot render console from 192.168.1.133! Allowed networks:
|
95
95
|
> 127.0.0.0/127.255.255.255, ::1
|
96
96
|
|
97
|
-
If you don't
|
97
|
+
If you don't want to see this message anymore, set this option to `false`:
|
98
98
|
|
99
99
|
```ruby
|
100
100
|
Rails.application.configure do
|
@@ -104,7 +104,7 @@ end
|
|
104
104
|
|
105
105
|
### config.web_console.template_paths
|
106
106
|
|
107
|
-
If you
|
107
|
+
If you want to style the console yourself, you can place `style.css` at a
|
108
108
|
directory pointed by `config.web_console.template_paths`:
|
109
109
|
|
110
110
|
```ruby
|
@@ -113,13 +113,13 @@ Rails.application.configure do
|
|
113
113
|
end
|
114
114
|
```
|
115
115
|
|
116
|
-
You may
|
116
|
+
You may want to check the [templates] folder at the source tree for the files you
|
117
117
|
may override.
|
118
118
|
|
119
119
|
### config.web_console.mount_point
|
120
120
|
|
121
121
|
Usually the middleware of _Web Console_ is mounted at `/__web_console`.
|
122
|
-
If you
|
122
|
+
If you want to change the path for some reasons, you can specify it
|
123
123
|
by `config.web_console.mount_point`:
|
124
124
|
|
125
125
|
```ruby
|
@@ -137,7 +137,7 @@ bundled with _Web Console_.
|
|
137
137
|
|
138
138
|
If you miss this feature, check out [rvt].
|
139
139
|
|
140
|
-
### Why I constantly get unavailable session errors?
|
140
|
+
### Why do I constantly get unavailable session errors?
|
141
141
|
|
142
142
|
All of _Web Console_ sessions are stored in memory. If you happen to run on a
|
143
143
|
multi-process server (like Unicorn) you may get unavailable session errors
|
@@ -146,12 +146,17 @@ different worker (process) that doesn't have the desired session in memory.
|
|
146
146
|
To avoid that, if you use such servers in development, configure them so they
|
147
147
|
server requests only out of one process.
|
148
148
|
|
149
|
+
#### Passenger
|
150
|
+
|
151
|
+
Enable sticky sessions for [Passenger on Nginx] or [Passenger on Apache] to
|
152
|
+
prevent unavailable session errors.
|
153
|
+
|
149
154
|
### How to inspect local and instance variables?
|
150
155
|
|
151
156
|
The interactive console executes Ruby code. Invoking `instance_variables` and
|
152
157
|
`local_variables` will give you what you want.
|
153
158
|
|
154
|
-
### Why does console only appear on error pages but not when I call it?
|
159
|
+
### Why does the console only appear on error pages but not when I call it?
|
155
160
|
|
156
161
|
This can be happening if you are using `Rack::Deflater`. Be sure that
|
157
162
|
`WebConsole::Middleware` is used after `Rack::Deflater`. The easiest way to do
|
@@ -163,7 +168,7 @@ Rails.application.configure do
|
|
163
168
|
end
|
164
169
|
```
|
165
170
|
|
166
|
-
### Why I
|
171
|
+
### Why am I getting an undefined method `web_console`?
|
167
172
|
|
168
173
|
Make sure your configuration lives in `config/environments/development.rb`.
|
169
174
|
|
@@ -183,3 +188,5 @@ Make sure your configuration lives in `config/environments/development.rb`.
|
|
183
188
|
[templates]: https://github.com/rails/web-console/tree/master/lib/web_console/templates
|
184
189
|
[rvt]: https://github.com/gsamokovarov/rvt
|
185
190
|
[contributors]: https://github.com/rails/web-console/graphs/contributors
|
191
|
+
[Passenger on Nginx]: https://www.phusionpassenger.com/library/config/nginx/reference/#passengerstickysessions
|
192
|
+
[Passenger on Apache]: https://www.phusionpassenger.com/library/config/apache/reference/#passengerstickysessions
|
@@ -603,6 +603,12 @@ REPLConsole.prototype.writeError = function(output) {
|
|
603
603
|
return consoleMessage;
|
604
604
|
};
|
605
605
|
|
606
|
+
REPLConsole.prototype.writeNotification = function(output) {
|
607
|
+
var consoleMessage = this.writeOutput(output);
|
608
|
+
addClass(consoleMessage, "notification-message");
|
609
|
+
return consoleMessage;
|
610
|
+
};
|
611
|
+
|
606
612
|
REPLConsole.prototype.onEnterKey = function() {
|
607
613
|
var input = this._input;
|
608
614
|
|
@@ -654,57 +660,85 @@ REPLConsole.prototype.onKeyDown = function(ev) {
|
|
654
660
|
}
|
655
661
|
|
656
662
|
switch (ev.keyCode) {
|
657
|
-
case
|
658
|
-
|
663
|
+
case 65: // Ctrl-A
|
664
|
+
if (ev.ctrlKey) {
|
665
|
+
this.setInput(this._input, 0);
|
666
|
+
ev.preventDefault();
|
667
|
+
}
|
668
|
+
break;
|
669
|
+
|
670
|
+
case 69: // Ctrl-E
|
659
671
|
if (ev.ctrlKey) {
|
660
672
|
this.onTabKey();
|
661
673
|
ev.preventDefault();
|
662
674
|
}
|
663
675
|
break;
|
664
|
-
|
665
|
-
|
676
|
+
|
677
|
+
case 87: // Ctrl-W
|
678
|
+
if (ev.ctrlKey) {
|
679
|
+
this.deleteWord();
|
680
|
+
ev.preventDefault();
|
681
|
+
}
|
682
|
+
break;
|
683
|
+
|
684
|
+
case 85: // Ctrl-U
|
685
|
+
if (ev.ctrlKey) {
|
686
|
+
this.deleteLine();
|
687
|
+
ev.preventDefault();
|
688
|
+
}
|
689
|
+
break;
|
690
|
+
|
691
|
+
case 69: // Ctrl-E
|
692
|
+
if (ev.ctrlKey) {
|
693
|
+
this.onTabKey();
|
694
|
+
ev.preventDefault();
|
695
|
+
}
|
696
|
+
break;
|
697
|
+
|
698
|
+
case 80: // Ctrl-P
|
699
|
+
if (! ev.ctrlKey) break;
|
700
|
+
|
701
|
+
case 78: // Ctrl-N
|
702
|
+
if (! ev.ctrlKey) break;
|
703
|
+
|
704
|
+
case 9: // Tab
|
666
705
|
this.onTabKey();
|
667
706
|
ev.preventDefault();
|
668
707
|
break;
|
669
|
-
|
670
|
-
|
708
|
+
|
709
|
+
case 13: // Enter key
|
671
710
|
this.onEnterKey();
|
672
711
|
ev.preventDefault();
|
673
712
|
break;
|
674
|
-
|
675
|
-
|
676
|
-
if (! ev.ctrlKey) break;
|
677
|
-
case 38:
|
678
|
-
// Up arrow
|
713
|
+
|
714
|
+
case 38: // Up arrow
|
679
715
|
this.onNavigateHistory(-1);
|
680
716
|
ev.preventDefault();
|
681
717
|
break;
|
682
|
-
|
683
|
-
|
684
|
-
if (! ev.ctrlKey) break;
|
685
|
-
case 40:
|
686
|
-
// Down arrow
|
718
|
+
|
719
|
+
case 40: // Down arrow
|
687
720
|
this.onNavigateHistory(1);
|
688
721
|
ev.preventDefault();
|
689
722
|
break;
|
690
|
-
|
691
|
-
|
723
|
+
|
724
|
+
case 37: // Left arrow
|
692
725
|
var caretPos = this._caretPos > 0 ? this._caretPos - 1 : this._caretPos;
|
693
726
|
this.setInput(this._input, caretPos);
|
694
727
|
ev.preventDefault();
|
695
728
|
break;
|
696
|
-
|
697
|
-
|
729
|
+
|
730
|
+
case 39: // Right arrow
|
698
731
|
var length = this._input.length;
|
699
732
|
var caretPos = this._caretPos < length ? this._caretPos + 1 : this._caretPos;
|
700
733
|
this.setInput(this._input, caretPos);
|
701
734
|
ev.preventDefault();
|
702
735
|
break;
|
703
|
-
|
704
|
-
|
736
|
+
|
737
|
+
case 8: // Delete
|
705
738
|
this.deleteAtCurrent();
|
706
739
|
ev.preventDefault();
|
707
740
|
break;
|
741
|
+
|
708
742
|
default:
|
709
743
|
break;
|
710
744
|
}
|
@@ -757,6 +791,47 @@ REPLConsole.prototype.deleteAtCurrent = function() {
|
|
757
791
|
}
|
758
792
|
};
|
759
793
|
|
794
|
+
/**
|
795
|
+
* Deletes the current line.
|
796
|
+
*/
|
797
|
+
REPLConsole.prototype.deleteLine = function() {
|
798
|
+
if (this._caretPos > 0) {
|
799
|
+
this.setInput("", 0);
|
800
|
+
|
801
|
+
if (!this._input) {
|
802
|
+
this.autocomplete && this.autocomplete.cancel();
|
803
|
+
this.autocomplete = false;
|
804
|
+
}
|
805
|
+
}
|
806
|
+
};
|
807
|
+
|
808
|
+
/**
|
809
|
+
* Deletes the current word.
|
810
|
+
*/
|
811
|
+
REPLConsole.prototype.deleteWord = function() {
|
812
|
+
if (this._caretPos > 0) {
|
813
|
+
var i = 1, current = this._caretPos;
|
814
|
+
while (this._input[current - i++] == " ");
|
815
|
+
|
816
|
+
var deleteIndex = 0;
|
817
|
+
for (; current - i > 0; i++) {
|
818
|
+
if (this._input[current - i] == " ") {
|
819
|
+
deleteIndex = current - i;
|
820
|
+
break;
|
821
|
+
}
|
822
|
+
}
|
823
|
+
|
824
|
+
var before = this._input.substring(0, deleteIndex);
|
825
|
+
var after = this._input.substring(current, this._input.length);
|
826
|
+
this.setInput(before + after, deleteIndex);
|
827
|
+
|
828
|
+
if (!this._input) {
|
829
|
+
this.autocomplete && this.autocomplete.cancel();
|
830
|
+
this.autocomplete = false;
|
831
|
+
}
|
832
|
+
}
|
833
|
+
};
|
834
|
+
|
760
835
|
/**
|
761
836
|
* Insert a character at the current position.
|
762
837
|
*/
|
@@ -795,11 +870,16 @@ REPLConsole.prototype.scrollToBottom = function() {
|
|
795
870
|
this.outer.scrollTop = this.outer.scrollHeight;
|
796
871
|
};
|
797
872
|
|
798
|
-
// Change the binding of the console
|
873
|
+
// Change the binding of the console.
|
799
874
|
REPLConsole.prototype.switchBindingTo = function(frameId, callback) {
|
800
875
|
var url = this.getSessionUrl('trace');
|
801
876
|
var params = "frame_id=" + encodeURIComponent(frameId);
|
802
|
-
|
877
|
+
|
878
|
+
var _this = this;
|
879
|
+
postRequest(url, params, function() {
|
880
|
+
var text = "Context has changed to: " + callback();
|
881
|
+
_this.writeNotification(text);
|
882
|
+
});
|
803
883
|
};
|
804
884
|
|
805
885
|
/**
|
@@ -11,12 +11,9 @@ for (var i = 0; i < traceFrames.length; i++) {
|
|
11
11
|
|
12
12
|
// Change the binding of the console.
|
13
13
|
changeBinding(frameId, function() {
|
14
|
-
|
15
|
-
selectedFrame.className = selectedFrame.className.replace("selected", "");
|
16
|
-
}
|
17
|
-
|
18
|
-
target.className += " selected";
|
14
|
+
// Rails already handles toggling the select class
|
19
15
|
selectedFrame = target;
|
16
|
+
return target.innerHTML;
|
20
17
|
});
|
21
18
|
|
22
19
|
// Change the extracted source code
|
@@ -24,6 +21,7 @@ for (var i = 0; i < traceFrames.length; i++) {
|
|
24
21
|
});
|
25
22
|
}
|
26
23
|
|
24
|
+
// Change the binding of the current session and prompt the user.
|
27
25
|
function changeBinding(frameId, callback) {
|
28
26
|
REPLConsole.currentSession.switchBindingTo(frameId, callback);
|
29
27
|
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
// Push the error page body upwards the size of the console.
|
2
|
+
document.addEventListener('DOMContentLoaded', function() {
|
3
|
+
var consoleElement = document.getElementById('console');
|
4
|
+
var resizerElement = consoleElement.getElementsByClassName('resizer')[0];
|
5
|
+
var bodyElement = document.body;
|
6
|
+
|
7
|
+
function setBodyElementBottomMargin(pixels) {
|
8
|
+
bodyElement.style.marginBottom = pixels + 'px';
|
9
|
+
}
|
10
|
+
|
11
|
+
var currentConsoleElementHeight = consoleElement.offsetHeight;
|
12
|
+
setBodyElementBottomMargin(currentConsoleElementHeight);
|
13
|
+
|
14
|
+
resizerElement.addEventListener('mousedown', function(event) {
|
15
|
+
function recordConsoleElementHeight(event) {
|
16
|
+
resizerElement.removeEventListener('mouseup', recordConsoleElementHeight);
|
17
|
+
|
18
|
+
var currentConsoleElementHeight = consoleElement.offsetHeight;
|
19
|
+
setBodyElementBottomMargin(currentConsoleElementHeight);
|
20
|
+
}
|
21
|
+
|
22
|
+
resizerElement.addEventListener('mouseup', recordConsoleElementHeight);
|
23
|
+
});
|
24
|
+
});
|
@@ -10,7 +10,8 @@
|
|
10
10
|
.console .console-inner { font-family: monospace; font-size: 11px; width: 100%; height: 100%; overflow: none; background: #333; }
|
11
11
|
.console .console-prompt-box { color: #FFF; }
|
12
12
|
.console .console-message { color: #1AD027; margin: 0; border: 0; white-space: pre-wrap; background-color: #333; padding: 0; }
|
13
|
-
.console .console-message.error-message { color: #
|
13
|
+
.console .console-message.error-message { color: #FC9; }
|
14
|
+
.console .console-message.notification-message { color: #99F; }
|
14
15
|
.console .console-message.auto-complete { word-break: break-all; }
|
15
16
|
.console .console-message.auto-complete .keyword { margin-right: 11px; }
|
16
17
|
.console .console-message.auto-complete .keyword.selected { background: #FFF; color: #000; }
|
@@ -21,8 +22,8 @@
|
|
21
22
|
.console .resizer { background: #333; width: 100%; height: 4px; cursor: ns-resize; }
|
22
23
|
.console .console-actions { padding-right: 3px; }
|
23
24
|
.console .console-actions .button { float: left; }
|
24
|
-
.console .button { cursor: pointer; border-radius: 1px; font-family: monospace; font-size: 13px; width: 14px; height: 14px; line-height: 14px; text-align: center; color: #
|
25
|
-
.console .button:hover { background: #666; color: #
|
25
|
+
.console .button { cursor: pointer; border-radius: 1px; font-family: monospace; font-size: 13px; width: 14px; height: 14px; line-height: 14px; text-align: center; color: #CCC; }
|
26
|
+
.console .button:hover { background: #666; color: #FFF; }
|
26
27
|
.console .button.close-button:hover { background: #966; }
|
27
28
|
.console .clipboard { height: 0px; padding: 0px; margin: 0px; width: 0px; margin-left: -1000px; }
|
28
29
|
.console .console-prompt-label { display: inline; color: #FFF; background: none repeat scroll 0% 0% #333; border: 0; padding: 0; }
|
data/lib/web_console/version.rb
CHANGED
data/lib/web_console/view.rb
CHANGED
@@ -10,6 +10,11 @@ module WebConsole
|
|
10
10
|
yield if Thread.current[:__web_console_exception].present?
|
11
11
|
end
|
12
12
|
|
13
|
+
# Execute a block only on regular, non-error, pages.
|
14
|
+
def only_on_regular_page(*args)
|
15
|
+
yield if Thread.current[:__web_console_binding].present?
|
16
|
+
end
|
17
|
+
|
13
18
|
# Render JavaScript inside a script tag and a closure.
|
14
19
|
#
|
15
20
|
# This one lets write JavaScript that will automatically get wrapped in a
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Somerville
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-09-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/web_console/templates/layouts/inlined_string.erb
|
109
109
|
- lib/web_console/templates/layouts/javascript.erb
|
110
110
|
- lib/web_console/templates/main.js.erb
|
111
|
+
- lib/web_console/templates/regular_page.js.erb
|
111
112
|
- lib/web_console/templates/style.css.erb
|
112
113
|
- lib/web_console/testing/erb_precompiler.rb
|
113
114
|
- lib/web_console/testing/fake_middleware.rb
|
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
139
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.7.
|
140
|
+
rubygems_version: 2.7.6
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
143
|
summary: A debugging tool for your Ruby on Rails applications.
|