kamiliff 0.15.0 → 0.16.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e1a6426cb9312e84ac551da647721c6a63c4def94bbda616618e219a1bf5b61
4
- data.tar.gz: 1290e1aa4a8fba4c814836992b1271cc722fbc4017298584971d7eb72f7ab565
3
+ metadata.gz: 923af087cbb7e01f33610fa15c0f57c28d7d341f57e21ab0e896e6daa66f2301
4
+ data.tar.gz: c215fab6cc29f24acdd7cf94b308e7a3561edd3818335a8f0da208ead09fe238
5
5
  SHA512:
6
- metadata.gz: c1dae23952d71fc92ce40301baf1d8a4b1b40681c3545333d2f024aec282466730c0b762181dbb9bb57c28034ecf0682e19791f5a00bb37705daa98a2e1f0a0a
7
- data.tar.gz: 570d689c3734d11b6adc4ddc67323f0e190fc710be3c2cba95029351e776da307c7bcd1a1dc14eeb6802db75ef8e8e35b56ef997491b8c8f017d1fa6358c8e62
6
+ metadata.gz: 5d2aa3a7ac569d545d8aa6b83b1479ed3f260951bef938aaa8661f36aa48dfadfe0ad50cd62696d36ee5358bb0cbb5ba8e1c5e757b00e7c6eb36ddac23b0e4dc
7
+ data.tar.gz: 87cf2a57d14ac68b80c914a302a483d714972ff5bba961788841bbadf50d31ca55ee066645286713afa57db3cf2d018890e83021c91132bec249f242e7d42887
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  # Kamiliff
2
-
3
2
  Kamiliff make LIFF easy to use.
4
3
 
5
4
  # Feature
@@ -8,7 +7,113 @@ Kamiliff make LIFF easy to use.
8
7
  - liff_send_text_message: quick send message and close LIFF.
9
8
 
10
9
  ## Installation & Usage
10
+ ### Create a new rails repository:
11
+
12
+ ```bash
13
+ # create rails repository
14
+ rails new kamiliff_demo
15
+ # change directory
16
+ cd kamiliff_demo
17
+ # install gem
18
+ bundle add kamiliff
19
+ bundle add dotenv-rails
20
+ ```
21
+
22
+ ### Add LIFF Endpoint URL
23
+ Login to LINE Developers, and create 3 LIFF for 3 different size.
24
+
25
+ - For compact
26
+ - LIFF app name: Compact
27
+ - Size: Compact
28
+ - Endpoint URL: https://yourwebsite/liff_entry
29
+
30
+ - For tall
31
+ - LIFF app name: Tall
32
+ - Size: Tall
33
+ - Endpoint URL: https://yourwebsite/liff_entry
34
+
35
+ - For full
36
+ - LIFF app name: Full
37
+ - Size: Full
38
+ - Endpoint URL: https://yourwebsite/liff_entry
39
+
40
+ Since the compact size is default. You could only create the compact one.
41
+
42
+ **NOTICE:** As LINE announcement, due to a function enhancement with LIFF v2, you should add LIFF apps to LINE Login channel. The LIFF apps added to Messaging API channels are still allowed to use.
43
+
44
+ ### Set environment variables
45
+ Create a file `.env` with the following content under the root directory. Kamiliff provides two setting ways, you can choose the one based on the position where LIFF apps added.
46
+
47
+ - LIFF apps added to Messaging API channel (v1)
48
+ ```
49
+ LIFF_COMPACT=line://app/{FOR_COMPACT_LIFF_ID}
50
+ LIFF_TALL=line://app/{FOR_TALL_LIFF_ID}
51
+ LIFF_FULL=line://app/{FOR_FULL_LIFF_ID}
52
+ ```
53
+
54
+ - LIFF apps added to LINE Login channel (v2)
55
+ ```
56
+ LIFF_COMPACT=https://liff.line.me/{FOR_COMPACT_LIFF_ID}
57
+ LIFF_TALL=https://liff.line.me/{FOR_TALL_LIFF_ID}
58
+ LIFF_FULL=https://liff.line.me/{FOR_FULL_LIFF_ID}
59
+ ```
60
+
61
+ You could choose another setting method.
62
+
63
+ ### Generate simple todo resource
64
+ Create todo resource:
65
+
66
+ ```bash
67
+ rails g scaffold todo name desc
68
+ rails db:migrate
69
+ ```
70
+
71
+ ### Create LIFF view
72
+ Create liff view for new action at `app/views/todos/new.liff.erb`.
73
+
74
+ ```
75
+ <%= render "todos/form.html", todo: @todo %>
76
+
77
+ <script>
78
+ document.title = "new todo";
79
+
80
+ window.addEventListener("liff_submit", function(event){
81
+ var json = JSON.stringify(event.detail.data);
82
+ var url = event.detail.url;
83
+ var method = event.detail.method;
84
+ var request_text = method + " " + url + "\n" + json;
85
+ liff_send_text_message(request_text);
86
+ });
87
+ </script>
88
+ ```
89
+
90
+ The javascript listen to submit button click, and build the message from form data, and send to current LINE chatroom, and then close the LIFF webview.
91
+
92
+ You could modify those javascript to change the format.
93
+
94
+ ### Test LIFF view
95
+ Add following content into `app/views/todos/index.html.erb`.
96
+
97
+ ```
98
+ <%= liff_path(path: new_todo_path) %>
99
+ ```
100
+
101
+ Copy this url and paste to any LINE chatroom.
102
+
103
+ Click this url in LINE app.
104
+
105
+ The correct usage is put this url into Rich Manu or Flex Message or Template Message with url action.
106
+
107
+ ### How to change LIFF size
108
+ You can change the size of LIFF by adding a parameter to the helper method, like this:
109
+
110
+ ```
111
+ <%= liff_path(path: new_todo_path, liff_size: :compact) %>
112
+ <%= liff_path(path: new_todo_path, liff_size: :tall) %>
113
+ <%= liff_path(path: new_todo_path, liff_size: :full) %>
114
+ ```
11
115
 
116
+ ## Apps use Kamiliff
12
117
  See my kamiliff demo: [https://github.com/etrex/kamiliff_demo](https://github.com/etrex/kamiliff_demo)
13
118
 
14
119
  ## Author
@@ -42,24 +42,26 @@
42
42
  });
43
43
  }
44
44
 
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 %>
58
- }
59
- })
60
- .catch((err) => {
61
- console.log(err.code, err.message);
62
- });
45
+ window.onload = function() {
46
+ liff.init({
47
+ liffId: "<%= @liff.id %>"
48
+ })
49
+ .then(() => {
50
+ if (!liff.isLoggedIn()) {
51
+ liff.login();
52
+ }else{
53
+ const data = {};
54
+ data.context = liff.getContext();
55
+ data.path = "<%= @liff.path %>";
56
+ <% if !@need_reload %>
57
+ route(data);
58
+ <% end %>
59
+ }
60
+ })
61
+ .catch((err) => {
62
+ console.log(err.code, err.message);
63
+ });
64
+ };
63
65
  })();
64
66
  </script>
65
67
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Kamiliff
2
- VERSION = '0.15.0'
2
+ VERSION = '0.16.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.15.0
4
+ version: 0.16.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-03 00:00:00.000000000 Z
11
+ date: 2020-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails