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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67e7634547fd11ce85cb180a5ca851f7738bcf9f3c13a2d8fc90f54c62c31e87
4
- data.tar.gz: 789cd493d0f2ee077988fae2aff5d7746982b8578e56b99b8ae479ff4635a140
3
+ metadata.gz: 38aca00ff3bcedc33c8e81f3c2067db8aeba06020701d93b03e8c6927b12267e
4
+ data.tar.gz: 7a5eeece3bc9a2530d568b9b50c99e8fd39e77b4f48ee79a59e85b1cf07811d6
5
5
  SHA512:
6
- metadata.gz: e1022327b2f5265a6abc343576a35999d88a36a207a3f0ddb8fe0bdd85ee28a769c099809c567bd135769ac8b5f5356924e66ef917fede1cc12a56664f9fc9fb
7
- data.tar.gz: 4a8abeb3abb678138d5174f989cb907ec72ac93b4a03b3f4b1ffed3d790e8ae883d09b610d1283bca195091a4d1d79278eb19b9a6c721e1558a9740ed5e2a111
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
- @body = reserve_route(path, request_params: source_info.merge(query), format: :liff)
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 dispatch_ready_event(data){
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 route(data){
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
- dispatch_ready_event();
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
- liff.init({
47
- liffId: "<%= @liff.id %>"
48
- })
49
- .then(() => {
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 %>
@@ -1,3 +1,3 @@
1
1
  module Kamiliff
2
- VERSION = '0.26.0'
2
+ VERSION = '0.27.0'
3
3
  end
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.26.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-03-06 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails