browser_app_base 0.0.3 → 0.0.4
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 +2 -2
- data/lib/template/config/browser.json +1 -1
- data/lib/template/config/setting.json +50 -0
- data/lib/template/config.ru +7 -1
- data/lib/template/css/index.css +22 -0
- data/lib/template/index.html +8 -2
- data/lib/template/js/main.js +109 -7
- data/lib/template/my_app_sample.rb +1 -0
- data/lib/template/server_app_base.rb +5 -0
- data/lib/template/start.rb +2 -2
- data/lib/template/wsserver.rb +22 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c4fbbeb0ae9c43190f17913cc4b4a0ae6e5ce22d5679ae03c3d86f036320e9e
|
4
|
+
data.tar.gz: 26cb090a78db468621454e6bf2b8dfdeede2cecc56791b66faf206dfe1bbb3b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1952a3ad99cc4812aea6f994561d479891d4ca8ce367138096265da4e5547e5906dc2ceabe704ff1ac18b5745b99571c8490a26355513665d08360c541891f66
|
7
|
+
data.tar.gz: 8e2e90765d52c0cccf5e0c4648180b128b300b2dd1d13036b9b50e770c59dfd371991e3fb0c211a41508ea4e5ab73b82cc4ef186ba5555fd77df0589552ed067
|
data/lib/browser_app_base.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "name1",
|
4
|
+
"value": "value1",
|
5
|
+
"type": "input",
|
6
|
+
"select": "",
|
7
|
+
"description": "設定項目1"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"name": "name2",
|
11
|
+
"value": true,
|
12
|
+
"type": "checkbox",
|
13
|
+
"select": "",
|
14
|
+
"description": "有効にする場合はチェック"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"name": "name3",
|
18
|
+
"value": "1",
|
19
|
+
"type": "select",
|
20
|
+
"select": [
|
21
|
+
"1",
|
22
|
+
"2",
|
23
|
+
"3",
|
24
|
+
"4",
|
25
|
+
"5"
|
26
|
+
],
|
27
|
+
"description": "選択項目"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "name4",
|
31
|
+
"value": "value4",
|
32
|
+
"type": "input",
|
33
|
+
"select": "",
|
34
|
+
"description": "設定項目4"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"name": "name5",
|
38
|
+
"value": "value5",
|
39
|
+
"type": "input",
|
40
|
+
"select": "",
|
41
|
+
"description": "設定項目5"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"name": "name6",
|
45
|
+
"value": "value6",
|
46
|
+
"type": "input",
|
47
|
+
"select": "",
|
48
|
+
"description": "設定項目6"
|
49
|
+
}
|
50
|
+
]
|
data/lib/template/config.ru
CHANGED
@@ -24,6 +24,12 @@ get "/js/:name.js" do
|
|
24
24
|
File.read "js/#{params[:name]}.js"
|
25
25
|
end
|
26
26
|
|
27
|
+
get "/config/*.*" do |file, ext|
|
28
|
+
content_type "text/json", :charset => "utf-8"
|
29
|
+
puts "#{file}.#{ext}"
|
30
|
+
File.read "config/#{file}.#{ext}"
|
31
|
+
end
|
32
|
+
|
27
33
|
map "/search" do
|
28
34
|
run Search
|
29
35
|
end
|
@@ -46,6 +52,6 @@ configure do
|
|
46
52
|
|
47
53
|
end
|
48
54
|
|
49
|
-
#\ --port
|
55
|
+
#\ --port 64141
|
50
56
|
|
51
57
|
run Sinatra::Application
|
data/lib/template/css/index.css
CHANGED
@@ -74,4 +74,26 @@ textarea.long {
|
|
74
74
|
|
75
75
|
.long {
|
76
76
|
width: 90%;
|
77
|
+
}
|
78
|
+
|
79
|
+
#setting_dialog {
|
80
|
+
color: #796fe9;
|
81
|
+
background-color: #000000;
|
82
|
+
}
|
83
|
+
|
84
|
+
.setting_name {
|
85
|
+
width: 200px;
|
86
|
+
color: #796fe9;
|
87
|
+
background-color: #000000;
|
88
|
+
}
|
89
|
+
|
90
|
+
.setting_value {
|
91
|
+
width: 300px;
|
92
|
+
color: #796fe9;
|
93
|
+
background-color: #000000;
|
94
|
+
}
|
95
|
+
|
96
|
+
.setting_checkbox {
|
97
|
+
color: #796fe9;
|
98
|
+
background-color: #000000;
|
77
99
|
}
|
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:64141/js/main.js"></script>
|
15
|
+
<link rel="stylesheet" href="http://localhost:64141/css/index.css" type="text/css">
|
16
16
|
</head>
|
17
17
|
|
18
18
|
<body>
|
@@ -26,6 +26,12 @@
|
|
26
26
|
<td>
|
27
27
|
<input type="button" id="stop" name="stop" value="停止">
|
28
28
|
</td>
|
29
|
+
<td>
|
30
|
+
<div id="setting_dialog" style="display:none;">
|
31
|
+
<dl id="wrap"></dl>
|
32
|
+
</div>
|
33
|
+
<input type="button" id="setting" value="設定" />
|
34
|
+
</td>
|
29
35
|
</tr>
|
30
36
|
</table>
|
31
37
|
|
data/lib/template/js/main.js
CHANGED
@@ -51,7 +51,7 @@ function autocomp(id, file_kind) {
|
|
51
51
|
},
|
52
52
|
source: function (req, resp) {
|
53
53
|
$.ajax({
|
54
|
-
url: "http://localhost:
|
54
|
+
url: "http://localhost:64141/search?path=" + $("#" + id).val() + "&kind=" + file_kind,
|
55
55
|
type: "GET",
|
56
56
|
cache: false,
|
57
57
|
dataType: "json",
|
@@ -68,17 +68,14 @@ function autocomp(id, file_kind) {
|
|
68
68
|
|
69
69
|
}
|
70
70
|
}).focus(function () {
|
71
|
-
console.log("forcus");
|
72
71
|
//jQuery(this).autocomplete("search", "");
|
73
72
|
$(this).keydown();
|
74
73
|
});
|
75
74
|
}
|
76
75
|
|
77
76
|
function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_name) {
|
78
|
-
console.log("select_file_dialog select_file=" + select_file);
|
79
77
|
$("#" + select_file).click(function () {
|
80
78
|
autocomp(search_id, file_kind);
|
81
|
-
console.log("open dialog dialog_id=", dialog_id);
|
82
79
|
$(".ui-autocomplete").css("z-index", 1000);
|
83
80
|
$("#" + search_id).val("/");
|
84
81
|
$("#" + dialog_id).dialog({
|
@@ -88,9 +85,9 @@ function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_n
|
|
88
85
|
, title: "Select File" //ダイアログのタイトル
|
89
86
|
, width: 580 //ダイアログの横幅
|
90
87
|
, height: 400 //ダイアログの高さ
|
91
|
-
, resizable:
|
88
|
+
, resizable: true //リサイズ可
|
92
89
|
, closeOnEscape: false //[ESC]キーで閉じられなくする
|
93
|
-
, draggable:
|
90
|
+
, draggable: true //ダイアログの移動を可に
|
94
91
|
, buttons: {
|
95
92
|
"OK": function () { //OKボタン
|
96
93
|
$("#" + file_name).val($("#" + search_id).val());
|
@@ -106,6 +103,109 @@ function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_n
|
|
106
103
|
});
|
107
104
|
}
|
108
105
|
|
106
|
+
function setting_dialog(open_id, dialog_id, json_file) {
|
107
|
+
$("#" + open_id).click(function () {
|
108
|
+
$("#" + dialog_id).val = $(function () {
|
109
|
+
$("dl#wrap").empty();
|
110
|
+
$.getJSON(json_file, function (s) {
|
111
|
+
for (var i in s) {
|
112
|
+
if (s[i].type == "input") {
|
113
|
+
var h = "<table><tr>"
|
114
|
+
+ "<td class='setting_name'>" + s[i].description + "</td>"
|
115
|
+
+ "<td><input class='setting_value' type='text' " + "id=" + s[i].name + "_value " + "value=" + s[i].value + ">"
|
116
|
+
+ "</td></tr></table>"
|
117
|
+
$("dl#wrap").append(h);
|
118
|
+
} else if (s[i].type == "checkbox") {
|
119
|
+
var h = "<table><tr>";
|
120
|
+
h += "<td class='setting_name'>" + s[i].description + "</td>";
|
121
|
+
if (s[i].value == true) {
|
122
|
+
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value checked ></td>";
|
123
|
+
} else {
|
124
|
+
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value ></td>";
|
125
|
+
}
|
126
|
+
h += "</tr></table>";
|
127
|
+
$("dl#wrap").append(h);
|
128
|
+
} else if (s[i].type == "select") {
|
129
|
+
var h = "<table><tr>";
|
130
|
+
h += "<td class='setting_name'>" + s[i].description + "</td>";
|
131
|
+
h += "<td> <select class='setting_value' id=" + s[i].name + "_value " + ">";
|
132
|
+
s[i].select.forEach(e => {
|
133
|
+
if (e == s[i].value) {
|
134
|
+
h += "<option value=" + e + " selected >" + e + "</option>";
|
135
|
+
} else {
|
136
|
+
h += "<option value=" + e + ">" + e + "</option>";
|
137
|
+
}
|
138
|
+
});
|
139
|
+
h += "</select></td>";
|
140
|
+
h += "</tr></table>";
|
141
|
+
$("dl#wrap").append(h);
|
142
|
+
} else {
|
143
|
+
console.log("type=" + s[i].type);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
});
|
147
|
+
});
|
148
|
+
$("#" + dialog_id).dialog({
|
149
|
+
modal: true
|
150
|
+
, show: "slide" //表示時のアニメーション
|
151
|
+
, hide: "explode" //閉じた時のアニメーション
|
152
|
+
, title: "Setting" //ダイアログのタイトル
|
153
|
+
, width: 580 //ダイアログの横幅
|
154
|
+
, height: 400 //ダイアログの高さ
|
155
|
+
, resizable: true //リサイズ可
|
156
|
+
, closeOnEscape: false //[ESC]キーで閉じられなくする
|
157
|
+
, draggable: true //ダイアログの移動を可に
|
158
|
+
, buttons: {
|
159
|
+
"OK": function () { //OKボタン
|
160
|
+
var json_data = []
|
161
|
+
$.getJSON(json_file, function (s) {
|
162
|
+
for (var i in s) {
|
163
|
+
console.log(s[i].name);
|
164
|
+
if (s[i].type == "input") {
|
165
|
+
var data = {};
|
166
|
+
data["name"] = s[i].name;
|
167
|
+
data["value"] = $("#" + s[i].name + "_value").val();
|
168
|
+
data["type"] = s[i].type;
|
169
|
+
data["select"] = s[i].select;
|
170
|
+
data["description"] = s[i].description;
|
171
|
+
json_data.push(data);
|
172
|
+
}
|
173
|
+
else if (s[i].type == "checkbox") {
|
174
|
+
var data = {};
|
175
|
+
data["name"] = s[i].name;
|
176
|
+
if ($("#" + s[i].name + "_value:checked").val() == "on") {
|
177
|
+
data["value"] = true;
|
178
|
+
} else {
|
179
|
+
data["value"] = false;
|
180
|
+
}
|
181
|
+
data["type"] = s[i].type;
|
182
|
+
data["select"] = s[i].select;
|
183
|
+
data["description"] = s[i].description;
|
184
|
+
json_data.push(data);
|
185
|
+
} else if (s[i].type == "select") {
|
186
|
+
var data = {};
|
187
|
+
data["name"] = s[i].name;
|
188
|
+
data["value"] = $("#" + s[i].name + "_value" + " option:selected").val();
|
189
|
+
data["type"] = s[i].type;
|
190
|
+
data["select"] = s[i].select;
|
191
|
+
data["description"] = s[i].description;
|
192
|
+
json_data.push(data);
|
193
|
+
} else {
|
194
|
+
console.log("type=" + s[i].type);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
$ws.send("setting:" + JSON.stringify(json_data));
|
198
|
+
});
|
199
|
+
$(this).dialog("close");
|
200
|
+
},
|
201
|
+
"Cancel": function () { //Cancelボタン
|
202
|
+
$(this).dialog("close");
|
203
|
+
}
|
204
|
+
}
|
205
|
+
});
|
206
|
+
});
|
207
|
+
}
|
208
|
+
|
109
209
|
function get_dirname(path) {
|
110
210
|
var result = path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '');
|
111
211
|
if (result.match(/^[^\/]*\.[^\/\.]*$/)) {
|
@@ -122,7 +222,7 @@ function dispFile() {
|
|
122
222
|
// 起動時の処理
|
123
223
|
$(document).ready(function () {
|
124
224
|
// サーバに接続
|
125
|
-
server_connect("ws://localhost:
|
225
|
+
server_connect("ws://localhost:64141/wsserver")
|
126
226
|
// ウインドウサイズ
|
127
227
|
var width = 800;
|
128
228
|
var height = 600;
|
@@ -146,5 +246,7 @@ $(document).ready(function () {
|
|
146
246
|
|
147
247
|
select_file_dialog("search_str2", "dir", "dialog2", "select_dir", "upDir");
|
148
248
|
|
249
|
+
setting_dialog("setting", "setting_dialog", "config/setting.json");
|
250
|
+
|
149
251
|
});
|
150
252
|
|
data/lib/template/start.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
# -*- coding: utf-8 -*-
|
2
3
|
$LOAD_PATH << File.dirname(File.expand_path(__FILE__))
|
3
4
|
|
@@ -49,8 +50,7 @@ Thread.start {
|
|
49
50
|
else
|
50
51
|
browser = json["chrome_win"]
|
51
52
|
end
|
52
|
-
|
53
|
-
browser += " -app=http://localhost:#{port}"
|
53
|
+
browser += " --disable-plugins --disable-extensions -app=http://localhost:#{port}"
|
54
54
|
puts browser
|
55
55
|
system browser
|
56
56
|
}
|
data/lib/template/wsserver.rb
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
require "./server_app_base"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
def config_json_hash(json)
|
5
|
+
config = {}
|
6
|
+
json.each do |j|
|
7
|
+
config[j["name"]] = j["value"]
|
8
|
+
end
|
9
|
+
return config
|
10
|
+
end
|
2
11
|
|
3
12
|
class WsServer < Sinatra::Base
|
4
13
|
$ws_list = []
|
14
|
+
json_config = nil
|
5
15
|
get "" do
|
6
16
|
if !request.websocket?
|
7
17
|
"no supported"
|
@@ -14,6 +24,9 @@ class WsServer < Sinatra::Base
|
|
14
24
|
ws.onmessage do |msg|
|
15
25
|
puts msg
|
16
26
|
if msg =~ /^exec:/
|
27
|
+
json = JSON.parse(File.read("config/setting.json"))
|
28
|
+
json_config = config_json_hash(json)
|
29
|
+
$app.set_config(json_config)
|
17
30
|
argv = msg.gsub(/^exec:/, "")
|
18
31
|
Thread.new {
|
19
32
|
$app.start(argv.split(",")) do |out|
|
@@ -30,6 +43,15 @@ class WsServer < Sinatra::Base
|
|
30
43
|
if msg =~ /^resume/
|
31
44
|
$app.resume
|
32
45
|
end
|
46
|
+
if msg =~ /^setting:/
|
47
|
+
json_string = msg.gsub(/^setting:/, "")
|
48
|
+
json = JSON.parse(json_string)
|
49
|
+
File.open("config/setting.json", "w") do |w|
|
50
|
+
w.puts JSON.pretty_generate(json)
|
51
|
+
end
|
52
|
+
json_config = config_json_hash(json)
|
53
|
+
$app.set_config(json_config)
|
54
|
+
end
|
33
55
|
|
34
56
|
if msg == "exit"
|
35
57
|
unless ENV["OCRA"] == "true"
|
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.4
|
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-
|
11
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/template/app_load.rb
|
117
117
|
- lib/template/config.ru
|
118
118
|
- lib/template/config/browser.json
|
119
|
+
- lib/template/config/setting.json
|
119
120
|
- lib/template/css/index.css
|
120
121
|
- lib/template/index.html
|
121
122
|
- lib/template/js/main.js
|