webview 0.1.5 → 0.1.6
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/Gemfile.lock +1 -1
- data/examples/htmlfile.rb +15 -0
- data/examples/rpc.html +41 -0
- data/ext/webview/main.go +7 -0
- data/lib/webview/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e1807345149b5a05d24e6cd5dcbcf045176b2b2a2e09e73f7b53aeb8516b816
|
4
|
+
data.tar.gz: b19c960a4d477ce74aa637d8a710006de2d5076c679ecaa91d44767bf3d297df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e445a56b4fb64ac8edb61b96548cfddd1951f32a5e9f4daccd9ab66721fe9d1a951e23fcd8f67870f97e703b10a94cf598a4cd0b502d14f4bac31e1b232a0587
|
7
|
+
data.tar.gz: 354efbac5797f39232211edefbc35d7db24b0853f5406a00266e9ab88576ed8b396cc21995c4049a07768c42bccdbc19a45e25ee0e5446e9c16a40a5a6269ba9
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'webview'
|
4
|
+
|
5
|
+
app = Webview::App.new(title: 'Ruby Language')
|
6
|
+
filepath = File.expand_path('../rpc.html', __FILE__)
|
7
|
+
app.open("file://#{filepath}")
|
8
|
+
|
9
|
+
at_exit { app.close }
|
10
|
+
begin
|
11
|
+
app.join
|
12
|
+
rescue Interrupt
|
13
|
+
app.close
|
14
|
+
end
|
15
|
+
|
data/examples/rpc.html
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
</head>
|
4
|
+
|
5
|
+
<body>
|
6
|
+
<button data-rpc='openfile'>OpenFile</button>
|
7
|
+
<button data-rpc='opendir'>OpenDir</button>
|
8
|
+
<button data-rpc='fullscreen'>Fullscreen</button>
|
9
|
+
<button data-rpc='unfullscreen'>Unfullscreen</button>
|
10
|
+
<button data-rpc='savefile'>SaveFile</button>
|
11
|
+
<button data-rpc='close'>Close</button>
|
12
|
+
|
13
|
+
<br />
|
14
|
+
<br />
|
15
|
+
<hr />
|
16
|
+
|
17
|
+
<strong>Output: </strong>
|
18
|
+
<div id='output'></div>
|
19
|
+
|
20
|
+
<script type='text/javascript'>
|
21
|
+
var output = document.querySelector('#output')
|
22
|
+
|
23
|
+
window.rpc_cb = function(type, value, userdata) {
|
24
|
+
output.innerHTML = output.innerHTML + "<br />" +
|
25
|
+
'RPC callback "' + type + '", "' + value + '", "' + userdata + '"';
|
26
|
+
}
|
27
|
+
|
28
|
+
var elems = document.querySelectorAll('button[data-rpc]');
|
29
|
+
for (var i = 0; i < elems.length; i++) {
|
30
|
+
var elem = elems[i];
|
31
|
+
elem.onclick = function(e) {
|
32
|
+
var action = e.target.dataset.rpc;
|
33
|
+
var userdata = new Date().getTime().toString();
|
34
|
+
var data = action + ',' + userdata
|
35
|
+
output.innerHTML = output.innerHTML + "<br /> invoke data: \"" + data + '"';
|
36
|
+
window.external.invoke(data);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
</script>
|
40
|
+
</body>
|
41
|
+
</html>
|
data/ext/webview/main.go
CHANGED
@@ -7,11 +7,18 @@ import "flag"
|
|
7
7
|
import "fmt"
|
8
8
|
import "os"
|
9
9
|
import "strings"
|
10
|
+
import "runtime"
|
10
11
|
|
11
12
|
func EvalCallback(w webview.WebView, name string, value string, userdata string) {
|
12
13
|
value = strings.Replace(value, "'", "\\'", -1)
|
13
14
|
userdata = strings.Replace(userdata, "'", "\\'", -1)
|
14
15
|
|
16
|
+
// for windows path
|
17
|
+
if runtime.GOOS == "windows" {
|
18
|
+
value = strings.Replace(value, "\\", "\\\\", -1)
|
19
|
+
userdata = strings.Replace(userdata, "\\", "\\\\", -1)
|
20
|
+
}
|
21
|
+
|
15
22
|
w.Eval(fmt.Sprintf(`
|
16
23
|
(function(){
|
17
24
|
var cb = window.rpc_cb;
|
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.6
|
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-06-
|
11
|
+
date: 2019-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,8 @@ files:
|
|
72
72
|
- bin/console
|
73
73
|
- bin/setup
|
74
74
|
- examples/app.rb
|
75
|
+
- examples/htmlfile.rb
|
76
|
+
- examples/rpc.html
|
75
77
|
- ext/Makefile
|
76
78
|
- ext/extconf.rb
|
77
79
|
- ext/webview/main.go
|