cama_contact_form 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/plugins/cama_contact_form/contact_form_controller_concern.rb +8 -1
- data/app/controllers/plugins/cama_contact_form/admin_forms_controller.rb +1 -1
- data/app/helpers/plugins/cama_contact_form/main_helper.rb +6 -1
- data/app/models/plugins/cama_contact_form/cama_contact_form.rb +16 -0
- data/app/views/plugins/cama_contact_form/admin_forms/edit.html.erb +23 -0
- data/app/views/plugins/cama_contact_form/forms_shorcode.html.erb +1 -0
- data/lib/cama_contact_form.rb +2 -1
- data/lib/cama_contact_form/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0943d6f462a7f834e435510534030ec25adebf
|
4
|
+
data.tar.gz: d37c4f408019f089f41ebc85a29b096f6439ca4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 735fa908aecfdc95ee55c788e09b58db50fc5f5c11af6690baa39571c6683fcb99768aaa6c6f3b940085ada2d334826900cc7d518132f9a7b99737de88bd1466
|
7
|
+
data.tar.gz: c2d6c3eb58a5d8f25a5e4b8abc23bf714c429683d8db7323ced018dccefb657c170c9da37ba0586daa05ea8addb1228798534d6826798efd834560fbbb378989
|
@@ -60,9 +60,16 @@ module Plugins::CamaContactForm::ContactFormControllerConcern
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
when 'captcha'
|
63
|
-
|
63
|
+
error_message = ->{
|
64
64
|
errors << "#{label.to_s.translate}: #{form.the_message('captcha_not_match', t('.captch_error_val', default: 'The entered code is incorrect'))}"
|
65
65
|
validate = false
|
66
|
+
}
|
67
|
+
|
68
|
+
if form.recaptcha_enabled?
|
69
|
+
form.set_captcha_settings!
|
70
|
+
error_message.call unless verify_recaptcha
|
71
|
+
else
|
72
|
+
error_message.call unless cama_captcha_verified?
|
66
73
|
end
|
67
74
|
end
|
68
75
|
end
|
@@ -16,7 +16,7 @@ class Plugins::CamaContactForm::AdminFormsController < CamaleonCms::Apps::Plugin
|
|
16
16
|
|
17
17
|
def update
|
18
18
|
if @form.update(params.require(:plugins_cama_contact_form_cama_contact_form).permit(:name, :slug))
|
19
|
-
settings = {"railscf_mail" => params[:railscf_mail], "railscf_message" => params[:railscf_message], "railscf_form_button" => params[:railscf_form_button]}
|
19
|
+
settings = {"railscf_mail" => params[:railscf_mail], "railscf_message" => params[:railscf_message], "railscf_form_button" => params[:railscf_form_button], recaptcha_site_key: params[:recaptcha_site_key], recaptcha_secret_key: params[:recaptcha_secret_key]}
|
20
20
|
fields = []
|
21
21
|
(params[:fields] || {}).each{|k, v|
|
22
22
|
v[:field_options][:options] = v[:field_options][:options].values if v[:field_options][:options].present?
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module Plugins::CamaContactForm::MainHelper
|
2
|
+
include Recaptcha::ClientHelper
|
2
3
|
def self.included(klass)
|
3
4
|
klass.helper_method [:cama_form_element_bootstrap_object, :cama_form_shortcode] rescue "" # here your methods accessible from views
|
4
5
|
end
|
@@ -109,7 +110,11 @@ module Plugins::CamaContactForm::MainHelper
|
|
109
110
|
class_type = "railscf-field-#{ob[:field_type]}" if ob[:field_type]=="email"
|
110
111
|
temp2 = "<input #{ob[:custom_attrs].to_attr_format} type=\"#{ob[:field_type]}\" value=\"#{values[cid] || ob[:default_value].to_s.translate}\" name=\"#{f_name}\" class=\"#{ob[:custom_class].presence || 'form-control'} #{class_type}\">"
|
111
112
|
when 'captcha'
|
112
|
-
|
113
|
+
if form.recaptcha_enabled?
|
114
|
+
temp2 = recaptcha_tags
|
115
|
+
else
|
116
|
+
temp2 = cama_captcha_tag(5, {}, {class: "#{ob[:custom_class].presence || 'form-control'} field-captcha required"}.merge(ob[:custom_attrs]))
|
117
|
+
end
|
113
118
|
when 'file'
|
114
119
|
temp2 = "<input multiple=\"multiple\" type=\"file\" value=\"\" name=\"#{f_name}[]\" #{ob[:custom_attrs].to_attr_format} class=\"#{ob[:custom_class].presence || 'form-control'}\">"
|
115
120
|
when 'dropdown'
|
@@ -32,6 +32,22 @@ class Plugins::CamaContactForm::CamaContactForm < ActiveRecord::Base
|
|
32
32
|
def self.field_template
|
33
33
|
"<div class='form-group'>\n\t <label>[label ci]</label>\n\t<p>[descr ci]</p>\n\t<div>[ci]</div> \n</div>"
|
34
34
|
end
|
35
|
+
|
36
|
+
# define recaptcha settings
|
37
|
+
def set_captcha_settings!
|
38
|
+
if recaptcha_enabled?
|
39
|
+
Recaptcha.configure do |config|
|
40
|
+
config.site_key = the_settings[:recaptcha_site_key]
|
41
|
+
config.secret_key = the_settings[:recaptcha_secret_key]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# verify if recaptcha was enabled for this form
|
47
|
+
# this method can be overwritten if recaptcha was already defined on initializers to return true as default
|
48
|
+
def recaptcha_enabled?
|
49
|
+
the_settings[:recaptcha_site_key].present?
|
50
|
+
end
|
35
51
|
|
36
52
|
private
|
37
53
|
def before_validating
|
@@ -84,6 +84,29 @@
|
|
84
84
|
</div>
|
85
85
|
</div>
|
86
86
|
|
87
|
+
<div class="panel panel-default">
|
88
|
+
<div class="panel-heading">
|
89
|
+
<h3 class="panel-title"><%= t('.form_recaptcha_title', default: 'Recaptcha Settings') %></h3>
|
90
|
+
<ul class="panel-controls">
|
91
|
+
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
|
92
|
+
</ul>
|
93
|
+
</div>
|
94
|
+
<div class="panel-body">
|
95
|
+
<div class="alert alert-info alert-xs" style="padding: 2px"><small><%= t('.recaptcha_info', default: 'If recaptcha settings is defined, will use recaptcha rather than classic captcha') %></small></div>
|
96
|
+
<div class="">
|
97
|
+
<div class="form-group">
|
98
|
+
<label><%= t('.recaptcha_site_key', default: 'Site Key') %>:</label><br>
|
99
|
+
<input class="form-control" type="text" name="recaptcha_site_key" value="<%= @form.the_settings[:recaptcha_site_key] rescue '' %>" />
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div class="form-group">
|
103
|
+
<label><%= t('.recaptcha_secret_key', default: 'Secret Key') %>:</label><br>
|
104
|
+
<input class="form-control" type="text" name="recaptcha_secret_key" value="<%= @form.the_settings[:recaptcha_secret_key] rescue '' %>" />
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
|
87
110
|
<div class="panel panel-default">
|
88
111
|
<div class="panel-heading">
|
89
112
|
<h3 class="panel-title"><%= t('.confirmation_email_settings', default: 'Confirmation Email Settings') %></h3>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%
|
2
2
|
@form = attributes['slug'] == '__first__' ? current_site.contact_forms.first : current_site.contact_forms.where({slug: attributes['slug']}).first
|
3
3
|
if @form.present?
|
4
|
+
@form.set_captcha_settings!
|
4
5
|
values_fields = (flash[:values].present?)? flash[:values].to_sym : {}
|
5
6
|
values = JSON.parse(@form.value).to_sym
|
6
7
|
r = {form: @form, form_class: "railscf-form railscf-form-group", before_form: @form.the_settings[:railscf_mail][:previous_html].to_s, after_form: @form.the_settings[:railscf_mail][:after_html].to_s, submit: "<div class='form-group'><button class='submit_btn btn btn-default pull-right' type='submit'>[submit_label]</button></div>"}
|
data/lib/cama_contact_form.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cama_contact_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Peredo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: recaptcha
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: sqlite3
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|