browser_app_base 0.1.7 → 0.1.9
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/README.md +173 -52
- data/bin/start_sample.rb +1 -1
- 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 +5 -3
- data/lib/template/config/setting.json +11 -1
- data/lib/template/config.ru +1 -1
- data/lib/template/css/index.css +418 -111
- data/lib/template/history/history.json +3 -1
- data/lib/template/html/index.html +45 -48
- data/lib/template/js/main.js +59 -20
- data/lib/template/server.rb +10 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54f5d83ea13920bcfc80e7ecd82c099c5749847535fb593de2f36ff942027555
|
4
|
+
data.tar.gz: 0a692e22ea4182825b0e6dd35c9c483c8e8d41ebbf9387155fcd4b53900b1f29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2be55260153ca5ea4ff173c72c5a368c5fc020ad426247bb4bdb6d40e875b1a83b56c2d61234a671ed4e650ea79e48bd5bfa0aa3038ba0681405e435d66d721
|
7
|
+
data.tar.gz: 06ba92962030bef3b58a5fb44ea8aa1c6596741fe82a12d40cbcf8bd1d040ddeeaf6e717046714ab76ae7623954b118edaa127ae6cbe0e9a8999770eb0a66db5
|
data/README.md
CHANGED
@@ -2,7 +2,21 @@
|
|
2
2
|
|
3
3
|
Windows and Linux browser-based desktop application templates.
|
4
4
|
|
5
|
-
|
5
|
+
On Linux, the Chrome browser is used by default.
|
6
|
+
On Windows, the Edge browser is used by default.
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## Features
|
11
|
+
|
12
|
+
- Cross-platform browser-based desktop app template (Windows/Linux)
|
13
|
+
- Simple app generation command (`create_browser_app`)
|
14
|
+
- Flexible application settings via `setting.json`
|
15
|
+
- Communication between browser UI and Ruby backend
|
16
|
+
- RSpec-based test framework (from v0.1.9)
|
17
|
+
- Easy browser configuration for each OS
|
18
|
+
|
19
|
+
---
|
6
20
|
|
7
21
|
## Installation
|
8
22
|
|
@@ -20,6 +34,8 @@ Or install it yourself as:
|
|
20
34
|
|
21
35
|
$ gem install browser_app_base
|
22
36
|
|
37
|
+
---
|
38
|
+
|
23
39
|
## Usage
|
24
40
|
|
25
41
|
create_browser_app [options]
|
@@ -27,72 +43,87 @@ Or install it yourself as:
|
|
27
43
|
-a, --app app_name application name
|
28
44
|
-h, --help command help
|
29
45
|
|
46
|
+
---
|
47
|
+
|
48
|
+
## Create app template
|
30
49
|
|
31
|
-
|
50
|
+
$ create_browser_app -d /path/to/test/ -a MyApp
|
32
51
|
|
33
|
-
|
52
|
+
---
|
34
53
|
|
35
|
-
##
|
36
|
-
|
54
|
+
## Add application code
|
55
|
+
|
56
|
+
$ cd /path/to/test/
|
37
57
|
$ vi my_app.rb
|
38
58
|
|
39
59
|
```ruby
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
class MyApp < AppMainBase
|
61
|
+
def start(argv)
|
62
|
+
super
|
63
|
+
# add application code
|
64
|
+
end
|
65
|
+
|
66
|
+
def stop()
|
67
|
+
super
|
68
|
+
# add application code
|
69
|
+
end
|
70
|
+
end
|
51
71
|
```
|
52
72
|
|
53
|
-
|
73
|
+
---
|
74
|
+
|
75
|
+
## UI application sample
|
54
76
|
|
55
77
|
index.html
|
56
78
|
css/index.css
|
57
79
|
js/main.js
|
58
80
|
|
81
|
+
---
|
82
|
+
|
59
83
|
## Start application
|
60
84
|
|
61
85
|
```shell
|
62
|
-
$ /
|
86
|
+
$ /path/to/test/bin/start_my_app.rb
|
63
87
|
```
|
64
88
|
|
65
89
|

|
66
90
|
|
67
|
-
|
91
|
+
---
|
68
92
|
|
69
|
-
|
70
|
-
|
93
|
+
## Browser setting
|
94
|
+
|
95
|
+
Configure your browser for Windows or Linux.
|
96
|
+
|
97
|
+
${home}/${app_name}/config/browser.json
|
71
98
|
|
72
99
|
```json
|
73
100
|
{
|
74
|
-
"chrome_win": "start
|
101
|
+
"chrome_win": "start msedge",
|
102
|
+
"chrome_win_": "start chrome",
|
75
103
|
"chrome_linux": "/bin/google-chrome"
|
76
104
|
}
|
77
105
|
```
|
78
106
|
|
79
|
-
|
107
|
+
---
|
80
108
|
|
81
|
-
|
109
|
+
## Send a message from your browser application to your Ruby application
|
82
110
|
|
83
|
-
|
111
|
+
Use the `send_message` function.
|
112
|
+
|
113
|
+
main.js sample:
|
84
114
|
```javascript
|
85
115
|
$("#exec").click(function () {
|
86
116
|
send_message("exec:" + $("#upFile").val());
|
87
117
|
});
|
88
|
-
|
89
118
|
```
|
90
119
|
|
91
|
-
|
120
|
+
---
|
92
121
|
|
93
|
-
|
122
|
+
## Send a message from the Ruby application to the browser application
|
94
123
|
|
95
|
-
|
124
|
+
Use the `app_send` function.
|
125
|
+
|
126
|
+
my_app_sample.rb sample:
|
96
127
|
```ruby
|
97
128
|
class MyApp < AppMainBase
|
98
129
|
def start(argv)
|
@@ -101,14 +132,19 @@ class MyApp < AppMainBase
|
|
101
132
|
|
102
133
|
# log message
|
103
134
|
yield "log message"
|
104
|
-
|
135
|
+
end
|
105
136
|
end
|
106
137
|
```
|
107
138
|
|
108
|
-
|
139
|
+
---
|
140
|
+
|
141
|
+
## Application Setting
|
109
142
|
|
110
|
-
|
143
|
+
You can add settings by modifying `setting.json`.
|
111
144
|
|
145
|
+
${home}/${app_name}/config/setting.json
|
146
|
+
|
147
|
+
Example (`setting.json`):
|
112
148
|
|
113
149
|
```json
|
114
150
|
{
|
@@ -119,14 +155,14 @@ end
|
|
119
155
|
"value": "value1 2 3 4",
|
120
156
|
"type": "input",
|
121
157
|
"select": "",
|
122
|
-
"description": "
|
158
|
+
"description": "Setting item 1"
|
123
159
|
},
|
124
160
|
{
|
125
161
|
"name": "name2",
|
126
162
|
"value": true,
|
127
163
|
"type": "checkbox",
|
128
164
|
"select": "",
|
129
|
-
"description": "
|
165
|
+
"description": "Check to enable"
|
130
166
|
},
|
131
167
|
{
|
132
168
|
"name": "name3",
|
@@ -139,61 +175,146 @@ end
|
|
139
175
|
"4",
|
140
176
|
"5"
|
141
177
|
],
|
142
|
-
"description": "
|
178
|
+
"description": "Select item"
|
143
179
|
},
|
144
180
|
{
|
145
181
|
"name": "name4",
|
146
182
|
"value": "value4",
|
147
183
|
"type": "input",
|
148
184
|
"select": "",
|
149
|
-
"description": "
|
185
|
+
"description": "Setting item 4"
|
150
186
|
},
|
151
187
|
{
|
152
188
|
"name": "name5",
|
153
189
|
"value": "value5",
|
154
190
|
"type": "input",
|
155
191
|
"select": "",
|
156
|
-
"description": "
|
192
|
+
"description": "Setting item 5"
|
157
193
|
},
|
158
194
|
{
|
159
195
|
"name": "name6",
|
160
196
|
"value": "value6",
|
161
197
|
"type": "input",
|
162
198
|
"select": "",
|
163
|
-
"description": "
|
199
|
+
"description": "Setting item 6"
|
200
|
+
},
|
201
|
+
{
|
202
|
+
"name": "jaon_area",
|
203
|
+
"value": {
|
204
|
+
"DEBUG": true,
|
205
|
+
"VERSION": 1
|
206
|
+
},
|
207
|
+
"type": "textarea",
|
208
|
+
"select": "",
|
209
|
+
"description": "JSON string<br>Example:<br>{<br> \"DEBUG\": true,<br> \"VERSION\": 1<br>}"
|
164
210
|
}
|
165
211
|
]
|
166
|
-
}
|
212
|
+
}
|
213
|
+
```
|
214
|
+
|
215
|
+
You can access the settings from your Ruby application like this:
|
216
|
+
|
167
217
|
```ruby
|
168
218
|
class MyApp < AppMainBase
|
169
219
|
def start(argv)
|
170
|
-
#
|
171
|
-
|
220
|
+
# Access a setting value
|
221
|
+
puts @config["name1"]
|
222
|
+
# Access jaon_area as a hash
|
223
|
+
p @config["jaon_area"] # => {"DEBUG"=>true, "VERSION"=>1}
|
224
|
+
end
|
225
|
+
end
|
226
|
+
```
|
172
227
|
|
173
|
-
|
174
|
-
yield "log message"
|
175
|
-
end
|
228
|
+
---
|
176
229
|
|
177
|
-
|
178
|
-
|
230
|
+
### About `jaon_area` in setting.json
|
231
|
+
|
232
|
+
The `jaon_area` item in `setting.json` allows you to input a JSON string as a setting value.
|
233
|
+
This field is of type `"textarea"` and is intended for storing flexible, structured data such as additional configuration, flags, or custom parameters.
|
234
|
+
|
235
|
+
**Example:**
|
236
|
+
```json
|
237
|
+
{
|
238
|
+
"DEBUG": true,
|
239
|
+
"VERSION": 1
|
240
|
+
}
|
241
|
+
```
|
242
|
+
|
243
|
+
- You can edit this field directly in the settings screen.
|
244
|
+
- The value must be valid JSON format.
|
245
|
+
- The application can parse and use this data as needed.
|
246
|
+
|
247
|
+
**Use cases:**
|
248
|
+
- Toggle debug mode (`"DEBUG": true`)
|
249
|
+
- Store version or environment information
|
250
|
+
- Save arbitrary key-value pairs for advanced configuration
|
251
|
+
|
252
|
+
**How to use in your Ruby application:**
|
253
|
+
You can access the `jaon_area` value as a Ruby hash via `@config["jaon_area"]`.
|
254
|
+
For example:
|
255
|
+
```ruby
|
256
|
+
class MyApp < AppMainBase
|
257
|
+
def start(argv)
|
258
|
+
debug_mode = @config["jaon_area"]["DEBUG"]
|
259
|
+
version = @config["jaon_area"]["VERSION"]
|
260
|
+
puts "Debug mode: #{debug_mode}, Version: #{version}"
|
261
|
+
end
|
179
262
|
end
|
180
263
|
```
|
181
264
|
|
182
|
-
|
183
|
-
|
265
|
+
**Note:**
|
266
|
+
Be sure to enter valid JSON. If the format is incorrect, the application may not be able to read the settings properly.
|
184
267
|
|
268
|
+
**Tips:**
|
269
|
+
- You can use `jaon_area` to store any structured data your application needs at runtime.
|
270
|
+
- This is useful for feature flags, environment-specific settings, or any advanced configuration that doesn't fit into a simple string or boolean value.
|
185
271
|
|
186
|
-
|
272
|
+
---
|
273
|
+
|
274
|
+
## Setting menu
|
275
|
+
The following image shows the application's setting menu, where you can access and modify various configuration options.
|
276
|
+

|
277
|
+
|
278
|
+
Setting screen
|
279
|
+
This image displays the detailed setting screen, allowing you to edit individual configuration items.
|
187
280
|

|
188
281
|
|
282
|
+
---
|
283
|
+
|
284
|
+
## Running Tests
|
285
|
+
|
286
|
+
From v0.1.9, RSpec-based testing is supported.
|
287
|
+
After installing dependencies, you can run tests with:
|
288
|
+
|
289
|
+
```sh
|
290
|
+
bundle install
|
291
|
+
bundle exec rake
|
292
|
+
```
|
293
|
+
|
294
|
+
or
|
295
|
+
|
296
|
+
```sh
|
297
|
+
bundle exec rspec
|
298
|
+
```
|
299
|
+
|
300
|
+
RSpec tasks are defined in the `Rakefile`, so `rake` will automatically run all tests.
|
301
|
+
Place your test code under the `spec/` directory.
|
302
|
+
|
303
|
+
---
|
304
|
+
|
189
305
|
## Development
|
190
306
|
|
191
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
307
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
308
|
+
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).
|
309
|
+
|
310
|
+
---
|
192
311
|
|
193
312
|
## Contributing
|
194
313
|
|
195
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/kuwayama1971/BrowserAppBase.
|
314
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/kuwayama1971/BrowserAppBase](https://github.com/kuwayama1971/BrowserAppBase).
|
315
|
+
|
316
|
+
---
|
196
317
|
|
197
318
|
## License
|
198
319
|
|
199
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
320
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/bin/start_sample.rb
CHANGED
data/img/app.png
CHANGED
Binary file
|
data/img/setting.png
CHANGED
Binary file
|
data/img/setting_menu.png
CHANGED
Binary file
|
@@ -48,6 +48,16 @@
|
|
48
48
|
"type": "input",
|
49
49
|
"select": "",
|
50
50
|
"description": "設定項目6"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"name": "jaon_area",
|
54
|
+
"value": {
|
55
|
+
"DEBUG": true,
|
56
|
+
"VERSION": 1
|
57
|
+
},
|
58
|
+
"type": "textarea",
|
59
|
+
"select": "",
|
60
|
+
"description": "Json文字列<br>例:<br>{<br> \"DEBUG\":true <br> \"VERSION\":1<br>}"
|
51
61
|
}
|
52
62
|
]
|
53
|
-
}
|
63
|
+
}
|