webview 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/.travis.yml +17 -2
- data/README.md +29 -3
- data/ext/webview/main.go +6 -3
- data/lib/webview/app.rb +13 -5
- data/lib/webview/version.rb +1 -1
- 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: 71067f7cf653b0246423225eedfcf954ca345d14b3d180698cdea616d7f237ae
|
4
|
+
data.tar.gz: 135bed20ebfc2cbd0710d01a0198918c68d01bdf51b630dc5415ef651569647e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20da9dcdd1a136e08b493407fb4311b300a1fc167c3f32b1b936385c9459e1542953a8c7487e85e65158a097d2e7f962dadfd7a287e2d134889e0a1e611beedc
|
7
|
+
data.tar.gz: 906ae1b839bb19dc1421e7f5b9b66f77ad79232a3d291373c605a6b76e3ce05b60068a8c46f54e44940e8431f9680a07585501472bdb0e13c1e49a742be1e06e
|
data/.travis.yml
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
---
|
2
2
|
sudo: false
|
3
3
|
language: ruby
|
4
|
-
cache:
|
4
|
+
cache:
|
5
|
+
- bundler
|
6
|
+
- apt
|
5
7
|
rvm:
|
6
8
|
- 2.6.3
|
7
|
-
before_install:
|
9
|
+
before_install:
|
10
|
+
- gem install bundler -v 2.0.1
|
11
|
+
|
12
|
+
- sudo add-apt-repository ppa:webkit-team/ppa -y
|
13
|
+
- sudo apt-get update
|
14
|
+
- sudo apt-get install libwebkit2gtk-4.0-dev -y
|
15
|
+
|
16
|
+
- cd ext
|
17
|
+
- ruby extconf.rb
|
18
|
+
- make && make install
|
19
|
+
- cd ..
|
20
|
+
|
21
|
+
script:
|
22
|
+
- bundle exec rspec
|
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Webview
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/xiejiangzhi/webview.svg?branch=master)](https://travis-ci.org/xiejiangzhi/webview)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/webview.svg)](https://badge.fury.io/rb/webview)
|
5
|
+
|
6
|
+
A webview GUI based on [zserge/webview](https://github.com/zserge/webview)
|
7
|
+
|
8
|
+
## Require
|
9
|
+
|
10
|
+
* `golang`
|
4
11
|
|
5
12
|
## Installation
|
6
13
|
|
@@ -35,10 +42,16 @@ end
|
|
35
42
|
Allow debug page
|
36
43
|
|
37
44
|
```ruby
|
38
|
-
|
45
|
+
Webview::App.new(debug: true).open('http://example.com')
|
46
|
+
```
|
47
|
+
|
48
|
+
All options
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
Webview::App.new(title: 'ttt', width: 600, height: 400, resizable: true, debug: true)
|
39
52
|
```
|
40
53
|
|
41
|
-
Run with your backend
|
54
|
+
Run with your backend.
|
42
55
|
|
43
56
|
```ruby
|
44
57
|
app = Webview::App.new
|
@@ -78,6 +91,19 @@ window.external.invoke('invalid_type' + ',' + 'my_data');
|
|
78
91
|
* opendir: Open a dialog, and call rpc_cb('opendir', path, user_data)
|
79
92
|
* savefile: Open a dialog, and call rpc_cb('savefile', path, user_data)
|
80
93
|
|
94
|
+
|
95
|
+
## GUI Application
|
96
|
+
|
97
|
+
If we build ruby binary for different systems, then we can public our App for normal user
|
98
|
+
|
99
|
+
Some ways:
|
100
|
+
|
101
|
+
* [Traveling Ruby](https://github.com/phusion/traveling-ruby). I have made a version to support ruby 2.6.3 [here](https://github.com/xiejiangzhi/traveling-ruby) for OSX and Linux
|
102
|
+
* [Ruby Packer](https://github.com/pmq20/ruby-packer)
|
103
|
+
|
104
|
+
|
105
|
+
When I finish my application, I will make a gem of the framework.
|
106
|
+
|
81
107
|
## Development
|
82
108
|
|
83
109
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/ext/webview/main.go
CHANGED
@@ -9,8 +9,8 @@ import "os"
|
|
9
9
|
import "strings"
|
10
10
|
|
11
11
|
func EvalCallback(w webview.WebView, name string, value string, userdata string) {
|
12
|
-
value = strings.
|
13
|
-
userdata = strings.
|
12
|
+
value = strings.Replace(value, "'", "\\'", -1)
|
13
|
+
userdata = strings.Replace(userdata, "'", "\\'", -1)
|
14
14
|
|
15
15
|
w.Eval(fmt.Sprintf(`
|
16
16
|
(function(){
|
@@ -26,7 +26,10 @@ func EvalCallback(w webview.WebView, name string, value string, userdata string)
|
|
26
26
|
|
27
27
|
func handleRPC(w webview.WebView, data string) {
|
28
28
|
s := strings.SplitN(data, ",", 2)
|
29
|
-
action, userdata := s[0],
|
29
|
+
action, userdata := s[0], ""
|
30
|
+
if len(s) > 1 {
|
31
|
+
userdata = s[1]
|
32
|
+
}
|
30
33
|
|
31
34
|
switch {
|
32
35
|
case action == "close":
|
data/lib/webview/app.rb
CHANGED
@@ -14,6 +14,9 @@ module Webview
|
|
14
14
|
debug: debug
|
15
15
|
}
|
16
16
|
@options.delete_if { |k, v| v.nil? }
|
17
|
+
@app_out = nil
|
18
|
+
@app_err = nil
|
19
|
+
@app_process = nil
|
17
20
|
end
|
18
21
|
|
19
22
|
def open(url)
|
@@ -37,12 +40,11 @@ module Webview
|
|
37
40
|
app_err.close
|
38
41
|
|
39
42
|
pid = app_process.pid
|
40
|
-
|
43
|
+
signal('QUIT')
|
41
44
|
begin
|
42
45
|
Timeout.timeout(3) { Process.wait(pid) }
|
43
46
|
rescue Timeout::Error
|
44
47
|
kill
|
45
|
-
rescue Errno::ECHILD
|
46
48
|
end
|
47
49
|
|
48
50
|
@app_process = nil
|
@@ -55,8 +57,15 @@ module Webview
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def kill
|
58
|
-
|
59
|
-
|
60
|
+
signal('TERM')
|
61
|
+
end
|
62
|
+
|
63
|
+
def signal(name)
|
64
|
+
return false unless app_process&.pid
|
65
|
+
Process.kill(name, app_process.pid)
|
66
|
+
true
|
67
|
+
rescue Errno::ECHILD, Errno::ESRCH
|
68
|
+
false
|
60
69
|
end
|
61
70
|
|
62
71
|
private
|
@@ -71,5 +80,4 @@ module Webview
|
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
74
|
-
|
75
83
|
end
|
data/lib/webview/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webview
|
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
|
- jiangzhi.xie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|