kamiliff 0.23.0 → 0.24.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 +10 -3
- data/app/helpers/liff_helper.rb +6 -1
- data/config/routes.rb +1 -0
- data/lib/kamiliff.rb +1 -0
- data/lib/kamiliff/services/liff_base64_service.rb +52 -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: 3189c0303b55fd1e7d8ed2cc55f613544f8bdd9db48f34cf526baec151044afe
|
4
|
+
data.tar.gz: 5204d91c73e59aec7386a07f1f25d7ef4f1a5b6d9f5eb81d032faf91ac0e94cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba41019d9be741d925eacf2451a16e3d4486a7404f2a2ed696eaed173b4f99f32bf235d4360331213113ba4a84a8de4ebccd7e98847d7f0673b302313c67bd2a
|
7
|
+
data.tar.gz: 226c181fd2fb67213dd105c984a1d251ccf58a3eb33645f2b0bdda5092c280810d91c9e09cd8e51dcb310f547d9cd48c2dc957a5471e152673334857abe81a6d
|
@@ -8,11 +8,18 @@ class LiffController < ActionController::Base
|
|
8
8
|
# fix liff 2.0 redirect issue
|
9
9
|
@need_reload = query["liff.state"].present?
|
10
10
|
if(@need_reload)
|
11
|
-
|
12
|
-
|
11
|
+
if query["liff.state"].index('?').present?
|
12
|
+
querystring = query["liff.state"][(query["liff.state"].index('?')+1)..-1]
|
13
|
+
query = Rack::Utils.parse_nested_query(querystring)
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
|
-
|
17
|
+
# try base64 decode
|
18
|
+
if params[:base64].present?
|
19
|
+
@liff = LiffBase64Service.from_base64(params[:base64])
|
20
|
+
else
|
21
|
+
@liff = LiffService.new(query)
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
def route
|
data/app/helpers/liff_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module LiffHelper
|
2
|
-
def
|
2
|
+
def old_liff_path(params)
|
3
3
|
liff = LiffService.new(params)
|
4
4
|
if ENV["LIFF_MODE"]&.downcase == "replace"
|
5
5
|
return "#{liff.url}/liff_entry?#{params.to_query}"
|
@@ -7,4 +7,9 @@ module LiffHelper
|
|
7
7
|
# liff mode is Concatenate
|
8
8
|
"#{liff.url}?#{params.to_query}"
|
9
9
|
end
|
10
|
+
|
11
|
+
def liff_path(params)
|
12
|
+
liff = LiffBase64Service.new(params)
|
13
|
+
liff.full_url
|
14
|
+
end
|
10
15
|
end
|
data/config/routes.rb
CHANGED
data/lib/kamiliff.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
3
|
+
class LiffBase64Service
|
4
|
+
|
5
|
+
# rails routes path
|
6
|
+
attr_accessor :path
|
7
|
+
|
8
|
+
# size
|
9
|
+
# COMPACT TALL FULL
|
10
|
+
attr_accessor :size
|
11
|
+
|
12
|
+
# liff app url
|
13
|
+
# https://liff.line.me/app/#{liff_id}
|
14
|
+
attr_accessor :url
|
15
|
+
|
16
|
+
# liff id
|
17
|
+
attr_accessor :id
|
18
|
+
|
19
|
+
def self.from_base64(base64_string)
|
20
|
+
base64_string = base64_string.tr('-','+').tr('_','/')
|
21
|
+
json = Base64.decode64(base64_string)
|
22
|
+
options = JSON.parse(json)
|
23
|
+
LiffBase64Service.new(options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_base64
|
27
|
+
json = {
|
28
|
+
path: path,
|
29
|
+
size: size
|
30
|
+
}.to_json
|
31
|
+
base64_string = Base64.encode64(json)
|
32
|
+
base64_string.tr('+','-').tr('/','_')[0..-4]
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(options)
|
36
|
+
options = options.with_indifferent_access
|
37
|
+
self.path = options[:path] || "/"
|
38
|
+
self.size = options[:liff_size] || :compact
|
39
|
+
self.size = size.to_s.upcase
|
40
|
+
raise "liff_size should be compact, tall or full." unless size.in? %w[COMPACT TALL FULL]
|
41
|
+
self.url = ENV["LIFF_#{size}"]
|
42
|
+
raise "LIFF_#{size} should be in the env variables" if url.blank?
|
43
|
+
self.id = url[(url.rindex('/')+1)..-1]
|
44
|
+
end
|
45
|
+
|
46
|
+
def full_url
|
47
|
+
if ENV["LIFF_MODE"]&.downcase == "replace"
|
48
|
+
end
|
49
|
+
# liff mode is Concatenate
|
50
|
+
"#{url}/#{to_base64}"
|
51
|
+
end
|
52
|
+
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.24.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:
|
11
|
+
date: 2021-01-22 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_base64_service.rb
|
49
50
|
- lib/kamiliff/services/liff_service.rb
|
50
51
|
- lib/kamiliff/version.rb
|
51
52
|
- lib/tasks/kamiliff_tasks.rake
|