BrowserAppBase
Windows and Linux browser-based desktop application templates.
On Linux, the Chrome browser is used by default. On Windows, the Edge browser is used by default.
Installation
Add this line to your application's Gemfile:
gem 'browser_app_base'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install browser_app_base
Usage
create_browser_app [options]
-d, --dir dir_name application directory
-a, --app app_name application name
-h, --help command help
Create app templat
$ create_browser_app -d /path/to/test/ -a MyApp
add application code
$ cd /path/to/test/
$ vi my_app.rb
class MyApp < AppMainBase
def start(argv)
super
# add application code
end
def stop()
super
# add application code
end
end
ui application sample
index.html
css/index.css
js/main.js
Start application
$ /path/to/test/bin/start_my_app.rb
browser setting
Configure your browser for Windows or Linux.
${home}/${app_nane}/config/browser.json
{
"chrome_win": "start msedge",
"chrome_win_": "start chrome",
"chrome_linux": "/bin/google-chrome"
}
Send a message from your browser application to your ruby application
Use the send_message function.
main.js sample
$("#exec").click(function () {
send_message("exec:" + $("#upFile").val());
});
Send a message from the ruby application to the browser application
Use the app_send function.
my_app_sample.rb sample
class MyApp < AppMainBase
def start(argv)
# popup message
app_send("popup:message string")
# log message
yield "log message"
end
end
Application Setting
You can add settings by modifying setting.json.
${home}/${app_nane}/config/setting.json
[
{
"name": "name1",
"value": "value1 2 3 4",
"type": "input",
"select": "",
"description": "設定項目1"
},
{
"name": "name2",
"value": true,
"type": "checkbox",
"select": "",
"description": "有効にする場合はチェック"
},
{
"name": "name3",
"value": "2",
"type": "select",
"select": [
"1",
"2",
"3",
"4",
"5"
],
"description": "選択項目"
},
{
"name": "name4",
"value": "value4",
"type": "input",
"select": "",
"description": "設定項目4"
},
{
"name": "name5",
"value": "value5",
"type": "input",
"select": "",
"description": "設定項目5"
},
{
"name": "name6",
"value": "value6",
"type": "input",
"select": "",
"description": "設定項目6"
}
]
You can access the settings from your Ruby application like this:
class MyApp < AppMainBase
def start(argv)
# popup message
app_send("popup:message string")
# log message
yield "log message"
end
# read setting
puts @config["name1"]
end
Setting menu
Setting screen
Development
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.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kuwayama1971/BrowserAppBase.
License
The gem is available as open source under the terms of the MIT License.