tailog 0.4.3 → 0.4.5
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/.codeclimate.yml +2 -0
- data/README.md +4 -0
- data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.svg +288 -0
- data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/assets/javascripts/ansi_up.js +1 -321
- data/app/assets/javascripts/jquery.form.js +11 -0
- data/app/assets/javascripts/jquery.highlight.js +1 -142
- data/app/assets/javascripts/jquery.js +16 -0
- data/app/assets/stylesheets/application.css +5 -1
- data/app/assets/stylesheets/bootstrap.css +5 -0
- data/app/views/layout.erb +4 -4
- data/app/views/logs/index.erb +34 -11
- data/lib/tailog/eval.rb +8 -2
- data/lib/tailog/version.rb +1 -1
- data/lib/tailog/watch_methods.rb +7 -0
- metadata +12 -3
data/app/views/logs/index.erb
CHANGED
@@ -32,6 +32,17 @@
|
|
32
32
|
</div>
|
33
33
|
|
34
34
|
<script type="text/javascript">
|
35
|
+
String.prototype.hashCode = function(){
|
36
|
+
var hash = 0;
|
37
|
+
if (this.length == 0) return "0000000";
|
38
|
+
for (i = 0; i < this.length; i++) {
|
39
|
+
char = this.charCodeAt(i);
|
40
|
+
hash = ((hash<<5)-hash)+char;
|
41
|
+
hash = hash & hash; // Convert to 32bit integer
|
42
|
+
}
|
43
|
+
return ("0000000" + (hash >>> 0).toString(16)).substr(-8);
|
44
|
+
}
|
45
|
+
|
35
46
|
var $settingsPanel = $("#settings-panel");
|
36
47
|
$("#settings-toggle").click(function() {
|
37
48
|
$settingsPanel.toggleClass("hidden");
|
@@ -49,18 +60,28 @@
|
|
49
60
|
var $highlight = $("#highlight"),
|
50
61
|
$highlightList = $("#highlight-list");
|
51
62
|
|
63
|
+
function highlightClassname(keyword) {
|
64
|
+
return 'highlight-' + keyword.hashCode();
|
65
|
+
}
|
66
|
+
|
52
67
|
function rawHighlight(keyword) {
|
53
|
-
$content.highlight(keyword, { className: 'highlight
|
68
|
+
$content.highlight(keyword, { className: 'highlight ' + highlightClassname(keyword) });
|
54
69
|
}
|
55
70
|
|
56
71
|
function rawUnhighlight(keyword) {
|
57
|
-
$content.unhighlight({ className:
|
72
|
+
$content.unhighlight({ className: highlightClassname(keyword) });
|
58
73
|
}
|
59
74
|
|
75
|
+
var highlightColors = ['#FFFF88', '#FF88FF', '#88FFFF', '#CCCCFF', '#CCFFCC', '#FFCCCC'];
|
60
76
|
function highlight(keyword) {
|
61
|
-
|
77
|
+
var color = highlightColors[$highlightList.find("span").length % highlightColors.length];
|
78
|
+
var classname = highlightClassname(keyword);
|
79
|
+
|
80
|
+
if ($highlightList.find('.' + classname).length > 0) return;
|
62
81
|
rawHighlight(keyword);
|
63
|
-
$highlightList.append('<
|
82
|
+
$highlightList.append('<div class="label label-primary ' + classname + '"><span>' + keyword + '</span><em>•</em></div>');
|
83
|
+
|
84
|
+
$('body').append('<style>.highlight.' + classname + '{background-color:' + color + ';} .label.' + classname + '>em{color:' + color + ';}</style>');
|
64
85
|
}
|
65
86
|
|
66
87
|
$highlight.keypress(function(event) {
|
@@ -72,11 +93,12 @@
|
|
72
93
|
highlight($highlight.val());
|
73
94
|
});
|
74
95
|
|
75
|
-
$("#highlight-list").on("click", ".
|
96
|
+
$("#highlight-list").on("click", ".label", function(event) {
|
76
97
|
var $this = $(this),
|
77
|
-
keyword = $this.text();
|
78
|
-
|
79
|
-
$this.
|
98
|
+
keyword = $this.find('span').text();
|
99
|
+
|
100
|
+
$this.hasClass('highlight-hidden') ? rawHighlight(keyword) : rawUnhighlight(keyword);
|
101
|
+
$this.toggleClass('highlight-hidden');
|
80
102
|
});
|
81
103
|
|
82
104
|
window.fileSize = {};
|
@@ -101,9 +123,10 @@
|
|
101
123
|
.append('<span class="text-info">' + data.server_hostname + ' - ' + data.file_size + '</span>')
|
102
124
|
.append(ansi_up.ansi_to_html(data.content));
|
103
125
|
|
104
|
-
$highlightList.find("
|
105
|
-
var $node = $(node)
|
106
|
-
|
126
|
+
$highlightList.find(".label").each(function(index, node) {
|
127
|
+
var $node = $(node),
|
128
|
+
keyword = $node.find('span').text();
|
129
|
+
$node.hasClass('highlight-hidden') || rawHighlight(keyword);
|
107
130
|
});
|
108
131
|
|
109
132
|
if (shouldScrollToBottom) {
|
data/lib/tailog/eval.rb
CHANGED
@@ -16,11 +16,17 @@ module Tailog
|
|
16
16
|
else
|
17
17
|
before = env["HTTP_TAILOG_EVAL_BEFORE"].presence
|
18
18
|
after = env["HTTP_TAILOG_EVAL_AFTER"].presence
|
19
|
+
inject = env["HTTP_TAILOG_INJECT"].presence
|
20
|
+
inject_options = env["HTTP_TAILOG_INJECT_OPTIONS"].present? ? JSON.parse(env["HTTP_TAILOG_INJECT_OPTIONS"]).symbolize_keys : Hash.new
|
19
21
|
|
20
22
|
binding = Object.new.send(:binding)
|
21
|
-
binding.eval
|
23
|
+
binding.eval(before) if before
|
24
|
+
Tailog.inject(inject.split(" "), inject_options) rescue nil if inject
|
25
|
+
|
22
26
|
response = @app.call(env)
|
23
|
-
|
27
|
+
|
28
|
+
Tailog.cleanup(inject.split(" ")) if inject
|
29
|
+
binding.eval(after) if after
|
24
30
|
|
25
31
|
response
|
26
32
|
end
|
data/lib/tailog/version.rb
CHANGED
data/lib/tailog/watch_methods.rb
CHANGED
@@ -34,6 +34,7 @@ module Tailog
|
|
34
34
|
}
|
35
35
|
|
36
36
|
def inject targets, options = {}
|
37
|
+
WatchMethods.logger.debug "Inject #{targets} with options #{options}."
|
37
38
|
options = Tailog::WatchMethods.inject_options.merge(options)
|
38
39
|
targets.each do |target|
|
39
40
|
begin
|
@@ -51,6 +52,7 @@ module Tailog
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def cleanup targets
|
55
|
+
WatchMethods.logger.debug "Cleanup #{targets}."
|
54
56
|
targets.each do |target|
|
55
57
|
if target.include? "#"
|
56
58
|
cleanup_instance_method target
|
@@ -71,6 +73,11 @@ module Tailog
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def inject_constant target, options
|
76
|
+
unless const_defined? target
|
77
|
+
WatchMethods.logger.error "Inject #{target} FAILED: NameError: uninitialized constant #{target}."
|
78
|
+
return
|
79
|
+
end
|
80
|
+
|
74
81
|
constant = target.constantize
|
75
82
|
constant.instance_methods(false).each do |method|
|
76
83
|
inject_instance_method "#{target}##{method}", options unless raw_method? method
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bbtfr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -59,14 +59,23 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".codeclimate.yml"
|
62
63
|
- ".gitignore"
|
63
64
|
- Gemfile
|
64
65
|
- LICENSE.md
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
68
|
+
- app/assets/fonts/glyphicons-halflings-regular.eot
|
69
|
+
- app/assets/fonts/glyphicons-halflings-regular.svg
|
70
|
+
- app/assets/fonts/glyphicons-halflings-regular.ttf
|
71
|
+
- app/assets/fonts/glyphicons-halflings-regular.woff
|
72
|
+
- app/assets/fonts/glyphicons-halflings-regular.woff2
|
67
73
|
- app/assets/javascripts/ansi_up.js
|
74
|
+
- app/assets/javascripts/jquery.form.js
|
68
75
|
- app/assets/javascripts/jquery.highlight.js
|
76
|
+
- app/assets/javascripts/jquery.js
|
69
77
|
- app/assets/stylesheets/application.css
|
78
|
+
- app/assets/stylesheets/bootstrap.css
|
70
79
|
- app/views/env.erb
|
71
80
|
- app/views/error.erb
|
72
81
|
- app/views/layout.erb
|
@@ -105,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
114
|
version: '0'
|
106
115
|
requirements: []
|
107
116
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.5.1
|
109
118
|
signing_key:
|
110
119
|
specification_version: 4
|
111
120
|
summary: tail -f to the web-browser
|