wechat-gate 0.1.3 → 0.1.4
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/Gemfile.lock +1 -1
- data/README.md +32 -0
- data/RELEASE.md +5 -0
- data/lib/tasks/wechat_gate.rake +22 -0
- data/lib/wechat-gate.rb +1 -0
- data/lib/wechat_gate/railtie.rb +8 -0
- data/lib/wechat_gate/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ba598a7d910af520e8bc6c9b3594718e15b903b
|
4
|
+
data.tar.gz: 2e701b25edda15379406b633fe6d484b8653f140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f9deb00d3e385360bfb1f54c65469b302d3bf124d1460d7283216b7fdcaaf5bab2400ee821962f02d7e8fd7be4d1037b195c8bb844127fb9ac11d5c33092f41
|
7
|
+
data.tar.gz: a047f4680fff1355ce6af76b3f05193aa6cf4333c59c75a51d3c28010053f3f73a138a6b77b46674bdabf2d131bcdf30be2c6e4f0751a77514fb04f00d5f2648
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -152,6 +152,38 @@ var wxServerConfig = <%= @data.to_json.html_safe %>;
|
|
152
152
|
})();
|
153
153
|
```
|
154
154
|
|
155
|
+
## 其他功能
|
156
|
+
|
157
|
+
### 自定义菜单
|
158
|
+
|
159
|
+
首先设置菜单配置文件,config/wechat_menu.yml,支持erb,格式请参考[微信自定义菜单文档](https://mp.weixin.qq.com/wiki):
|
160
|
+
|
161
|
+
```
|
162
|
+
button:
|
163
|
+
- type: view
|
164
|
+
name: 我的2
|
165
|
+
url: <%= @config.oauth2_entrance_url(scope: 'snsapi_userinfo', state: 'profile') %>
|
166
|
+
- type: view
|
167
|
+
name: 课程
|
168
|
+
sub_button:
|
169
|
+
- type: view
|
170
|
+
name: 免费课程
|
171
|
+
url: <%= @config.oauth2_entrance_url(scope: 'snsapi_userinfo', state: 'free') %>
|
172
|
+
- type: view
|
173
|
+
name: 付费课程
|
174
|
+
url: <%= @config.oauth2_entrance_url(scope: 'snsapi_userinfo', state: 'paid') %>
|
175
|
+
```
|
176
|
+
|
177
|
+
> 其中的**@config**变量为当前微信公众号实例,请不要修改,直接使用
|
178
|
+
|
179
|
+
然后执行rake任务:
|
180
|
+
|
181
|
+
```shell
|
182
|
+
$rails wechat_gate:create_menu APP_NAME=eggman CONFIG=/path/to/wechat.yml MENU=/path/to/wechat_menu
|
183
|
+
```
|
184
|
+
|
185
|
+
其中,CONFIG默认为config/wechat.yml,MENU默认为config/wechat_menu.yml,APP_NAME必须指定
|
186
|
+
|
155
187
|
## TODO
|
156
188
|
|
157
189
|
添加测试
|
data/RELEASE.md
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'wechat_gate/exception'
|
2
|
+
|
3
|
+
namespace :wechat_gate do
|
4
|
+
|
5
|
+
def validate_envs
|
6
|
+
raise WechatGate::Exception::ConfigException, 'need specify APP_NAME!' unless ENV['APP_NAME']
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "create menu, APP_NAME=app_name, CONFIG=/path/to/config/file.yml, MENU=/path/to/menu/config/file.yml"
|
10
|
+
task :create_menu => :environment do
|
11
|
+
validate_envs
|
12
|
+
|
13
|
+
@config = WechatGate::Config.new(ENV['APP_NAME'], ENV['CONFIG'])
|
14
|
+
|
15
|
+
menu_file = ENV['MENU']
|
16
|
+
menu_file = "#{Dir.pwd}/config/wechat_menu.yml" unless menu_file
|
17
|
+
raise WechatGate::Exception::ConfigException, "MENU #{menu_file} not found!" unless File.exists?(menu_file)
|
18
|
+
|
19
|
+
menu = YAML.load(ERB.new(File.read(menu_file)).result(binding))
|
20
|
+
@config.menu_create(JSON.generate(menu))
|
21
|
+
end
|
22
|
+
end
|
data/lib/wechat-gate.rb
CHANGED
data/lib/wechat_gate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wechat-gate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lei Lee
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- bin/refresh_token_and_ticket
|
86
86
|
- bin/setup
|
87
87
|
- config/wechat.yml
|
88
|
+
- lib/tasks/wechat_gate.rake
|
88
89
|
- lib/wechat-gate.rb
|
89
90
|
- lib/wechat_gate/config.rb
|
90
91
|
- lib/wechat_gate/controller.rb
|
@@ -93,6 +94,7 @@ files:
|
|
93
94
|
- lib/wechat_gate/menu.rb
|
94
95
|
- lib/wechat_gate/message.rb
|
95
96
|
- lib/wechat_gate/oauth.rb
|
97
|
+
- lib/wechat_gate/railtie.rb
|
96
98
|
- lib/wechat_gate/request.rb
|
97
99
|
- lib/wechat_gate/send_message.rb
|
98
100
|
- lib/wechat_gate/tokens/access_token.rb
|