browser_app_base 0.0.4 → 0.0.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/lib/browser_app_base/version.rb +1 -1
- data/lib/browser_app_base.rb +17 -2
- data/lib/template/config.ru +1 -1
- data/lib/template/css/index.css +14 -10
- data/lib/template/index.html +6 -3
- data/lib/template/js/main.js +23 -9
- data/lib/template/server.rb +2 -1
- data/lib/template/start.rb +1 -1
- data/lib/template/wsserver.rb +22 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3565687a000a2d7a0636d2ac47c09de24d87cfe1554777b58d8f9d9ab494102d
|
4
|
+
data.tar.gz: a305213755edff63ab70edff0f2011d52c33ee6fd53b9aaddce80865440107c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f2cb63d6ff01e6bb39731fd36944a8a4ff96c9b5370ed9b386383bc6c67fe55586d1e6f278d8af17713b542079f1850de0afd820c9b78357d7afc4debb63d8
|
7
|
+
data.tar.gz: 200b7d9a67ef7421f52a2d3887b91d3d9c5ab99eda27ccebbf1725718204d25945bc0f31679811d0d4e959561ebed2906de8b98900c9272f80196b6fa9f7640a
|
data/lib/browser_app_base.rb
CHANGED
@@ -19,6 +19,18 @@ module BrowserAppBase
|
|
19
19
|
return app_file_name + ".rb"
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.get_app_name(app)
|
23
|
+
app_name = ""
|
24
|
+
app.each_char do |s|
|
25
|
+
if s =~ /[a-z]/ and app_name.size == 0
|
26
|
+
app_name += s.upcase
|
27
|
+
else
|
28
|
+
app_name += s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
return app_name
|
32
|
+
end
|
33
|
+
|
22
34
|
def self.create(arg)
|
23
35
|
dir = arg[:dir]
|
24
36
|
app = arg[:app]
|
@@ -37,7 +49,7 @@ module BrowserAppBase
|
|
37
49
|
|
38
50
|
load_app = <<"EOS"
|
39
51
|
require '#{app_file}'
|
40
|
-
$app =
|
52
|
+
$app = #{get_app_name(app)}.new
|
41
53
|
EOS
|
42
54
|
|
43
55
|
File.open("#{dir}/app_load.rb", "w") do |f|
|
@@ -45,7 +57,10 @@ EOS
|
|
45
57
|
end
|
46
58
|
|
47
59
|
puts "create #{app_file}"
|
48
|
-
|
60
|
+
new_file = "#{dir}/#{app_file}"
|
61
|
+
FileUtils.cp("#{dir}/my_app_sample.rb", new_file)
|
62
|
+
buf = File.binread(new_file)
|
63
|
+
File.binwrite(new_file, buf.gsub(/MyApp/, get_app_name(app)))
|
49
64
|
end
|
50
65
|
end
|
51
66
|
end
|
data/lib/template/config.ru
CHANGED
data/lib/template/css/index.css
CHANGED
@@ -22,9 +22,9 @@ hr {
|
|
22
22
|
padding: 5px;
|
23
23
|
width: 95vw;
|
24
24
|
height: 50vh;
|
25
|
+
overflow: auto;
|
25
26
|
}
|
26
27
|
|
27
|
-
|
28
28
|
.inarea {
|
29
29
|
border: thin solid #000000;
|
30
30
|
margin: 5px;
|
@@ -32,12 +32,6 @@ hr {
|
|
32
32
|
width: 95%;
|
33
33
|
}
|
34
34
|
|
35
|
-
input {
|
36
|
-
background-color: #FAFAFA;
|
37
|
-
margin: 5px;
|
38
|
-
padding: 5px;
|
39
|
-
}
|
40
|
-
|
41
35
|
input.long {
|
42
36
|
width: 90%;
|
43
37
|
background-color: #FAFAFA;
|
@@ -50,18 +44,22 @@ textarea.long {
|
|
50
44
|
height: 50vh;
|
51
45
|
}
|
52
46
|
|
47
|
+
.ui-widget {
|
48
|
+
font-size: 12px;
|
49
|
+
}
|
50
|
+
|
53
51
|
.ui-autocomplete {
|
54
52
|
max-height: 200px;
|
55
53
|
max-width: 500px;
|
56
54
|
overflow-y: auto;
|
57
|
-
overflow-x:
|
58
|
-
padding-right:
|
55
|
+
overflow-x: auto;
|
56
|
+
padding-right: 10px;
|
59
57
|
}
|
58
|
+
|
60
59
|
#jquery-ui-autocomplete label {
|
61
60
|
float: left;
|
62
61
|
margin-right: 0.5em;
|
63
62
|
color: black;
|
64
|
-
font-size: 15px;
|
65
63
|
}
|
66
64
|
|
67
65
|
.ui-dialog {
|
@@ -96,4 +94,10 @@ textarea.long {
|
|
96
94
|
.setting_checkbox {
|
97
95
|
color: #796fe9;
|
98
96
|
background-color: #000000;
|
97
|
+
}
|
98
|
+
|
99
|
+
ul.log {
|
100
|
+
list-style-type: decimal;
|
101
|
+
font-size: 10px;
|
102
|
+
color: #5d0a94;
|
99
103
|
}
|
data/lib/template/index.html
CHANGED
@@ -11,8 +11,8 @@
|
|
11
11
|
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
12
12
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
|
13
13
|
|
14
|
-
<script src="http://localhost:
|
15
|
-
<link rel="stylesheet" href="http://localhost:
|
14
|
+
<script src="http://localhost:52538/js/main.js"></script>
|
15
|
+
<link rel="stylesheet" href="http://localhost:52538/css/index.css" type="text/css">
|
16
16
|
</head>
|
17
17
|
|
18
18
|
<body>
|
@@ -55,7 +55,10 @@
|
|
55
55
|
</tr>
|
56
56
|
</table>
|
57
57
|
|
58
|
-
<
|
58
|
+
<div class="outarea">
|
59
|
+
<ul name="log" id="log" class="log">
|
60
|
+
</ul>
|
61
|
+
</div>
|
59
62
|
|
60
63
|
</body>
|
61
64
|
|
data/lib/template/js/main.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
// main.js
|
2
2
|
|
3
3
|
var $ws = null;
|
4
|
+
var $auto_scroll = true;
|
4
5
|
|
5
6
|
function server_connect(url) {
|
6
7
|
var ws = new WebSocket(url);
|
@@ -14,14 +15,12 @@ function server_connect(url) {
|
|
14
15
|
file_name = evt.data.replace(/^startup:/, "");
|
15
16
|
//alert(file_name);
|
16
17
|
} else {
|
17
|
-
var log =
|
18
|
-
$('#log').
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
);
|
18
|
+
var log = "<li>" + evt.data + "</li>";
|
19
|
+
$('#log').append(log);
|
20
|
+
if ($auto_scroll) {
|
21
|
+
$('.outarea').scrollTop($('.outarea').get(0).scrollHeight);
|
22
|
+
}
|
23
23
|
}
|
24
|
-
|
25
24
|
};
|
26
25
|
ws.onclose = function () {
|
27
26
|
alert("アプリケーションが終了しました!!");
|
@@ -51,7 +50,7 @@ function autocomp(id, file_kind) {
|
|
51
50
|
},
|
52
51
|
source: function (req, resp) {
|
53
52
|
$.ajax({
|
54
|
-
url: "http://localhost:
|
53
|
+
url: "http://localhost:52538/search?path=" + $("#" + id).val() + "&kind=" + file_kind,
|
55
54
|
type: "GET",
|
56
55
|
cache: false,
|
57
56
|
dataType: "json",
|
@@ -222,7 +221,7 @@ function dispFile() {
|
|
222
221
|
// 起動時の処理
|
223
222
|
$(document).ready(function () {
|
224
223
|
// サーバに接続
|
225
|
-
server_connect("ws://localhost:
|
224
|
+
server_connect("ws://localhost:52538/wsserver")
|
226
225
|
// ウインドウサイズ
|
227
226
|
var width = 800;
|
228
227
|
var height = 600;
|
@@ -233,12 +232,27 @@ $(document).ready(function () {
|
|
233
232
|
//window.moveTo(0,0);
|
234
233
|
});
|
235
234
|
|
235
|
+
$('.outarea').scroll(function () {
|
236
|
+
var h = $('.outarea').get(0).scrollHeight - $('.outarea').innerHeight();
|
237
|
+
console.log("scrollEnd=" + Math.abs($('.outarea').scrollTop() - h));
|
238
|
+
if (Math.abs($('.outarea').scrollTop() - h) < 5) {
|
239
|
+
// 最後までスクロールしている
|
240
|
+
// 自動スクロールON
|
241
|
+
$auto_scroll = true;
|
242
|
+
} else {
|
243
|
+
// 自動スクロールOFF
|
244
|
+
$auto_scroll = false;
|
245
|
+
}
|
246
|
+
//console.log("auto_scroll=" + $auto_scroll);
|
247
|
+
});
|
248
|
+
|
236
249
|
// ハンドラ登録
|
237
250
|
$("#stop").click(function () {
|
238
251
|
send_message("stop");
|
239
252
|
});
|
240
253
|
|
241
254
|
$("#exec").click(function () {
|
255
|
+
$('#log').empty();
|
242
256
|
send_message("exec:" + $("#upFile").val());
|
243
257
|
});
|
244
258
|
|
data/lib/template/server.rb
CHANGED
@@ -48,7 +48,8 @@ class Search < Sinatra::Base
|
|
48
48
|
data = {}
|
49
49
|
next if File.basename(file) == "."
|
50
50
|
next if kind == "dir" and !File.directory?(file)
|
51
|
-
data["label"] = File.
|
51
|
+
data["label"] = File.basename(file)
|
52
|
+
data["label"] += "/" if (File.directory?(file))
|
52
53
|
data["value"] = File.expand_path(file)
|
53
54
|
res.push data
|
54
55
|
end
|
data/lib/template/start.rb
CHANGED
data/lib/template/wsserver.rb
CHANGED
@@ -12,6 +12,7 @@ end
|
|
12
12
|
class WsServer < Sinatra::Base
|
13
13
|
$ws_list = []
|
14
14
|
json_config = nil
|
15
|
+
exec_thread = nil
|
15
16
|
get "" do
|
16
17
|
if !request.websocket?
|
17
18
|
"no supported"
|
@@ -24,24 +25,33 @@ class WsServer < Sinatra::Base
|
|
24
25
|
ws.onmessage do |msg|
|
25
26
|
puts msg
|
26
27
|
if msg =~ /^exec:/
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
if exec_thread == nil
|
29
|
+
json = JSON.parse(File.read("config/setting.json"))
|
30
|
+
json_config = config_json_hash(json)
|
31
|
+
$app.set_config(json_config)
|
32
|
+
argv = msg.gsub(/^exec:/, "")
|
33
|
+
exec_thread = Thread.new {
|
34
|
+
$app.start(argv.split(",")) do |out|
|
35
|
+
ws.send(out)
|
36
|
+
end
|
37
|
+
exec_thread = nil
|
38
|
+
}
|
39
|
+
end
|
36
40
|
end
|
37
41
|
if msg =~ /^stop/
|
38
|
-
|
42
|
+
if exec_thread
|
43
|
+
$app.stop
|
44
|
+
end
|
39
45
|
end
|
40
46
|
if msg =~ /^suspend/
|
41
|
-
|
47
|
+
if exec_thread
|
48
|
+
$app.suspend
|
49
|
+
end
|
42
50
|
end
|
43
51
|
if msg =~ /^resume/
|
44
|
-
|
52
|
+
if exec_thread
|
53
|
+
$app.resume
|
54
|
+
end
|
45
55
|
end
|
46
56
|
if msg =~ /^setting:/
|
47
57
|
json_string = msg.gsub(/^setting:/, "")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browser_app_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masataka kuwayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|