kamiliff 0.28.0 → 0.32.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: ab005f01ac6af835748c47ef0c94a5036f7da0d0ed2e250750adaee470f7cf4d
4
- data.tar.gz: deba6685fa6388fc17b0b97ee26a0980ddd686b55b180c56b9a93527b27cde36
3
+ metadata.gz: 36670cc34affa11b01f78976bd3630a7a5cae7061f420a83e4c5a4ae4e49c118
4
+ data.tar.gz: 439962ffdba9c96506dd942d876c28888d6c49054db21faa7e19454f598c3d9c
5
5
  SHA512:
6
- metadata.gz: c84c268fcad2335741d7fb4e0c80bcc7997d895ceda2b81263f72932900ac679211e5ab1407746b63aca9545947657c0f249dbe2f4426ea9e0839f9a70860e52
7
- data.tar.gz: 9d2be0ac73c44d9ae24608d12eab10351d8ce7c4dd413e46f45962637b832691513154cf842a32bf2f2f6ead904e8df9567da64e65927c2badf8a01dfe102bd4
6
+ metadata.gz: ad8417dbe7cdd11be8b7a147887812485ea313994795673479432997f0bd94d2f896c05bde1b30eedd74b7d1157ae92d8d9d7f97327cd45944e4b6472ff49e01
7
+ data.tar.gz: e89b3b1e26bb1f9ba1d76c388dff2029cd0e344f2187330c8930607401b697c0c093c6e008a84afb60cf96203f94788e01d4b847e2f8828b47dcae77f5cdf5bb
data/README.md CHANGED
@@ -123,3 +123,9 @@ Create by [etrex](https://etrex.tw)
123
123
 
124
124
  ## License
125
125
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
126
+
127
+ ## How to test this gem
128
+
129
+ ```
130
+ rails t
131
+ ```
@@ -0,0 +1,16 @@
1
+ <%
2
+ messages = [messages] if messages.is_a? Hash
3
+ messages = messages.to_json if messages.is_a? Array
4
+ %>
5
+
6
+ <script>
7
+ (function(){
8
+ async function send_messages(){
9
+ const messages = <%= raw messages %>;
10
+ await liff.sendMessages(messages);
11
+ liff.closeWindow();
12
+ }
13
+
14
+ send_messages();
15
+ })();
16
+ </script>
@@ -0,0 +1,36 @@
1
+ <%
2
+ messages = [messages] if messages.is_a? Hash
3
+ messages = messages.to_json if messages.is_a? Array
4
+ %>
5
+
6
+ <script>
7
+ (function(){
8
+ async function share_target_picker(messages){
9
+ /* JS 不支援的情況 */
10
+ if (!liff.isApiAvailable('shareTargetPicker')){
11
+ return;
12
+ }
13
+
14
+ /* 分享訊息給好友 */
15
+ const response = await liff.shareTargetPicker(messages);
16
+
17
+ /* 分享訊息失敗 */
18
+ if(!response){
19
+ const [majorVer, minorVer] = (liff.getLineVersion() || "").split('.');
20
+ if (parseInt(majorVer) == 10 && parseInt(minorVer) < 11) {
21
+ alert("你的 LINE 版本太舊,無法使用分享訊息功能。");
22
+ } else {
23
+ alert("你已取消分享訊息。");
24
+ }
25
+ }
26
+ }
27
+
28
+ async function send_messages(){
29
+ const messages = <%= raw messages %>;
30
+ await share_target_picker(messages);
31
+ liff.closeWindow();
32
+ }
33
+
34
+ send_messages();
35
+ })();
36
+ </script>
@@ -38,8 +38,16 @@ let open_liff_page = (function(){
38
38
  }
39
39
  }
40
40
 
41
+ async function get_liff_profile(){
42
+ try{
43
+ return await liff.getProfile();
44
+ }catch(error){
45
+ return {};
46
+ }
47
+ }
48
+
41
49
  async function get_liff_data(){
42
- const profile = await liff.getProfile();
50
+ const profile = await get_liff_profile();
43
51
  const context = liff.getContext();
44
52
  return {
45
53
  profile,
@@ -3,4 +3,4 @@
3
3
  # Add new mime types for use in respond_to blocks:
4
4
  # Mime::Type.register "text/richtext", :rtf
5
5
 
6
- Mime::Type.register "text/html", :liff
6
+ Mime::Type.register_alias "text/html", :liff
@@ -7,7 +7,8 @@ class Base64DecodeService
7
7
  end
8
8
 
9
9
  def run
10
- json = Base64.decode64(@base64_string)
10
+ string = @base64_string.tr('-','+').tr('_','/')
11
+ json = Base64.decode64(string)
11
12
  options = JSON.parse(json)
12
13
  options.with_indifferent_access
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module Kamiliff
2
- VERSION = '0.28.0'
2
+ VERSION = '0.32.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.28.0
4
+ version: 0.32.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-06-27 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -39,6 +39,8 @@ files:
39
39
  - app/helpers/liff_helper.rb
40
40
  - app/views/layouts/application.liff.erb
41
41
  - app/views/layouts/liff.html.erb
42
+ - app/views/liff/_send_messages.liff.erb
43
+ - app/views/liff/_share_target_picker.liff.erb
42
44
  - app/views/liff/entry.html.erb
43
45
  - app/views/liff/route.html.erb
44
46
  - config/initializers/assets.rb
@@ -71,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
73
  - !ruby/object:Gem::Version
72
74
  version: '0'
73
75
  requirements: []
74
- rubygems_version: 3.1.2
76
+ rubygems_version: 3.1.4
75
77
  signing_key:
76
78
  specification_version: 4
77
79
  summary: An easy way to use LINE Front-end Framework(LIFF) on rails.