- Author
-
SouthWolf
- Copyright
-
Copyright © 2011 SouthWolf, Yinxiangma Inc.
- License
- Info
- Git
- Bugs
This plugin adds helpers for the YinXiangMa CAPTCHA API. In your views you can use the yinxiangma_tags
method to embed the needed javascript, and you can validate in your controllers with yinxiangma_valid
.
Beforehand you need to configure YinXiangMa with your custom publisher key. You may find detailed examples below. Exceptions will be raised if you call these methods and the keys can’t be found.
This gem tries to introduces a more convenient way to configure YinXiangMa’s settings. The structure & style are inspired by reCAPTCHA gem
YinXiangMa for Rails, add this to your Gemfile:
gem "yinxiangma", :require => "yinxiangma/rails"
Or, it can be installed as a gem:
config.gem "yinxiangma", :lib => "yinxiangma/rails"
Or, as a standard rails plugin:
script/plugin install git://github.com/southwolf/yinxiangma.git
There are multiple ways to setup your YinXiangMa API key once you obtain one.
You may use the block style configuration. The following code could be placed into a config/initializers/yinxiangma.rb
when used in a Rails project.
Yinxiangma.configure do |config| config.publisher_key = 'cb9d0fe8dabdea89019d845be3059973' config.mode ='live' end
This way, you may also set additional options to fit YinXiangMa into your deployment environment.
Or, you can keep your keys out of your code base by exporting the following environment variables. You might do this in the .profile/rc, or equivalent for the user running your application:
export YINXIANGMA_PUBLISHER_KEY = 'cb9d0fe8dabdea89019d845be3059973'
You can also pass in your keys as options at runtime, for example:
yinxiangma_tags :publisher_key => 'cb9d0fe8dabdea89019d845be3059973'
This option might be useful, if the same code base is used for multiple YinXiangMa setups.
Add yinxiangma_tags
to each form you want to protect.
And, add yinxiangma_valid
logic to each form action that you’ve protected.
This method generate HTML tag including YinXiangMa widget.
This method returns true
or false
after processing the parameters from the YinXiangMa widget.
-
Validation Error handlings
-
Better documentation
-
Switch back to local CAPTCHA or reCAPTHA when YinXiangMa is unavailable
印象码 是目前中国国内推出的第一款视频广告验证码云服务平台,不仅提供了安全的基于云计算的视频验证码服务,为网站提供了良好的验证码用户体验,并且提出了新一代的基于用户反馈的广告计费商业模式概念。
本gem提供了Rails下的印象码功能,配置简单。
首先请注册印象码服务,获取API key 建立config/initializers/yinxiangma.rb
内容如下(请将publisher_key替换成您的key)
Yinxiangma.configure do |config| config.publisher_key = 'cb9d0fe8dabdea89019d845be3059973' config.mode ='live' end
在Gemfile添加
gem "yinxiangma", :require => "yinxiangma/rails"
建立
在View中插入<%= yinxiangma_tags %>, 在View中需要进行验证处插入yinxiangma_valid() 即可