browser_app_base 0.1.0 → 0.1.3
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/.gitignore +2 -0
- data/.vscode/launch.json +1 -0
- data/README.md +82 -1
- data/bin/start_sample.rb +19 -5
- data/img/app.png +0 -0
- data/img/setting.png +0 -0
- data/img/setting_menu.png +0 -0
- data/lib/browser_app_base/version.rb +1 -1
- data/lib/template/config/browser.json +2 -2
- data/lib/template/config.ru +8 -7
- data/lib/template/css/index.css +54 -0
- data/lib/template/html/index.html +29 -18
- data/lib/template/html/test.html +0 -85
- data/lib/template/js/main.js +81 -6
- data/lib/template/server_app_base.rb +6 -2
- data/lib/template/start.rb +13 -6
- data/lib/template/wsserver.rb +11 -6
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a22a122d81077a56ab0c76ef5faa6bcff0df41828eb333087735243890835f1a
|
|
4
|
+
data.tar.gz: 8360c3f68edf2eb31783ed4dcef383b3bba6c53ebc2924fb4023cb265bc1775a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ee58439f8cec945ab9577fe7f2d27770a69ea070ef1ee00ce49d4a106bd114d0a3d0a1eae971b89532c64a3a3c435989cc92a39b03bf3c9f7697106b46d7856
|
|
7
|
+
data.tar.gz: a477e7007e72552b287078b76e19760896a19360ea31229ee34841d7171397b87b1b80a871a7e55d0e8cf2f07f06171aebad88a0cdf32801179fe941b0349184
|
data/.gitignore
CHANGED
data/.vscode/launch.json
CHANGED
data/README.md
CHANGED
|
@@ -62,9 +62,11 @@ ui application sample
|
|
|
62
62
|
$ /tmp/test/bin/start_my_app.rb
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+

|
|
66
|
+
|
|
65
67
|
## browser setting
|
|
66
68
|
|
|
67
|
-
config/browser.json
|
|
69
|
+
${home}/${app_nane}/config/browser.json
|
|
68
70
|
Set the path for your Windows or Linux Chrome browser
|
|
69
71
|
|
|
70
72
|
```json
|
|
@@ -103,6 +105,85 @@ class MyApp < AppMainBase
|
|
|
103
105
|
end
|
|
104
106
|
```
|
|
105
107
|
|
|
108
|
+
## Application Setting
|
|
109
|
+
|
|
110
|
+
${home}/${app_nane}/config/setting.json
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
[
|
|
115
|
+
{
|
|
116
|
+
"name": "name1",
|
|
117
|
+
"value": "value1 2 3 4",
|
|
118
|
+
"type": "input",
|
|
119
|
+
"select": "",
|
|
120
|
+
"description": "設定項目1"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "name2",
|
|
124
|
+
"value": true,
|
|
125
|
+
"type": "checkbox",
|
|
126
|
+
"select": "",
|
|
127
|
+
"description": "有効にする場合はチェック"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "name3",
|
|
131
|
+
"value": "2",
|
|
132
|
+
"type": "select",
|
|
133
|
+
"select": [
|
|
134
|
+
"1",
|
|
135
|
+
"2",
|
|
136
|
+
"3",
|
|
137
|
+
"4",
|
|
138
|
+
"5"
|
|
139
|
+
],
|
|
140
|
+
"description": "選択項目"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "name4",
|
|
144
|
+
"value": "value4",
|
|
145
|
+
"type": "input",
|
|
146
|
+
"select": "",
|
|
147
|
+
"description": "設定項目4"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "name5",
|
|
151
|
+
"value": "value5",
|
|
152
|
+
"type": "input",
|
|
153
|
+
"select": "",
|
|
154
|
+
"description": "設定項目5"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "name6",
|
|
158
|
+
"value": "value6",
|
|
159
|
+
"type": "input",
|
|
160
|
+
"select": "",
|
|
161
|
+
"description": "設定項目6"
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
```
|
|
165
|
+
```ruby
|
|
166
|
+
class MyApp < AppMainBase
|
|
167
|
+
def start(argv)
|
|
168
|
+
# popup message
|
|
169
|
+
app_send("popup:message string")
|
|
170
|
+
|
|
171
|
+
# log message
|
|
172
|
+
yield "log message"
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# read setting
|
|
176
|
+
puts @config["name1"]
|
|
177
|
+
end
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Setting menu
|
|
181
|
+

|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
Setting screen
|
|
185
|
+

|
|
186
|
+
|
|
106
187
|
## Development
|
|
107
188
|
|
|
108
189
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
data/bin/start_sample.rb
CHANGED
|
@@ -5,15 +5,28 @@ require "facter"
|
|
|
5
5
|
require "tmpdir"
|
|
6
6
|
|
|
7
7
|
# tmpdirディレクトリにコピー
|
|
8
|
-
dir = File.dirname(File.expand_path(__FILE__
|
|
8
|
+
dir = File.dirname(File.expand_path(__FILE__ + "/../"))
|
|
9
|
+
home_dir = ENV["HOME"] + "/" + dir.split("/")[-1]
|
|
10
|
+
puts "home_dir=#{$home_dir}"
|
|
9
11
|
Dir.mktmpdir { |tmpdir|
|
|
10
|
-
|
|
12
|
+
outdir = tmpdir + "/" + dir.split("/")[-1]
|
|
13
|
+
FileUtils.mkdir_p outdir
|
|
14
|
+
FileUtils.mkdir_p home_dir
|
|
15
|
+
puts outdir
|
|
11
16
|
Dir.glob("#{dir}/lib/*") do |f|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
if f =~ /config$/
|
|
18
|
+
# configはhomeにコピー
|
|
19
|
+
if !File.exists? "#{home_dir}/config"
|
|
20
|
+
puts "#{f} => #{home_dir}/"
|
|
21
|
+
FileUtils.cp_r f, "#{home_dir}/"
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
puts "#{f} => #{outdir}/"
|
|
25
|
+
FileUtils.cp_r f, "#{outdir}/"
|
|
26
|
+
end
|
|
14
27
|
end
|
|
15
28
|
|
|
16
|
-
FileUtils.cd "#{
|
|
29
|
+
FileUtils.cd "#{outdir}"
|
|
17
30
|
kernel = Facter.value(:kernel)
|
|
18
31
|
if kernel == "windows"
|
|
19
32
|
system "rubyw ./start.rb"
|
|
@@ -22,4 +35,5 @@ Dir.mktmpdir { |tmpdir|
|
|
|
22
35
|
else
|
|
23
36
|
system "ruby ./start.rb"
|
|
24
37
|
end
|
|
38
|
+
FileUtils.cd ENV["HOME"]
|
|
25
39
|
}
|
data/img/app.png
ADDED
|
Binary file
|
data/img/setting.png
ADDED
|
Binary file
|
|
Binary file
|
data/lib/template/config.ru
CHANGED
|
@@ -8,10 +8,7 @@ require "json"
|
|
|
8
8
|
require "./server"
|
|
9
9
|
require "./wsserver"
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
temp_dir = "/tmp" if temp_dir == nil
|
|
13
|
-
puts "temp_dir=#{temp_dir}"
|
|
14
|
-
access_log = File.new("#{temp_dir}/logs/sinatra.log", "a+")
|
|
11
|
+
access_log = File.new("#{$home_dir}/logs/sinatra.log", "a+")
|
|
15
12
|
access_log.sync = true
|
|
16
13
|
use Rack::CommonLogger, access_log
|
|
17
14
|
|
|
@@ -39,14 +36,18 @@ end
|
|
|
39
36
|
get "/config/*.*" do |file, ext|
|
|
40
37
|
content_type "text/json", :charset => "utf-8"
|
|
41
38
|
puts "#{file}.#{ext}"
|
|
42
|
-
File.read "config/#{file}.#{ext}"
|
|
39
|
+
File.read "#{$home_dir}/config/#{file}.#{ext}"
|
|
43
40
|
end
|
|
44
41
|
|
|
45
42
|
post "/history/*.*" do |file, ext|
|
|
46
43
|
content_type "text/json", :charset => "utf-8"
|
|
47
44
|
puts "#{file}.#{ext}"
|
|
48
45
|
p = params[:param1]
|
|
49
|
-
|
|
46
|
+
begin
|
|
47
|
+
buf = File.read "#{$home_dir}/history/#{file}.#{ext}"
|
|
48
|
+
rescue
|
|
49
|
+
buf = ""
|
|
50
|
+
end
|
|
50
51
|
data = eval(buf)
|
|
51
52
|
if data != nil
|
|
52
53
|
if p != ""
|
|
@@ -101,6 +102,6 @@ configure do
|
|
|
101
102
|
|
|
102
103
|
end
|
|
103
104
|
|
|
104
|
-
#\ --port
|
|
105
|
+
#\ --port 40173
|
|
105
106
|
|
|
106
107
|
run Sinatra::Application
|
data/lib/template/css/index.css
CHANGED
|
@@ -121,4 +121,58 @@ input[type="search"] {
|
|
|
121
121
|
|
|
122
122
|
input[type="search"]::-webkit-search-cancel-button {
|
|
123
123
|
-webkit-appearance: searchfield-cancel-button;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* menu */
|
|
127
|
+
.menu {
|
|
128
|
+
display: flex;
|
|
129
|
+
justify-content: flex-start;
|
|
130
|
+
list-style-type: none;
|
|
131
|
+
color: #393737;
|
|
132
|
+
padding: 0;
|
|
133
|
+
font-size: 16px;
|
|
134
|
+
font-weight: bold;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.menu li {
|
|
138
|
+
position: relative;
|
|
139
|
+
width: 100px;
|
|
140
|
+
margin-left: 1px;
|
|
141
|
+
padding: 5px;
|
|
142
|
+
background: #d8dada;
|
|
143
|
+
list-style-type: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.menu li a {
|
|
147
|
+
color: rgb(20, 114, 192);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.menu li a:hover {
|
|
151
|
+
background: #eba399;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.menuSub {
|
|
155
|
+
position: absolute;
|
|
156
|
+
margin-left: -6px;
|
|
157
|
+
padding: 0;
|
|
158
|
+
display: none;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/*.openが付与された時、表示の設定*/
|
|
162
|
+
.menuSub.open {
|
|
163
|
+
display: block;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.menuSub li a {
|
|
167
|
+
padding: 5px;
|
|
168
|
+
margin-left: -5px;
|
|
169
|
+
margin-right: -5px;
|
|
170
|
+
margin-bottom: -5px;
|
|
171
|
+
display: block;
|
|
172
|
+
color: rgb(20, 114, 192);
|
|
173
|
+
text-decoration: none;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.menuSub li a:hover {
|
|
177
|
+
background: #eba399;
|
|
124
178
|
}
|
|
@@ -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="
|
|
15
|
-
<link rel="stylesheet" href="
|
|
14
|
+
<script src="js/main.js"></script>
|
|
15
|
+
<link rel="stylesheet" href="css/index.css" type="text/css">
|
|
16
16
|
</head>
|
|
17
17
|
|
|
18
18
|
<body>
|
|
@@ -21,22 +21,33 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
<h4>RubyAppBase</h4>
|
|
23
23
|
<hr>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
<!-- menu -->
|
|
25
|
+
<div id="setting_dialog" style="display:none;">
|
|
26
|
+
<dl id="wrap"></dl>
|
|
27
|
+
</div>
|
|
28
|
+
<div>
|
|
29
|
+
<ul class="menu">
|
|
30
|
+
<Li><a href="#" id="exec" name="exec">実行</a></li>
|
|
31
|
+
<li><a href="#" id="stop" name="stop">停止</a></li>
|
|
32
|
+
<li>
|
|
33
|
+
設定
|
|
34
|
+
<ul class="menuSub">
|
|
35
|
+
<li><a href="#" id="setting">設定</a></li>
|
|
36
|
+
<li><a href="#" id="save_setting">設定保存</a></li>
|
|
37
|
+
<li><a href="#" id="load_setting">設定読み込み</a></li>
|
|
38
|
+
</ul>
|
|
39
|
+
</li>
|
|
40
|
+
<!--
|
|
41
|
+
<li>
|
|
42
|
+
menu3
|
|
43
|
+
<ul class="menuSub">
|
|
44
|
+
<li><a href="#">menu3-1</a></li>
|
|
45
|
+
<li><a href="#">menu3-2</a></li>
|
|
46
|
+
</ul>
|
|
47
|
+
</li>
|
|
48
|
+
-->
|
|
49
|
+
</ul>
|
|
50
|
+
</div>
|
|
40
51
|
|
|
41
52
|
<div id="dialog1" style="display:none;">
|
|
42
53
|
<input class="inarea" type="search" name="search_str" id="search_str">
|
data/lib/template/html/test.html
CHANGED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="ja">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<title>modalをcomponentで作る</title>
|
|
7
|
-
</head>
|
|
8
|
-
|
|
9
|
-
<style>
|
|
10
|
-
#content {
|
|
11
|
-
z-index: 10;
|
|
12
|
-
width: 50%;
|
|
13
|
-
padding: 1em;
|
|
14
|
-
background: #fff;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
#overlay {
|
|
18
|
-
/* 要素を重ねた時の順番 */
|
|
19
|
-
|
|
20
|
-
z-index: 1;
|
|
21
|
-
|
|
22
|
-
/* 画面全体を覆う設定 */
|
|
23
|
-
position: fixed;
|
|
24
|
-
top: 0;
|
|
25
|
-
left: 0;
|
|
26
|
-
width: 100%;
|
|
27
|
-
height: 100%;
|
|
28
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
29
|
-
|
|
30
|
-
/* 画面の中央に要素を表示させる設定 */
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: center;
|
|
33
|
-
justify-content: center;
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
</style>
|
|
37
|
-
|
|
38
|
-
<body>
|
|
39
|
-
<div id="app">
|
|
40
|
-
|
|
41
|
-
<button v-on:click="openModal">Click</button>
|
|
42
|
-
|
|
43
|
-
<open-modal v-show="showContent" v-on:from-child="closeModal">slotからモーダルウィンドウへ</open-modal>
|
|
44
|
-
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
48
|
-
<script>
|
|
49
|
-
Vue.component('open-modal', {
|
|
50
|
-
template: `
|
|
51
|
-
<div id="overlay" v-on:click="clickEvent">
|
|
52
|
-
<div id="content" v-on:click="stopEvent">
|
|
53
|
-
<p><slot></slot></p>
|
|
54
|
-
<button v-on:click="clickEvent">close</button>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
`,
|
|
58
|
-
methods: {
|
|
59
|
-
clickEvent: function () {
|
|
60
|
-
this.$emit('from-child')
|
|
61
|
-
},
|
|
62
|
-
stopEvent: function () {
|
|
63
|
-
event.stopPropagation()
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
new Vue({
|
|
69
|
-
el: '#app',
|
|
70
|
-
data: {
|
|
71
|
-
showContent: false
|
|
72
|
-
},
|
|
73
|
-
methods: {
|
|
74
|
-
openModal: function () {
|
|
75
|
-
this.showContent = true
|
|
76
|
-
},
|
|
77
|
-
closeModal: function () {
|
|
78
|
-
this.showContent = false
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
</script>
|
|
83
|
-
</body>
|
|
84
|
-
|
|
85
|
-
</html>
|
data/lib/template/js/main.js
CHANGED
|
@@ -115,7 +115,7 @@ function autocomp(id, file_kind) {
|
|
|
115
115
|
},
|
|
116
116
|
source: function (req, resp) {
|
|
117
117
|
$.ajax({
|
|
118
|
-
url: "
|
|
118
|
+
url: "search?path=" + $("#" + id).val() + "&kind=" + file_kind,
|
|
119
119
|
type: "GET",
|
|
120
120
|
cache: false,
|
|
121
121
|
dataType: "json",
|
|
@@ -148,7 +148,7 @@ function autocomp_history(id, file_name) {
|
|
|
148
148
|
},
|
|
149
149
|
source: function (req, resp) {
|
|
150
150
|
$.ajax({
|
|
151
|
-
url: "
|
|
151
|
+
url: "history/" + file_name,
|
|
152
152
|
type: "POST",
|
|
153
153
|
cache: false,
|
|
154
154
|
dataType: "json",
|
|
@@ -291,6 +291,7 @@ function setting_dialog(open_id, dialog_id, json_file) {
|
|
|
291
291
|
//console.log("type=" + s[i].type);
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
+
// Jsonデータをサーバに送信
|
|
294
295
|
$ws.send("setting:" + JSON.stringify(json_data));
|
|
295
296
|
});
|
|
296
297
|
$(this).dialog("close");
|
|
@@ -303,6 +304,57 @@ function setting_dialog(open_id, dialog_id, json_file) {
|
|
|
303
304
|
});
|
|
304
305
|
}
|
|
305
306
|
|
|
307
|
+
// 設定読み込み
|
|
308
|
+
function load_setting(open_id) {
|
|
309
|
+
document.getElementById(open_id).onclick = async () => {
|
|
310
|
+
[fileHandle] = await window.showOpenFilePicker();
|
|
311
|
+
const file = await fileHandle.getFile();
|
|
312
|
+
const json_data = await file.text();
|
|
313
|
+
console.log(json_data);
|
|
314
|
+
// Jsonデータをサーバに送信
|
|
315
|
+
$ws.send("setting:" + json_data);
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 設定保存
|
|
320
|
+
function save_setting(open_id, json_file) {
|
|
321
|
+
document.getElementById(open_id).onclick = async () => {
|
|
322
|
+
var json_data = ""
|
|
323
|
+
$.ajax({
|
|
324
|
+
// jsonの読み込み
|
|
325
|
+
type: "GET",
|
|
326
|
+
url: json_file, // ファイルパス(相対パス)
|
|
327
|
+
dataType: "json", // ファイル形式
|
|
328
|
+
async: false // 非同期通信フラグ
|
|
329
|
+
}).then(
|
|
330
|
+
function (json) {
|
|
331
|
+
// 読み込み成功時の処理
|
|
332
|
+
json_data = JSON.stringify(json, null, 2);
|
|
333
|
+
console.log("json=" + json_data);
|
|
334
|
+
},
|
|
335
|
+
function () {
|
|
336
|
+
// 読み込み失敗時の処理
|
|
337
|
+
console.log("読み込みに失敗しました");
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
// Jsonを保存
|
|
341
|
+
const opts = {
|
|
342
|
+
suggestedName: 'setting.json',
|
|
343
|
+
types: [{
|
|
344
|
+
description: 'Text file',
|
|
345
|
+
accept: { 'text/plain': ['.json'] },
|
|
346
|
+
}],
|
|
347
|
+
};
|
|
348
|
+
// ファイルをどこにどんな名前で保存するか訊くダイアログを表示
|
|
349
|
+
const saveHandle = await window.showSaveFilePicker(opts)
|
|
350
|
+
// 保存先ファイルに書き込み準備
|
|
351
|
+
const writable = await saveHandle.createWritable();
|
|
352
|
+
// 先程同様に書き込んで終了
|
|
353
|
+
await writable.write(json_data);
|
|
354
|
+
await writable.close();
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
306
358
|
function get_dirname(path) {
|
|
307
359
|
var result = path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '');
|
|
308
360
|
if (result.match(/^[^\/]*\.[^\/\.]*$/)) {
|
|
@@ -323,12 +375,27 @@ function openFile(file) {
|
|
|
323
375
|
// 起動時の処理
|
|
324
376
|
$(document).ready(function () {
|
|
325
377
|
|
|
378
|
+
// サーバに接続
|
|
379
|
+
server_connect("ws://localhost:40173/wsserver")
|
|
326
380
|
window.onload = function (e) {
|
|
327
|
-
console.log("onload");
|
|
328
381
|
// サーバに接続
|
|
329
|
-
server_connect("ws://localhost:
|
|
382
|
+
//server_connect("ws://localhost:40173/wsserver")
|
|
330
383
|
}
|
|
331
384
|
|
|
385
|
+
// menu
|
|
386
|
+
$(function () {
|
|
387
|
+
$(".menu li").hover(
|
|
388
|
+
function () {
|
|
389
|
+
//クラス名「open」を付与する
|
|
390
|
+
$(this).children(".menuSub").addClass("open");
|
|
391
|
+
//hoverが外れた場合
|
|
392
|
+
}, function () {
|
|
393
|
+
//クラス名「open」を取り除く
|
|
394
|
+
$(this).children(".menuSub").removeClass("open");
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
});
|
|
398
|
+
|
|
332
399
|
// ウインドウサイズ
|
|
333
400
|
var width = 800;
|
|
334
401
|
var height = 600;
|
|
@@ -357,6 +424,15 @@ $(document).ready(function () {
|
|
|
357
424
|
//console.log("auto_scroll=" + $auto_scroll);
|
|
358
425
|
});
|
|
359
426
|
|
|
427
|
+
// 設定ダイアログ
|
|
428
|
+
setting_dialog("setting", "setting_dialog", "config/setting.json");
|
|
429
|
+
|
|
430
|
+
// 設定保存
|
|
431
|
+
save_setting("save_setting", "config/setting.json");
|
|
432
|
+
|
|
433
|
+
// 設定読み込み
|
|
434
|
+
load_setting("load_setting");
|
|
435
|
+
|
|
360
436
|
// ハンドラ登録
|
|
361
437
|
$("#stop").click(function () {
|
|
362
438
|
send_message("stop");
|
|
@@ -367,12 +443,11 @@ $(document).ready(function () {
|
|
|
367
443
|
send_message("exec:" + $("#upFile").val());
|
|
368
444
|
});
|
|
369
445
|
|
|
446
|
+
|
|
370
447
|
select_file_dialog("search_str", "file", "dialog1", "select_file", "upFile");
|
|
371
448
|
|
|
372
449
|
select_file_dialog("search_str2", "dir", "dialog2", "select_dir", "upDir");
|
|
373
450
|
|
|
374
|
-
setting_dialog("setting", "setting_dialog", "config/setting.json");
|
|
375
|
-
|
|
376
451
|
autocomp_history("upFile", "history.json")
|
|
377
452
|
|
|
378
453
|
});
|
|
@@ -41,7 +41,11 @@ class AppMainBase
|
|
|
41
41
|
|
|
42
42
|
# 履歴の保存
|
|
43
43
|
def add_history(file, history_data, max = 10)
|
|
44
|
-
|
|
44
|
+
begin
|
|
45
|
+
buf = File.read "#{$home_dir}history/#{file}"
|
|
46
|
+
rescue
|
|
47
|
+
buf = ""
|
|
48
|
+
end
|
|
45
49
|
data = eval(buf)
|
|
46
50
|
if data == nil
|
|
47
51
|
data = []
|
|
@@ -50,7 +54,7 @@ class AppMainBase
|
|
|
50
54
|
data.prepend history_data
|
|
51
55
|
end
|
|
52
56
|
data = data.uniq[0..max - 1]
|
|
53
|
-
File.open("history/#{file}", "w") do |f|
|
|
57
|
+
File.open("#{$home_dir}history/#{file}", "w") do |f|
|
|
54
58
|
f.write JSON.pretty_generate data
|
|
55
59
|
end
|
|
56
60
|
end
|
data/lib/template/start.rb
CHANGED
|
@@ -50,11 +50,18 @@ end
|
|
|
50
50
|
dir = File.dirname(File.expand_path(__FILE__))
|
|
51
51
|
FileUtils.cd dir
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
# ディレクトリ作成
|
|
54
|
+
pp ARGV
|
|
55
|
+
if ARGV[0] == "test"
|
|
56
|
+
$home_dir = "./"
|
|
57
|
+
ARGV = []
|
|
58
|
+
else
|
|
59
|
+
$home_dir = ENV["HOME"] + "/" + dir.split("/")[-1] + "/"
|
|
60
|
+
end
|
|
61
|
+
puts "home_dir=#{$home_dir}"
|
|
62
|
+
FileUtils.mkdir_p("#{$home_dir}/logs")
|
|
63
|
+
FileUtils.mkdir_p("#{$home_dir}/history")
|
|
64
|
+
Output.console_and_file("#{$home_dir}/logs/app.log", true)
|
|
58
65
|
|
|
59
66
|
# 空きポートを取得
|
|
60
67
|
def get_unused_port
|
|
@@ -98,7 +105,7 @@ begin
|
|
|
98
105
|
end
|
|
99
106
|
|
|
100
107
|
puts "start browser"
|
|
101
|
-
json_file =
|
|
108
|
+
json_file = "#{$home_dir}/config/browser.json"
|
|
102
109
|
json = JSON.parse(File.read json_file)
|
|
103
110
|
puts json
|
|
104
111
|
kernel = Facter.value(:kernel)
|
data/lib/template/wsserver.rb
CHANGED
|
@@ -51,7 +51,7 @@ class WsServer < Sinatra::Base
|
|
|
51
51
|
end
|
|
52
52
|
ws.onmessage do |msg|
|
|
53
53
|
puts msg
|
|
54
|
-
json = JSON.parse(File.read("config/setting.json"))
|
|
54
|
+
json = JSON.parse(File.read("#{$home_dir}/config/setting.json"))
|
|
55
55
|
json_config = config_json_hash(json)
|
|
56
56
|
$app.set_config(json_config)
|
|
57
57
|
if msg =~ /^exec:/
|
|
@@ -97,12 +97,17 @@ class WsServer < Sinatra::Base
|
|
|
97
97
|
end
|
|
98
98
|
if msg =~ /^setting:/
|
|
99
99
|
json_string = msg.gsub(/^setting:/, "")
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
begin
|
|
101
|
+
json = JSON.parse(json_string)
|
|
102
|
+
File.open("#{$home_dir}/config/setting.json", "w") do |w|
|
|
103
|
+
w.puts JSON.pretty_generate(json)
|
|
104
|
+
end
|
|
105
|
+
json_config = config_json_hash(json)
|
|
106
|
+
$app.set_config(json_config)
|
|
107
|
+
rescue
|
|
108
|
+
# jsonファイルではない
|
|
109
|
+
ws_send("app_end:error")
|
|
103
110
|
end
|
|
104
|
-
json_config = config_json_hash(json)
|
|
105
|
-
$app.set_config(json_config)
|
|
106
111
|
end
|
|
107
112
|
if msg =~ /^openfile:/
|
|
108
113
|
file = msg.gsub(/^openfile:/, "")
|
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.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- masataka kuwayama
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sinatra
|
|
@@ -113,6 +113,9 @@ files:
|
|
|
113
113
|
- bin/create_browser_app.rb
|
|
114
114
|
- bin/start_sample.rb
|
|
115
115
|
- browser_app_base.gemspec
|
|
116
|
+
- img/app.png
|
|
117
|
+
- img/setting.png
|
|
118
|
+
- img/setting_menu.png
|
|
116
119
|
- lib/browser_app_base.rb
|
|
117
120
|
- lib/browser_app_base/version.rb
|
|
118
121
|
- lib/template/app_load.rb
|