browser_app_base 0.1.8 → 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 +210 -92
- 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 -1
- 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 +2 -2
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,9 +2,22 @@
|
|
2
2
|
|
3
3
|
Windows and Linux browser-based desktop application templates.
|
4
4
|
|
5
|
-
On Linux, the Chrome browser is used by default.
|
5
|
+
On Linux, the Chrome browser is used by default.
|
6
6
|
On Windows, the Edge browser is used by default.
|
7
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
|
+
---
|
20
|
+
|
8
21
|
## Installation
|
9
22
|
|
10
23
|
Add this line to your application's Gemfile:
|
@@ -21,6 +34,8 @@ Or install it yourself as:
|
|
21
34
|
|
22
35
|
$ gem install browser_app_base
|
23
36
|
|
37
|
+
---
|
38
|
+
|
24
39
|
## Usage
|
25
40
|
|
26
41
|
create_browser_app [options]
|
@@ -28,35 +43,43 @@ Or install it yourself as:
|
|
28
43
|
-a, --app app_name application name
|
29
44
|
-h, --help command help
|
30
45
|
|
46
|
+
---
|
31
47
|
|
32
|
-
## Create app
|
48
|
+
## Create app template
|
33
49
|
|
34
50
|
$ create_browser_app -d /path/to/test/ -a MyApp
|
35
51
|
|
36
|
-
|
52
|
+
---
|
53
|
+
|
54
|
+
## Add application code
|
55
|
+
|
37
56
|
$ cd /path/to/test/
|
38
57
|
$ vi my_app.rb
|
39
58
|
|
40
59
|
```ruby
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
52
71
|
```
|
53
72
|
|
54
|
-
|
73
|
+
---
|
74
|
+
|
75
|
+
## UI application sample
|
55
76
|
|
56
77
|
index.html
|
57
78
|
css/index.css
|
58
79
|
js/main.js
|
59
80
|
|
81
|
+
---
|
82
|
+
|
60
83
|
## Start application
|
61
84
|
|
62
85
|
```shell
|
@@ -65,10 +88,13 @@ $ /path/to/test/bin/start_my_app.rb
|
|
65
88
|
|
66
89
|

|
67
90
|
|
68
|
-
|
91
|
+
---
|
92
|
+
|
93
|
+
## Browser setting
|
94
|
+
|
69
95
|
Configure your browser for Windows or Linux.
|
70
96
|
|
71
|
-
${home}/${
|
97
|
+
${home}/${app_name}/config/browser.json
|
72
98
|
|
73
99
|
```json
|
74
100
|
{
|
@@ -78,23 +104,26 @@ Configure your browser for Windows or Linux.
|
|
78
104
|
}
|
79
105
|
```
|
80
106
|
|
81
|
-
|
107
|
+
---
|
108
|
+
|
109
|
+
## Send a message from your browser application to your Ruby application
|
82
110
|
|
83
|
-
Use the send_message function.
|
111
|
+
Use the `send_message` function.
|
84
112
|
|
85
|
-
main.js sample
|
113
|
+
main.js sample:
|
86
114
|
```javascript
|
87
115
|
$("#exec").click(function () {
|
88
116
|
send_message("exec:" + $("#upFile").val());
|
89
117
|
});
|
90
|
-
|
91
118
|
```
|
92
119
|
|
93
|
-
|
120
|
+
---
|
121
|
+
|
122
|
+
## Send a message from the Ruby application to the browser application
|
94
123
|
|
95
|
-
Use the app_send function.
|
124
|
+
Use the `app_send` function.
|
96
125
|
|
97
|
-
my_app_sample.rb sample
|
126
|
+
my_app_sample.rb sample:
|
98
127
|
```ruby
|
99
128
|
class MyApp < AppMainBase
|
100
129
|
def start(argv)
|
@@ -103,100 +132,189 @@ class MyApp < AppMainBase
|
|
103
132
|
|
104
133
|
# log message
|
105
134
|
yield "log message"
|
106
|
-
|
135
|
+
end
|
107
136
|
end
|
108
137
|
```
|
109
138
|
|
110
|
-
|
111
|
-
|
139
|
+
---
|
140
|
+
|
141
|
+
## Application Setting
|
142
|
+
|
143
|
+
You can add settings by modifying `setting.json`.
|
112
144
|
|
113
|
-
${home}/${
|
145
|
+
${home}/${app_name}/config/setting.json
|
114
146
|
|
147
|
+
Example (`setting.json`):
|
115
148
|
|
116
149
|
```json
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
"
|
138
|
-
"
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
150
|
+
{
|
151
|
+
"version": 0.1,
|
152
|
+
"setting_list": [
|
153
|
+
{
|
154
|
+
"name": "name1",
|
155
|
+
"value": "value1 2 3 4",
|
156
|
+
"type": "input",
|
157
|
+
"select": "",
|
158
|
+
"description": "Setting item 1"
|
159
|
+
},
|
160
|
+
{
|
161
|
+
"name": "name2",
|
162
|
+
"value": true,
|
163
|
+
"type": "checkbox",
|
164
|
+
"select": "",
|
165
|
+
"description": "Check to enable"
|
166
|
+
},
|
167
|
+
{
|
168
|
+
"name": "name3",
|
169
|
+
"value": "3",
|
170
|
+
"type": "select",
|
171
|
+
"select": [
|
172
|
+
"1",
|
173
|
+
"2",
|
174
|
+
"3",
|
175
|
+
"4",
|
176
|
+
"5"
|
177
|
+
],
|
178
|
+
"description": "Select item"
|
179
|
+
},
|
180
|
+
{
|
181
|
+
"name": "name4",
|
182
|
+
"value": "value4",
|
183
|
+
"type": "input",
|
184
|
+
"select": "",
|
185
|
+
"description": "Setting item 4"
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"name": "name5",
|
189
|
+
"value": "value5",
|
190
|
+
"type": "input",
|
191
|
+
"select": "",
|
192
|
+
"description": "Setting item 5"
|
193
|
+
},
|
194
|
+
{
|
195
|
+
"name": "name6",
|
196
|
+
"value": "value6",
|
197
|
+
"type": "input",
|
198
|
+
"select": "",
|
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>}"
|
210
|
+
}
|
211
|
+
]
|
212
|
+
}
|
167
213
|
```
|
168
|
-
|
214
|
+
|
215
|
+
You can access the settings from your Ruby application like this:
|
169
216
|
|
170
217
|
```ruby
|
171
218
|
class MyApp < AppMainBase
|
172
219
|
def start(argv)
|
173
|
-
#
|
174
|
-
|
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
|
+
```
|
175
227
|
|
176
|
-
|
177
|
-
yield "log message"
|
178
|
-
end
|
228
|
+
---
|
179
229
|
|
180
|
-
|
181
|
-
|
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
|
182
262
|
end
|
183
263
|
```
|
184
264
|
|
185
|
-
|
186
|
-
|
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.
|
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.
|
187
271
|
|
272
|
+
---
|
188
273
|
|
189
|
-
Setting
|
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.
|
190
280
|

|
191
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
|
+
|
192
305
|
## Development
|
193
306
|
|
194
|
-
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
|
+
---
|
195
311
|
|
196
312
|
## Contributing
|
197
313
|
|
198
|
-
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
|
+
---
|
199
317
|
|
200
318
|
## License
|
201
319
|
|
202
|
-
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/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
|
+
}
|