kamiliff 0.14.0 → 0.15.0
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/app/controllers/liff_controller.rb +7 -6
- data/app/helpers/liff_helper.rb +2 -5
- data/app/views/layouts/liff.html.erb +1 -1
- data/app/views/liff/entry.html.erb +17 -8
- data/lib/kamiliff.rb +1 -0
- data/lib/kamiliff/services/liff_service.rb +26 -0
- data/lib/kamiliff/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e1a6426cb9312e84ac551da647721c6a63c4def94bbda616618e219a1bf5b61
|
4
|
+
data.tar.gz: 1290e1aa4a8fba4c814836992b1271cc722fbc4017298584971d7eb72f7ab565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1dae23952d71fc92ce40301baf1d8a4b1b40681c3545333d2f024aec282466730c0b762181dbb9bb57c28034ecf0682e19791f5a00bb37705daa98a2e1f0a0a
|
7
|
+
data.tar.gz: 570d689c3734d11b6adc4ddc67323f0e190fc710be3c2cba95029351e776da307c7bcd1a1dc14eeb6802db75ef8e8e35b56ef997491b8c8f017d1fa6358c8e62
|
@@ -2,16 +2,17 @@
|
|
2
2
|
class LiffController < ApplicationController
|
3
3
|
layout false, only: :route
|
4
4
|
|
5
|
-
|
6
5
|
def entry
|
7
6
|
query = Rack::Utils.parse_nested_query(request.query_string)
|
8
7
|
|
9
|
-
# fix liff 2.0
|
10
|
-
|
11
|
-
|
8
|
+
# fix liff 2.0 redirect issue
|
9
|
+
@need_reload = query["liff.state"].present?
|
10
|
+
if(@need_reload)
|
11
|
+
querystring = query["liff.state"][(query["liff.state"].index('?')+1)..-1]
|
12
|
+
query = Rack::Utils.parse_nested_query(querystring)
|
12
13
|
end
|
13
14
|
|
14
|
-
@
|
15
|
+
@liff = LiffService.new(query)
|
15
16
|
end
|
16
17
|
|
17
18
|
def route
|
@@ -32,7 +33,7 @@ class LiffController < ApplicationController
|
|
32
33
|
|
33
34
|
res = Rails.application.routes.router.serve(request)
|
34
35
|
res[2].body
|
35
|
-
rescue
|
36
|
+
rescue Exception => e
|
36
37
|
res[2].to_s
|
37
38
|
end
|
38
39
|
|
data/app/helpers/liff_helper.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
module LiffHelper
|
2
2
|
def liff_path(params)
|
3
|
-
|
4
|
-
|
5
|
-
raise "liff_size should be compact, tall or full." unless liff_size.in? %w[COMPACT TALL FULL]
|
6
|
-
liff_url = ENV["LIFF_#{liff_size}"]
|
7
|
-
"#{liff_url}?#{params.to_query}"
|
3
|
+
liff = LiffService.new(params)
|
4
|
+
"#{liff.url}/liff_entry?#{params.to_query}"
|
8
5
|
end
|
9
6
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<%= csrf_meta_tags %>
|
6
6
|
<%= csp_meta_tag %>
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1" >
|
8
|
-
<script src="https://
|
8
|
+
<script src="https://static.line-scdn.net/liff/edge/2.1/sdk.js"></script>
|
9
9
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
|
10
10
|
|
11
11
|
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
@@ -42,15 +42,24 @@
|
|
42
42
|
});
|
43
43
|
}
|
44
44
|
|
45
|
-
liff.init(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
liff.init({
|
46
|
+
liffId: "<%= @liff.id %>"
|
47
|
+
})
|
48
|
+
.then(() => {
|
49
|
+
if (!liff.isLoggedIn()) {
|
50
|
+
liff.login();
|
51
|
+
}else{
|
52
|
+
const data = {};
|
53
|
+
data.context = liff.getContext();
|
54
|
+
data.path = "<%= @liff.path %>";
|
55
|
+
<% if !@need_reload %>
|
56
|
+
route(data);
|
57
|
+
<% end %>
|
52
58
|
}
|
53
|
-
)
|
59
|
+
})
|
60
|
+
.catch((err) => {
|
61
|
+
console.log(err.code, err.message);
|
62
|
+
});
|
54
63
|
})();
|
55
64
|
</script>
|
56
65
|
<% end %>
|
data/lib/kamiliff.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
class LiffService
|
2
|
+
|
3
|
+
# rails routes path
|
4
|
+
attr_accessor :path
|
5
|
+
|
6
|
+
# size
|
7
|
+
# COMPACT TALL FULL
|
8
|
+
attr_accessor :size
|
9
|
+
|
10
|
+
# liff app url
|
11
|
+
# https://liff.line.me/app/#{liff_id}
|
12
|
+
attr_accessor :url
|
13
|
+
|
14
|
+
# liff id
|
15
|
+
attr_accessor :id
|
16
|
+
|
17
|
+
def initialize(options)
|
18
|
+
self.path = options[:path] || options['path'] || "/"
|
19
|
+
self.size = options[:liff_size] || options['liff_size'] || :compact
|
20
|
+
self.size = size.to_s.upcase
|
21
|
+
raise "liff_size should be compact, tall or full." unless size.in? %w[COMPACT TALL FULL]
|
22
|
+
self.url = ENV["LIFF_#{size}"]
|
23
|
+
raise "LIFF_#{size} should be in the env variables" if url.empty?
|
24
|
+
self.id = url[(url.rindex('/')+1)..-1]
|
25
|
+
end
|
26
|
+
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.15.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: 2020-04-
|
11
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- config/routes.rb
|
47
47
|
- lib/kamiliff.rb
|
48
48
|
- lib/kamiliff/engine.rb
|
49
|
+
- lib/kamiliff/services/liff_service.rb
|
49
50
|
- lib/kamiliff/version.rb
|
50
51
|
- lib/tasks/kamiliff_tasks.rake
|
51
52
|
homepage: https://github.com/etrex/kamiliff
|