bamboolab_contact_form 0.0.19 → 0.0.20

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
  SHA1:
3
- metadata.gz: dd239654b8f106bc48d4c581cfca626d9c188bfb
4
- data.tar.gz: 772973aba23a76a0c5ef638b96a32ce9ece2391a
3
+ metadata.gz: ec934c86007472510144e7d4f4ac0823cb66f524
4
+ data.tar.gz: f6051ebfcca722a1223bf1c65df9819e70ec37da
5
5
  SHA512:
6
- metadata.gz: 0a96f13b69f2843eeb5f05f7a78b2abc736347dcbc2f3d19cb654befff525394646d037768e3084d318fe803020c9025c792cfc3f0681c26d73682fc22e22980
7
- data.tar.gz: 00f2fc99831cd6ff63223ce1d6211c770aa806065791831018aa6aa848f980ce9d484592d5e8875992c783e4280d945165c3c27872739151dd4e534f8054c2a2
6
+ metadata.gz: 0fea2a25f65a5140727a51320d56cbc85a509e462e3fac92d562afabf3ba5aeb1780472be3356f799aea27792b5fc90b02d77ed2b551dd047379d810124fa867
7
+ data.tar.gz: 1d14f731a87a1908b1e9811eb05ed730b349bcc107828df689e1b204bc97ab84ec8ac1c567e8ec07153ff29149278dfc34a9454d1abf5e218a951af77537f404
@@ -20,9 +20,14 @@ unless mailer_arg == "nil"
20
20
  mailer.last.slice!(-1)
21
21
  end
22
22
 
23
+ translation_arg = arg[3] || "[en]"
24
+ translations = translation_arg.split(", ")
25
+ translations.first.slice!(0)
26
+ translations.last.slice!(-1)
27
+
23
28
  require 'bamboolab_contact_form'
24
29
 
25
- form = Bamboolab_contact_form.new(name, fields, mailer)
30
+ form = Bamboolab_contact_form.new(name, fields, mailer, translations)
26
31
 
27
32
  if save == "destroy"
28
33
  system("rails destroy controller #{name}s")
@@ -51,9 +56,12 @@ else
51
56
  end
52
57
 
53
58
  form.helper
54
- form.view
59
+ form.view
55
60
 
56
61
  system("rails generate mailer #{name}s") unless mailer_arg=="nil"
57
62
  form.mailer unless mailer_arg=="nil"
63
+
64
+ form.translation
65
+
58
66
  form.notice
59
67
  end
@@ -1,8 +1,9 @@
1
1
  class Bamboolab_contact_form
2
- def initialize(name, fields, mailer)
2
+ def initialize(name, fields, mailer, translations)
3
3
  @name = name
4
4
  @fields = fields
5
5
  @mailer = mailer
6
+ @translations = translations
6
7
  end
7
8
 
8
9
  def model
@@ -37,6 +38,10 @@ class Bamboolab_contact_form
37
38
  create_controller_save(@name, @fields, @mailer)
38
39
  end
39
40
 
41
+ def translation
42
+ create_translation(@name, @fields, @translations)
43
+ end
44
+
40
45
  end
41
46
 
42
47
  require_relative 'create_model'
@@ -47,5 +52,4 @@ require_relative 'create_mailer'
47
52
  require_relative 'create_notice'
48
53
  require_relative 'create_model_save'
49
54
  require_relative 'create_controller_save'
50
-
51
-
55
+ require_relative 'create_translation'
data/lib/create_model.rb CHANGED
@@ -23,7 +23,7 @@ def create_model(name, fields)
23
23
  success_case << " and #{e}"
24
24
 
25
25
  emai_format_cases << " elsif !@#{name}[:#{e.slice(6..-1)}].blank? and !#{e}"
26
- emai_format_cases << " @msg = 'Format email-a ne valja! Provjerite polje \"#{e.slice(6..-1)}\".'"
26
+ emai_format_cases << " @msg = t('error_#{e.slice(6..-1)_#{name}}')"
27
27
  emai_format_cases << " @valid = false"
28
28
  end
29
29
 
@@ -40,11 +40,11 @@ def create_model(name, fields)
40
40
  #{field_emails.join("\n")}
41
41
 
42
42
  #{success_case}
43
- @msg = 'Uspješno ste poslali poruku.'
43
+ @msg = t('success_#{name}')
44
44
  @valid = true
45
45
  #{emai_format_cases.join("\n")}
46
46
  else
47
- @msg = 'Sva polja moraju biti popunjena!'
47
+ @msg = t('error_field_#{name}')
48
48
  @valid = false
49
49
  end
50
50
  end
@@ -28,7 +28,7 @@ def create_model_save(name, fields)
28
28
  success_case << " and " unless success_case == "if"
29
29
  success_case << " valid_#{email}"
30
30
  wrong_email << " elsif self.#{email}.present? and !valid_#{email}"
31
- wrong_email << " return 'Format email-a ne valja! Provjerite polje \"#{email}\".'"
31
+ wrong_email << " return t('error_#{e.slice(6..-1)_#{name}}')"
32
32
  end
33
33
 
34
34
  write_model = "class #{name.capitalize} < ApplicationRecord
@@ -39,10 +39,10 @@ def create_model_save(name, fields)
39
39
  def msg
40
40
  #{validate_email.join("\n")}
41
41
  #{success_case}
42
- return 'Uspješno ste poslali poruku.'
42
+ return t('success_#{name}')
43
43
  #{wrong_email.join("\n")}
44
44
  else
45
- return 'Sva polja moraju biti popunjena!'
45
+ return t('error_field_#{name}')
46
46
  end
47
47
  end
48
48
  end
data/lib/create_notice.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  def create_notice(name, fields, mailer)
2
2
  puts "*******************************************************************************************************"
3
- puts "---------------------------"
4
- puts "| BAMBOOLAB CONTACT FORM |"
5
- puts "---------------------------"
3
+ puts " ---------------------------"
4
+ puts " | BAMBOOLAB CONTACT FORM |"
5
+ puts " ---------------------------"
6
6
  puts ""
7
7
  puts "=> Add helper to controller where you want to use the form:"
8
8
  puts " include #{name.capitalize}sHelper"
@@ -13,26 +13,34 @@ def create_notice(name, fields, mailer)
13
13
  puts " post 'send_#{name}', to: '#{name}s#send_#{name}'"
14
14
  puts ""
15
15
 
16
+ puts "=> Because of the translations add this to your app/controllers/application_controller.rb: "
17
+ puts " def set_locale"
18
+ puts " I18n.locale = params[:locale] || I18n.default_locale"
19
+ puts " end"
20
+
16
21
  puts "=> Add this line to your views: "
17
22
  puts " <%= render '#{name}s/form' %>"
18
23
  puts ""
19
24
 
20
- puts "=> Add this code to you config/environments/development.rb and /production.rb with the right host :"
21
- puts " config.action_mailer.raise_delivery_errors = false"
22
- puts " config.action_mailer.default_url_options = { :host => 'yourhost.dev.bambooapp.eu' }"
23
- puts " config.action_mailer.delivery_method = :smtp"
24
- puts " config.action_mailer.smtp_settings = {"
25
- puts " address: ENV['SMTP_SERVER'],"
26
- puts " openssl_verify_mode: OpenSSL::SSL::VERIFY_NONE,"
27
- puts " port: ENV['SMTP_PORT'].to_i,"
28
- puts " domain: ENV['MAILER_DOMAIN'],"
29
- puts " authentication: 'plain',"
30
- puts " enable_starttls_auto: true,"
31
- puts " user_name: ENV['SMTP_USER'],"
32
- puts " password: ENV['SMTP_PWD']"
33
- puts " }"
34
- puts ""
25
+ unless mailer == "nil"
26
+ puts "=> Add this code to you config/environments/development.rb and /production.rb with the right host :"
27
+ puts " config.action_mailer.raise_delivery_errors = false"
28
+ puts " config.action_mailer.default_url_options = { :host => 'yourhost.dev.bambooapp.eu' }"
29
+ puts " config.action_mailer.delivery_method = :smtp"
30
+ puts " config.action_mailer.smtp_settings = {"
31
+ puts " address: ENV['SMTP_SERVER'],"
32
+ puts " openssl_verify_mode: OpenSSL::SSL::VERIFY_NONE,"
33
+ puts " port: ENV['SMTP_PORT'].to_i,"
34
+ puts " domain: ENV['MAILER_DOMAIN'],"
35
+ puts " authentication: 'plain',"
36
+ puts " enable_starttls_auto: true,"
37
+ puts " user_name: ENV['SMTP_USER'],"
38
+ puts " password: ENV['SMTP_PWD']"
39
+ puts " }"
40
+ puts ""
41
+
42
+ puts "=> And add your personal sendgrid information to config/environment.rb !"
43
+ end
35
44
 
36
- puts "=> And add your personal sendgrid information to config/environment.rb !"
37
45
  puts "*******************************************************************************************************"
38
46
  end
data/lib/create_view.rb CHANGED
@@ -21,7 +21,7 @@ def create_view(name, fields)
21
21
  write_view = "
22
22
  <%= form_for(@#{name}, :url => send_#{name}_path, html: {class: 'form form--contact'} ) do |f| %>
23
23
  <fieldset class='form__fieldset'>
24
- <legend class='legend'>Pošaljite poruku</legend>
24
+ <legend class='legend'>t('title_#{name}')</legend>
25
25
  </fieldset>
26
26
 
27
27
  <fieldset class='form__fieldset'>
@@ -35,7 +35,7 @@ def create_view(name, fields)
35
35
  </fieldset>
36
36
 
37
37
  <fieldset class='form__fieldset'>
38
- <%= f.submit 'Pošalji', :class => 'btn btn--full right' %>
38
+ <%= f.submit t('send_btn_#{name}'), :class => 'btn btn--full right' %>
39
39
  </fieldset>
40
40
 
41
41
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboolab_contact_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mislav Kvesić