kamiliff 0.26.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/liff_controller.rb +2 -1
- data/app/views/liff/entry.html.erb +31 -26
- data/lib/kamiliff/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: 38aca00ff3bcedc33c8e81f3c2067db8aeba06020701d93b03e8c6927b12267e
|
4
|
+
data.tar.gz: 7a5eeece3bc9a2530d568b9b50c99e8fd39e77b4f48ee79a59e85b1cf07811d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcded347d34ad824c20dc0e481d46e5ee376140f049a7d3fe603d6ea71dd9662bcfe9d09bd4d9cb2d3a2ad384f8503f4bfaeb22529a5a040a09e570bc99410a0
|
7
|
+
data.tar.gz: 71bbd81ebc6963ddd9dca6244803e62c4bbbce31ec4479b7f7fa3d948c8fa2ce7e397ebc225d10f832d6ee3ba6f744c2c7e45d900143f6885db17ab89bb32b4e
|
@@ -30,7 +30,8 @@ class LiffController < ActionController::Base
|
|
30
30
|
def route
|
31
31
|
path, query = params["path"].split("?")
|
32
32
|
query = Rack::Utils.parse_nested_query(query)
|
33
|
-
|
33
|
+
http_method = query["_method"]&.upcase || "GET"
|
34
|
+
@body = reserve_route(path, http_method: http_method, request_params: source_info.merge(query), format: :liff)
|
34
35
|
end
|
35
36
|
|
36
37
|
private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :js do %>
|
2
2
|
<script>
|
3
|
-
(function(){
|
3
|
+
let open_liff_page = (function(){
|
4
4
|
function append_csrf(data){
|
5
5
|
var csrf_param = undefined;
|
6
6
|
var csrf_token = undefined;
|
@@ -24,47 +24,52 @@
|
|
24
24
|
$("#liff_body").html(body);
|
25
25
|
}
|
26
26
|
|
27
|
-
function
|
27
|
+
function dispatch_liff_ready_event(){
|
28
28
|
var event = new CustomEvent('liff_ready');
|
29
29
|
window.dispatchEvent(event);
|
30
30
|
}
|
31
31
|
|
32
|
-
function
|
32
|
+
async function liff_init(){
|
33
|
+
await liff.init({
|
34
|
+
liffId: "<%= @liff.id %>"
|
35
|
+
});
|
36
|
+
if (!liff.isLoggedIn()) {
|
37
|
+
liff.login();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
async function get_liff_data(){
|
42
|
+
const profile = await liff.getProfile();
|
43
|
+
const context = liff.getContext();
|
44
|
+
return {
|
45
|
+
profile,
|
46
|
+
context
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
async function open_liff_page(path){
|
51
|
+
const data = await get_liff_data();
|
52
|
+
data.path = path;
|
33
53
|
$.ajax({
|
34
54
|
type: "POST",
|
35
55
|
url: '/liff_route',
|
36
56
|
data: append_csrf(data)
|
37
57
|
}).done(function(html){
|
38
58
|
render_body(html);
|
39
|
-
|
59
|
+
dispatch_liff_ready_event();
|
40
60
|
}).fail(function(e){
|
41
61
|
alert("on error: " + JSON.stringify(e));
|
42
62
|
});
|
43
63
|
}
|
44
64
|
|
45
|
-
window.onload = function() {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
if (!liff.isLoggedIn()) {
|
51
|
-
liff.login();
|
52
|
-
}else{
|
53
|
-
liff.getProfile().then(profile => {
|
54
|
-
const data = {};
|
55
|
-
data.context = liff.getContext();
|
56
|
-
data.profile = profile;
|
57
|
-
data.path = "<%= @liff.path %>";
|
58
|
-
<% if !@need_reload %>
|
59
|
-
route(data);
|
60
|
-
<% end %>
|
61
|
-
})
|
62
|
-
}
|
63
|
-
})
|
64
|
-
.catch((err) => {
|
65
|
-
console.log(err.code, err.message);
|
66
|
-
});
|
65
|
+
window.onload = async function() {
|
66
|
+
await liff_init();
|
67
|
+
<% if !@need_reload %>
|
68
|
+
await open_liff_page("<%= @liff.path %>");
|
69
|
+
<% end %>
|
67
70
|
};
|
71
|
+
|
72
|
+
return open_liff_page;
|
68
73
|
})();
|
69
74
|
</script>
|
70
75
|
<% end %>
|
data/lib/kamiliff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamiliff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- etrex kuo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|