browser_app_base 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/start_sample.rb +18 -5
- data/lib/browser_app_base/version.rb +1 -1
- data/lib/template/config.ru +8 -7
- data/lib/template/html/index.html +2 -2
- data/lib/template/html/test.html +0 -85
- data/lib/template/js/main.js +3 -3
- data/lib/template/server_app_base.rb +6 -2
- data/lib/template/start.rb +7 -6
- data/lib/template/wsserver.rb +2 -2
- 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: b109174e4089e40026b7e2d3f51a285750ca8cd0aa84f413e4e09df742614454
|
4
|
+
data.tar.gz: 18711484b2be36ed9a6b5ec8dac1099d93789da0523764b62ca2f7a56da9ba3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b533ff63da5cb09650b8351d56ce24786291750d6d6ccb83d38cbf2b42cf204049b02729e011ad3b3819a4a3d2b9345e93fc41720658ea62d92d18d64cd447c5
|
7
|
+
data.tar.gz: 47a9c950034781fde7b13ea142ac21ad26973ef9ab165e2f6e9077401a30c13472433fb51dda7fc5844ff1c28b1f801c5464ac60bdae256ce12516d9bcad0ec3
|
data/README.md
CHANGED
data/bin/start_sample.rb
CHANGED
@@ -5,15 +5,27 @@ 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
|
+
puts outdir
|
11
15
|
Dir.glob("#{dir}/lib/*") do |f|
|
12
|
-
|
13
|
-
|
16
|
+
if f =~ /config$/
|
17
|
+
# configはhomeにコピー
|
18
|
+
if !File.exists? "#{home_dir}/config"
|
19
|
+
puts "#{f} => #{home_dir}/"
|
20
|
+
FileUtils.cp_r f, "#{home_dir}/"
|
21
|
+
end
|
22
|
+
else
|
23
|
+
puts "#{f} => #{outdir}/"
|
24
|
+
FileUtils.cp_r f, "#{outdir}/"
|
25
|
+
end
|
14
26
|
end
|
15
27
|
|
16
|
-
FileUtils.cd "#{
|
28
|
+
FileUtils.cd "#{outdir}"
|
17
29
|
kernel = Facter.value(:kernel)
|
18
30
|
if kernel == "windows"
|
19
31
|
system "rubyw ./start.rb"
|
@@ -22,4 +34,5 @@ Dir.mktmpdir { |tmpdir|
|
|
22
34
|
else
|
23
35
|
system "ruby ./start.rb"
|
24
36
|
end
|
37
|
+
FileUtils.cd ENV["HOME"]
|
25
38
|
}
|
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 58656
|
105
106
|
|
106
107
|
run Sinatra::Application
|
@@ -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:58656/js/main.js"></script>
|
15
|
+
<link rel="stylesheet" href="http://localhost:58656/css/index.css" type="text/css">
|
16
16
|
</head>
|
17
17
|
|
18
18
|
<body>
|
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: "http://localhost:
|
118
|
+
url: "http://localhost:58656/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: "http://localhost:
|
151
|
+
url: "http://localhost:58656/history/" + file_name,
|
152
152
|
type: "POST",
|
153
153
|
cache: false,
|
154
154
|
dataType: "json",
|
@@ -326,7 +326,7 @@ $(document).ready(function () {
|
|
326
326
|
window.onload = function (e) {
|
327
327
|
console.log("onload");
|
328
328
|
// サーバに接続
|
329
|
-
server_connect("ws://localhost:
|
329
|
+
server_connect("ws://localhost:58656/wsserver")
|
330
330
|
}
|
331
331
|
|
332
332
|
// ウインドウサイズ
|
@@ -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,12 @@ end
|
|
50
50
|
dir = File.dirname(File.expand_path(__FILE__))
|
51
51
|
FileUtils.cd dir
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
puts "
|
56
|
-
FileUtils.mkdir_p("#{
|
57
|
-
|
53
|
+
# ディレクトリ作成
|
54
|
+
$home_dir = ENV["HOME"] + "/" + dir.split("/")[-1] + "/"
|
55
|
+
puts "home_dir=#{$home_dir}"
|
56
|
+
FileUtils.mkdir_p("#{$home_dir}/logs")
|
57
|
+
FileUtils.mkdir_p("#{$home_dir}/history")
|
58
|
+
Output.console_and_file("#{$home_dir}/logs/app.log", true)
|
58
59
|
|
59
60
|
# 空きポートを取得
|
60
61
|
def get_unused_port
|
@@ -98,7 +99,7 @@ begin
|
|
98
99
|
end
|
99
100
|
|
100
101
|
puts "start browser"
|
101
|
-
json_file =
|
102
|
+
json_file = "#{$home_dir}/config/browser.json"
|
102
103
|
json = JSON.parse(File.read json_file)
|
103
104
|
puts json
|
104
105
|
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:/
|
@@ -98,7 +98,7 @@ class WsServer < Sinatra::Base
|
|
98
98
|
if msg =~ /^setting:/
|
99
99
|
json_string = msg.gsub(/^setting:/, "")
|
100
100
|
json = JSON.parse(json_string)
|
101
|
-
File.open("config/setting.json", "w") do |w|
|
101
|
+
File.open("#{$home_dir}/config/setting.json", "w") do |w|
|
102
102
|
w.puts JSON.pretty_generate(json)
|
103
103
|
end
|
104
104
|
json_config = config_json_hash(json)
|
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.1
|
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-01-
|
11
|
+
date: 2022-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|