binda 0.0.2

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.
Files changed (201) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +63 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/config/binda_manifest.js +2 -0
  6. data/app/assets/javascripts/binda/application.js +18 -0
  7. data/app/assets/javascripts/binda/components/form_item.js +54 -0
  8. data/app/assets/javascripts/binda/components/form_item_asset.js +24 -0
  9. data/app/assets/javascripts/binda/components/form_item_repeater.js +66 -0
  10. data/app/assets/javascripts/binda/components/sortable.js +44 -0
  11. data/app/assets/javascripts/binda/dist/binda.bundle.js +336 -0
  12. data/app/assets/javascripts/binda/index.js +16 -0
  13. data/app/assets/stylesheets/binda/application.css +6 -0
  14. data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -0
  15. data/app/assets/stylesheets/binda/components/button.scss +7 -0
  16. data/app/assets/stylesheets/binda/components/form_body.scss +2 -0
  17. data/app/assets/stylesheets/binda/components/form_item.scss +169 -0
  18. data/app/assets/stylesheets/binda/components/form_item_asset.scss +20 -0
  19. data/app/assets/stylesheets/binda/components/form_section.scss +40 -0
  20. data/app/assets/stylesheets/binda/components/login.scss +6 -0
  21. data/app/assets/stylesheets/binda/components/main_container.scss +0 -0
  22. data/app/assets/stylesheets/binda/components/main_content.scss +5 -0
  23. data/app/assets/stylesheets/binda/components/main_header.scss +25 -0
  24. data/app/assets/stylesheets/binda/components/main_table.scss +28 -0
  25. data/app/assets/stylesheets/binda/components/sidebar.scss +131 -0
  26. data/app/assets/stylesheets/binda/components/sortable.scss +98 -0
  27. data/app/assets/stylesheets/binda/index.scss +24 -0
  28. data/app/assets/stylesheets/binda/layout/components_index.scss +9 -0
  29. data/app/assets/stylesheets/binda/layout/dashboard.scss +7 -0
  30. data/app/assets/stylesheets/binda/layout/users_sign_in.scss +29 -0
  31. data/app/assets/stylesheets/binda/settings/common.scss +93 -0
  32. data/app/assets/stylesheets/binda/settings/fonts.scss +90 -0
  33. data/app/assets/stylesheets/binda/settings/variables.scss +83 -0
  34. data/app/assets/stylesheets/scaffolds.scss +89 -0
  35. data/app/controllers/binda/application_controller.rb +29 -0
  36. data/app/controllers/binda/assets_controller.rb +62 -0
  37. data/app/controllers/binda/bindings_controller.rb +62 -0
  38. data/app/controllers/binda/categories_controller.rb +60 -0
  39. data/app/controllers/binda/components_controller.rb +223 -0
  40. data/app/controllers/binda/dates_controller.rb +62 -0
  41. data/app/controllers/binda/field_groups_controller.rb +114 -0
  42. data/app/controllers/binda/field_settings_controller.rb +66 -0
  43. data/app/controllers/binda/galleries_controller.rb +62 -0
  44. data/app/controllers/binda/manage/users_controller.rb +97 -0
  45. data/app/controllers/binda/repeaters_controller.rb +67 -0
  46. data/app/controllers/binda/settings_controller.rb +75 -0
  47. data/app/controllers/binda/structures_controller.rb +89 -0
  48. data/app/controllers/binda/texts_controller.rb +62 -0
  49. data/app/controllers/binda/users/confirmations_controller.rb +33 -0
  50. data/app/controllers/binda/users/omniauth_callbacks_controller.rb +33 -0
  51. data/app/controllers/binda/users/passwords_controller.rb +37 -0
  52. data/app/controllers/binda/users/registrations_controller.rb +89 -0
  53. data/app/controllers/binda/users/sessions_controller.rb +30 -0
  54. data/app/controllers/binda/users/unlocks_controller.rb +33 -0
  55. data/app/helpers/binda/application_helper.rb +25 -0
  56. data/app/helpers/binda/assets_helper.rb +4 -0
  57. data/app/helpers/binda/bindings_helper.rb +4 -0
  58. data/app/helpers/binda/categories_helper.rb +10 -0
  59. data/app/helpers/binda/components_helper.rb +10 -0
  60. data/app/helpers/binda/dates_helper.rb +4 -0
  61. data/app/helpers/binda/field_groups_helper.rb +10 -0
  62. data/app/helpers/binda/field_settings_helper.rb +14 -0
  63. data/app/helpers/binda/galleries_helper.rb +4 -0
  64. data/app/helpers/binda/repeaters_helper.rb +4 -0
  65. data/app/helpers/binda/settings_helper.rb +13 -0
  66. data/app/helpers/binda/structures_helper.rb +4 -0
  67. data/app/helpers/binda/texts_helper.rb +4 -0
  68. data/app/jobs/binda/application_job.rb +4 -0
  69. data/app/mailers/binda/application_mailer.rb +6 -0
  70. data/app/models/binda/application_record.rb +5 -0
  71. data/app/models/binda/asset.rb +21 -0
  72. data/app/models/binda/binding.rb +24 -0
  73. data/app/models/binda/category.rb +31 -0
  74. data/app/models/binda/component.rb +186 -0
  75. data/app/models/binda/date.rb +9 -0
  76. data/app/models/binda/field_group.rb +40 -0
  77. data/app/models/binda/field_setting.rb +95 -0
  78. data/app/models/binda/gallery.rb +18 -0
  79. data/app/models/binda/repeater.rb +108 -0
  80. data/app/models/binda/setting.rb +42 -0
  81. data/app/models/binda/structure.rb +31 -0
  82. data/app/models/binda/text.rb +9 -0
  83. data/app/models/binda/user.rb +8 -0
  84. data/app/uploaders/binda/asset/image_uploader.rb +76 -0
  85. data/app/views/binda/assets/_form.html.erb +22 -0
  86. data/app/views/binda/assets/edit.html.erb +6 -0
  87. data/app/views/binda/assets/index.html.erb +29 -0
  88. data/app/views/binda/assets/new.html.erb +5 -0
  89. data/app/views/binda/assets/show.html.erb +19 -0
  90. data/app/views/binda/bindings/_form.html.erb +32 -0
  91. data/app/views/binda/bindings/edit.html.erb +6 -0
  92. data/app/views/binda/bindings/index.html.erb +31 -0
  93. data/app/views/binda/bindings/new.html.erb +5 -0
  94. data/app/views/binda/bindings/show.html.erb +19 -0
  95. data/app/views/binda/categories/_form.html.erb +58 -0
  96. data/app/views/binda/categories/edit.html.erb +8 -0
  97. data/app/views/binda/categories/index.html.erb +34 -0
  98. data/app/views/binda/categories/new.html.erb +8 -0
  99. data/app/views/binda/components/_form_body.html.erb +86 -0
  100. data/app/views/binda/components/_form_item_asset.html.erb +20 -0
  101. data/app/views/binda/components/_form_item_date.html.erb +16 -0
  102. data/app/views/binda/components/_form_item_gallery.html.erb +0 -0
  103. data/app/views/binda/components/_form_item_new_repeater.html.erb +33 -0
  104. data/app/views/binda/components/_form_item_repeater.html.erb +81 -0
  105. data/app/views/binda/components/_form_item_text.html.erb +28 -0
  106. data/app/views/binda/components/_form_section.html.erb +37 -0
  107. data/app/views/binda/components/_form_section_repeater.html.erb +31 -0
  108. data/app/views/binda/components/_form_sidebar.html.erb +34 -0
  109. data/app/views/binda/components/edit.html.erb +8 -0
  110. data/app/views/binda/components/index.html.erb +43 -0
  111. data/app/views/binda/components/new.html.erb +8 -0
  112. data/app/views/binda/dates/_form.html.erb +22 -0
  113. data/app/views/binda/dates/edit.html.erb +6 -0
  114. data/app/views/binda/dates/index.html.erb +27 -0
  115. data/app/views/binda/dates/new.html.erb +5 -0
  116. data/app/views/binda/dates/show.html.erb +9 -0
  117. data/app/views/binda/field_groups/_form_body.html.erb +71 -0
  118. data/app/views/binda/field_groups/_form_item.html.erb +62 -0
  119. data/app/views/binda/field_groups/_form_section.html.erb +37 -0
  120. data/app/views/binda/field_groups/_form_section_repeater.html.erb +25 -0
  121. data/app/views/binda/field_groups/edit.html.erb +8 -0
  122. data/app/views/binda/field_groups/index.html.erb +34 -0
  123. data/app/views/binda/field_groups/new.html.erb +8 -0
  124. data/app/views/binda/field_settings/_form_body.html.erb +60 -0
  125. data/app/views/binda/field_settings/edit.html.erb +8 -0
  126. data/app/views/binda/field_settings/index.html.erb +31 -0
  127. data/app/views/binda/field_settings/new.html.erb +8 -0
  128. data/app/views/binda/galleries/_form.html.erb +27 -0
  129. data/app/views/binda/galleries/edit.html.erb +6 -0
  130. data/app/views/binda/galleries/index.html.erb +29 -0
  131. data/app/views/binda/galleries/new.html.erb +5 -0
  132. data/app/views/binda/galleries/show.html.erb +14 -0
  133. data/app/views/binda/manage/users/_admin_manage_user.json.jbuilder +2 -0
  134. data/app/views/binda/manage/users/_form_body.html.erb +58 -0
  135. data/app/views/binda/manage/users/edit.html.erb +8 -0
  136. data/app/views/binda/manage/users/index.html.erb +38 -0
  137. data/app/views/binda/manage/users/index.json.jbuilder +1 -0
  138. data/app/views/binda/manage/users/new.html.erb +8 -0
  139. data/app/views/binda/manage/users/show.json.jbuilder +1 -0
  140. data/app/views/binda/repeaters/_form.html.erb +27 -0
  141. data/app/views/binda/repeaters/edit.html.erb +6 -0
  142. data/app/views/binda/repeaters/index.html.erb +29 -0
  143. data/app/views/binda/repeaters/new.html.erb +5 -0
  144. data/app/views/binda/repeaters/show.html.erb +14 -0
  145. data/app/views/binda/settings/_dashboard_form.html.erb +51 -0
  146. data/app/views/binda/settings/_form.html.erb +52 -0
  147. data/app/views/binda/settings/dashboard.html.erb +9 -0
  148. data/app/views/binda/settings/edit.html.erb +8 -0
  149. data/app/views/binda/settings/index.html.erb +34 -0
  150. data/app/views/binda/settings/new.html.erb +8 -0
  151. data/app/views/binda/structures/_form_body.html.erb +56 -0
  152. data/app/views/binda/structures/_form_section.html.erb +64 -0
  153. data/app/views/binda/structures/add_child.html.erb +0 -0
  154. data/app/views/binda/structures/edit.html.erb +8 -0
  155. data/app/views/binda/structures/index.html.erb +34 -0
  156. data/app/views/binda/structures/new.html.erb +8 -0
  157. data/app/views/binda/texts/_form.html.erb +22 -0
  158. data/app/views/binda/texts/edit.html.erb +6 -0
  159. data/app/views/binda/texts/index.html.erb +27 -0
  160. data/app/views/binda/texts/new.html.erb +5 -0
  161. data/app/views/binda/texts/show.html.erb +9 -0
  162. data/app/views/layouts/binda/_flash.html.erb +26 -0
  163. data/app/views/layouts/binda/_header.html.erb +9 -0
  164. data/app/views/layouts/binda/_sidebar.html.erb +50 -0
  165. data/app/views/layouts/binda/application.html.erb +29 -0
  166. data/app/views/users/confirmations/new.html.erb +16 -0
  167. data/app/views/users/mailer/confirmation_instructions.html.erb +5 -0
  168. data/app/views/users/mailer/password_change.html.erb +3 -0
  169. data/app/views/users/mailer/reset_password_instructions.html.erb +8 -0
  170. data/app/views/users/mailer/unlock_instructions.html.erb +7 -0
  171. data/app/views/users/passwords/edit.html.erb +31 -0
  172. data/app/views/users/passwords/new.html.erb +28 -0
  173. data/app/views/users/registrations/edit.html.erb +27 -0
  174. data/app/views/users/registrations/new.html.erb +17 -0
  175. data/app/views/users/sessions/new.html.erb +27 -0
  176. data/app/views/users/shared/_links.html.erb +25 -0
  177. data/app/views/users/unlocks/new.html.erb +16 -0
  178. data/config/initializers/assets.rb +3 -0
  179. data/config/initializers/devise.rb +278 -0
  180. data/config/initializers/devise_patch.rb +50 -0
  181. data/config/initializers/friendly_id.rb +88 -0
  182. data/config/initializers/simple_form.rb +165 -0
  183. data/config/initializers/simple_form_bootstrap.rb +149 -0
  184. data/config/locales/devise.en.yml +62 -0
  185. data/config/locales/en.yml +37 -0
  186. data/config/locales/simple_form.en.yml +31 -0
  187. data/config/routes.rb +67 -0
  188. data/config/tinymce.yml +15 -0
  189. data/db/migrate/1_create_binda_tables.rb +172 -0
  190. data/lib/binda.rb +5 -0
  191. data/lib/binda/engine.rb +30 -0
  192. data/lib/binda/version.rb +3 -0
  193. data/lib/generators/binda/install/USAGE +9 -0
  194. data/lib/generators/binda/install/install_generator.rb +107 -0
  195. data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +32 -0
  196. data/lib/generators/binda/install/templates/config/initializers/devise.rb +280 -0
  197. data/lib/generators/binda/setup/USAGE +8 -0
  198. data/lib/generators/binda/setup/setup_generator.rb +43 -0
  199. data/lib/tasks/binda.rake +25 -0
  200. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  201. metadata +637 -0
@@ -0,0 +1,107 @@
1
+ require 'colorize'
2
+ require 'securerandom'
3
+
4
+ module Binda
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def check_previous_install
9
+ # Ensure Binda is not installed
10
+ if Component.table_exists?
11
+ puts "Binda has already been installed on this database.".colorize(:red)
12
+ puts "Please ensure Binda is completely removed from the database before trying to install it again.".colorize(:red)
13
+ exit
14
+ end
15
+ end
16
+
17
+ def add_route
18
+ return if Rails.env.production?
19
+ return if Rails.application.routes.routes.detect { |route| route.app.app == Binda::Engine }
20
+ route "mount Binda::Engine => '/admin_panel'"
21
+ end
22
+
23
+ def copy_migrations
24
+ return if Rails.env.production?
25
+
26
+ # Check if there is any previous Binda migration
27
+ previous_binda_migrations = Dir.glob( Rails.root.join('db', 'migrate', '*.binda.rb' ))
28
+ previous_migrations = Dir.glob( Rails.root.join('db', 'migrate', '*.rb' ))
29
+
30
+ # If it's the first time you run the installation
31
+ unless previous_binda_migrations.any?
32
+ rake 'binda:install:migrations'
33
+ else
34
+ # If there is any previous Binda migration
35
+ if previous_migrations.size != previous_binda_migrations.size
36
+ puts "You have several migrations, please manually delete Binda's ones then run 'rails g binda:install' again.".colorize(:red)
37
+ puts "Keep in mind that Binda will place the new migration after the existing ones.".colorize(:red)
38
+ exit
39
+ else
40
+ # Remove previous Binda migrations
41
+ FileUtils.rm_rf( previous_binda_migrations )
42
+ # Install Binda migrations
43
+ rake 'binda:install:migrations'
44
+ end
45
+ end
46
+ end
47
+
48
+ def run_migrations
49
+ rake 'db:migrate'
50
+ end
51
+
52
+ def setup_devise
53
+ return if Rails.env.production?
54
+ return if Dir.glob( Rails.root.join('config', 'initializers', 'devise.rb' )).any?
55
+
56
+ # Copy the initilializer on the application folder
57
+ template 'config/initializers/devise.rb'
58
+
59
+ # Add secret key
60
+ inject_into_file 'config/initializers/devise.rb', after: "# binda.hook.1" do
61
+ "\n config.secret_key = '#{ SecureRandom.hex(64) }'"
62
+ end
63
+ # Add pepper
64
+ inject_into_file 'config/initializers/devise.rb', after: "# binda.hook.2" do
65
+ "\n config.pepper = '#{ SecureRandom.hex(64) }'"
66
+ end
67
+
68
+ application( nil, env: [ "development", "test" ] ) do
69
+ "\n config.action_mailer.default_url_options = { host: 'localhost:3000' }\n config.action_mailer.raise_delivery_errors = true\n"
70
+ end
71
+ application( nil, env: "production" ) do
72
+ "\n # PLEASE UPDATE THIS WITH THE FINAL URL OF YOUR DOMAIN\n # config.action_mailer.default_url_options = { host: 'yourdomain.com' }\n # config.action_mailer.delivery_method = :smtp\n # config.action_mailer.perform_deliveries = true\n # config.action_mailer.raise_delivery_errors = false\n # config.action_mailer.default :charset => 'utf-8'\n # config.action_mailer.smtp_settings = {\n # address: 'smtp.gmail.com',\n # port: 587,\n # domain: ENV['MAIL_DOMAIN'],\n # authentication: 'plain',\n # enable_starttls_auto: true,\n # user_name: ENV['MAIL_USERNAME'],\n # password: ENV['MAIL_PASSWORD']\n # }"
73
+
74
+ # which returns the snippet below:
75
+ #
76
+ # # PLEASE UPDATE THIS WITH THE FINAL URL OF YOUR DOMAIN
77
+ # # for setup see https://rubyonrailshelp.wordpress.com/2014/01/02/setting-up-mailer-using-devise-for-forgot-password/
78
+ # config.action_mailer.default_url_options = { host: 'yourdomain.com' }
79
+ # config.action_mailer.delivery_method = :smtp
80
+ # config.action_mailer.perform_deliveries = true
81
+ # config.action_mailer.raise_delivery_errors = false
82
+ # config.action_mailer.default :charset => 'utf-8'
83
+ # config.action_mailer.smtp_settings = {
84
+ # address: 'smtp.gmail.com',
85
+ # port: 587,
86
+ # domain: ENV['MAIL_DOMAIN'],
87
+ # authentication: 'plain',
88
+ # enable_starttls_auto: true,
89
+ # user_name: ENV['MAIL_USERNAME'],
90
+ # password: ENV['MAIL_PASSWORD']
91
+ # }
92
+ end
93
+ end
94
+
95
+ def setup_carrierwave
96
+ return if Rails.env.production?
97
+ return if Dir.glob( Rails.root.join('config', 'initializers', 'carrierwave.rb' )).any?
98
+
99
+ template 'config/initializers/carrierwave.rb'
100
+ end
101
+
102
+ def setup_settings
103
+ exec 'rails g binda:setup'
104
+ end
105
+
106
+ end
107
+ end
@@ -0,0 +1,32 @@
1
+ CarrierWave.configure do |config|
2
+ config.storage = :file
3
+
4
+ # # Use Google if you want
5
+ # config.fog_provider = 'fog/google' # required
6
+ # config.fog_credentials = {
7
+ # provider: 'Google',
8
+ # google_project: '',
9
+ # google_client_email: '',
10
+ # google_json_key_location: ''
11
+ # }
12
+ # # config.storage must go after config.fog_credentials
13
+ # # https://github.com/carrierwaveuploader/carrierwave/issues/2023#issuecomment-252407542
14
+ # config.storage = :fog
15
+ # config.fog_directory = ''
16
+
17
+ # # Use S3 if you want
18
+ # config.fog_credentials = {
19
+ # provider: 'AWS',
20
+ # region: '',
21
+ # aws_access_key_id: '',
22
+ # aws_secret_access_key: ''
23
+ # }
24
+ # # config.storage must go after config.fog_credentials
25
+ # # https://github.com/carrierwaveuploader/carrierwave/issues/2023#issuecomment-252407542
26
+ # config.storage = :fog
27
+ # config.fog_directory = ''
28
+ # config.fog_public = true
29
+ # config.fog_attributes = { 'Cache-Control' => 'max-age=315576000' }
30
+
31
+ config.enable_processing = !Rails.env.test?
32
+ end
@@ -0,0 +1,280 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+
5
+ # https://github.com/plataformatec/devise/wiki/How-To:-Use-devise-inside-a-mountable-engine
6
+ # You probably want Devise's controllers to inherit from
7
+ # your engine's controller and not the main controller.
8
+ # ============== DON'T CHANGE IT ===============
9
+ config.parent_controller = 'Binda::ApplicationController'
10
+ # ============== =============== ===============
11
+
12
+ # The secret key used by Devise. Devise uses this key to generate
13
+ # random tokens. Changing this key will render invalid all existing
14
+ # confirmation, reset password and unlock tokens in the database.
15
+ # Devise will use the `secret_key_base` as its `secret_key`
16
+ # by default. You can change it below and use your own secret key.
17
+ # config.secret_key = 'a8395fa034e067da620d70f7f39ad4765d163e44ce05d5c243393e1bbfdc10f9a464aaf34fcac3291a6746424ea2b9f9564a01c31820e28bf1737c16d139cd5c'
18
+ # binda.hook.1
19
+
20
+ # ==> Mailer Configuration
21
+ # Configure the e-mail address which will be shown in Devise::Mailer,
22
+ # note that it will be overwritten if you use your own mailer class
23
+ # with default "from" parameter.
24
+ # config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
25
+
26
+ # Configure the class responsible to send e-mails.
27
+ # config.mailer = 'Devise::Mailer'
28
+
29
+ # Configure the parent class responsible to send e-mails.
30
+ # config.parent_mailer = 'ActionMailer::Base'
31
+
32
+ # ==> ORM configuration
33
+ # Load and configure the ORM. Supports :active_record (default) and
34
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
35
+ # available as additional gems.
36
+ require 'devise/orm/active_record'
37
+
38
+ # ==> Configuration for any authentication mechanism
39
+ # Configure which keys are used when authenticating a user. The default is
40
+ # just :email. You can configure it to use [:username, :subdomain], so for
41
+ # authenticating a user, both parameters are required. Remember that those
42
+ # parameters are used only when authenticating and not when retrieving from
43
+ # session. If you need permissions, you should implement that in a before filter.
44
+ # You can also supply a hash where the value is a boolean determining whether
45
+ # or not authentication should be aborted when the value is not present.
46
+ # config.authentication_keys = [:email]
47
+
48
+ # Configure parameters from the request object used for authentication. Each entry
49
+ # given should be a request method and it will automatically be passed to the
50
+ # find_for_authentication method and considered in your model lookup. For instance,
51
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
52
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
53
+ # config.request_keys = []
54
+
55
+ # Configure which authentication keys should be case-insensitive.
56
+ # These keys will be downcased upon creating or modifying a user and when used
57
+ # to authenticate or find a user. Default is :email.
58
+ config.case_insensitive_keys = [:email]
59
+
60
+ # Configure which authentication keys should have whitespace stripped.
61
+ # These keys will have whitespace before and after removed upon creating or
62
+ # modifying a user and when used to authenticate or find a user. Default is :email.
63
+ config.strip_whitespace_keys = [:email]
64
+
65
+ # Tell if authentication through request.params is enabled. True by default.
66
+ # It can be set to an array that will enable params authentication only for the
67
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
68
+ # enable it only for database (email + password) authentication.
69
+ # config.params_authenticatable = true
70
+
71
+ # Tell if authentication through HTTP Auth is enabled. False by default.
72
+ # It can be set to an array that will enable http authentication only for the
73
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
74
+ # enable it only for database authentication. The supported strategies are:
75
+ # :database = Support basic authentication with authentication key + password
76
+ # config.http_authenticatable = false
77
+
78
+ # If 401 status code should be returned for AJAX requests. True by default.
79
+ # config.http_authenticatable_on_xhr = true
80
+
81
+ # The realm used in Http Basic Authentication. 'Application' by default.
82
+ # config.http_authentication_realm = 'Application'
83
+
84
+ # It will change confirmation, password recovery and other workflows
85
+ # to behave the same regardless if the e-mail provided was right or wrong.
86
+ # Does not affect registerable.
87
+ # config.paranoid = true
88
+
89
+ # By default Devise will store the user in session. You can skip storage for
90
+ # particular strategies by setting this option.
91
+ # Notice that if you are skipping storage for all authentication paths, you
92
+ # may want to disable generating routes to Devise's sessions controller by
93
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
94
+ config.skip_session_storage = [:http_auth]
95
+
96
+ # By default, Devise cleans up the CSRF token on authentication to
97
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
98
+ # requests for sign in and sign up, you need to get a new CSRF token
99
+ # from the server. You can disable this option at your own risk.
100
+ # config.clean_up_csrf_token_on_authentication = true
101
+
102
+ # ==> Configuration for :database_authenticatable
103
+ # For bcrypt, this is the cost for hashing the password and defaults to 11. If
104
+ # using other algorithms, it sets how many times you want the password to be hashed.
105
+ #
106
+ # Limiting the stretches to just one in testing will increase the performance of
107
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
108
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
109
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
110
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
111
+ config.stretches = Rails.env.test? ? 1 : 11
112
+
113
+ # Set up a pepper to generate the hashed password.
114
+ # config.pepper = '124ef1b08a92f891a392a9594b868887c945ca8438bd7852f8ac4d91e51f2cc699b8b6c7b12057c0f0e6dc03d04f8ee4eab72278b0f948e2c1e43f8b449c2262'
115
+ # binda.hook.2
116
+
117
+ # Send a notification email when the user's password is changed
118
+ # config.send_password_change_notification = false
119
+
120
+ # ==> Configuration for :confirmable
121
+ # A period that the user is allowed to access the website even without
122
+ # confirming their account. For instance, if set to 2.days, the user will be
123
+ # able to access the website for two days without confirming their account,
124
+ # access will be blocked just in the third day. Default is 0.days, meaning
125
+ # the user cannot access the website without confirming their account.
126
+ # config.allow_unconfirmed_access_for = 2.days
127
+
128
+ # A period that the user is allowed to confirm their account before their
129
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
130
+ # their account within 3 days after the mail was sent, but on the fourth day
131
+ # their account can't be confirmed with the token any more.
132
+ # Default is nil, meaning there is no restriction on how long a user can take
133
+ # before confirming their account.
134
+ # config.confirm_within = 3.days
135
+
136
+ # If true, requires any email changes to be confirmed (exactly the same way as
137
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
138
+ # db field (see migrations). Until confirmed, new email is stored in
139
+ # unconfirmed_email column, and copied to email column on successful confirmation.
140
+ config.reconfirmable = true
141
+
142
+ # Defines which key will be used when confirming an account
143
+ # config.confirmation_keys = [:email]
144
+
145
+ # ==> Configuration for :rememberable
146
+ # The time the user will be remembered without asking for credentials again.
147
+ # config.remember_for = 2.weeks
148
+
149
+ # Invalidates all the remember me tokens when the user signs out.
150
+ config.expire_all_remember_me_on_sign_out = true
151
+
152
+ # If true, extends the user's remember period when remembered via cookie.
153
+ # config.extend_remember_period = false
154
+
155
+ # Options to be passed to the created cookie. For instance, you can set
156
+ # secure: true in order to force SSL only cookies.
157
+ # config.rememberable_options = {}
158
+
159
+ # ==> Configuration for :validatable
160
+ # Range for password length.
161
+ config.password_length = 8..128
162
+
163
+ # Email regex used to validate email formats. It simply asserts that
164
+ # one (and only one) @ exists in the given string. This is mainly
165
+ # to give user feedback and not to assert the e-mail validity.
166
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
167
+
168
+ # ==> Configuration for :timeoutable
169
+ # The time you want to timeout the user session without activity. After this
170
+ # time the user will be asked for credentials again. Default is 30 minutes.
171
+ # config.timeout_in = 30.minutes
172
+
173
+ # ==> Configuration for :lockable
174
+ # Defines which strategy will be used to lock an account.
175
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
176
+ # :none = No lock strategy. You should handle locking by yourself.
177
+ # config.lock_strategy = :failed_attempts
178
+
179
+ # Defines which key will be used when locking and unlocking an account
180
+ # config.unlock_keys = [:email]
181
+
182
+ # Defines which strategy will be used to unlock an account.
183
+ # :email = Sends an unlock link to the user email
184
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
185
+ # :both = Enables both strategies
186
+ # :none = No unlock strategy. You should handle unlocking by yourself.
187
+ # config.unlock_strategy = :both
188
+
189
+ # Number of authentication tries before locking an account if lock_strategy
190
+ # is failed attempts.
191
+ # config.maximum_attempts = 20
192
+
193
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
194
+ # config.unlock_in = 1.hour
195
+
196
+ # Warn on the last attempt before the account is locked.
197
+ # config.last_attempt_warning = true
198
+
199
+ # ==> Configuration for :recoverable
200
+ #
201
+ # Defines which key will be used when recovering the password for an account
202
+ # config.reset_password_keys = [:email]
203
+
204
+ # Time interval you can reset your password with a reset password key.
205
+ # Don't put a too small interval or your users won't have the time to
206
+ # change their passwords.
207
+ config.reset_password_within = 6.hours
208
+
209
+ # When set to false, does not sign a user in automatically after their password is
210
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
211
+ # config.sign_in_after_reset_password = true
212
+
213
+ # ==> Configuration for :encryptable
214
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
215
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
216
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
217
+ # for default behavior) and :restful_authentication_sha1 (then you should set
218
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
219
+ #
220
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
221
+ # config.encryptor = :sha512
222
+
223
+ # ==> Scopes configuration
224
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
225
+ # "users/sessions/new". It's turned off by default because it's slower if you
226
+ # are using only default views.
227
+ # config.scoped_views = false
228
+
229
+ # Configure the default scope given to Warden. By default it's the first
230
+ # devise role declared in your routes (usually :user).
231
+ # config.default_scope = :user
232
+
233
+ # Set this configuration to false if you want /users/sign_out to sign out
234
+ # only the current scope. By default, Devise signs out all scopes.
235
+ # config.sign_out_all_scopes = true
236
+
237
+ # ==> Navigation configuration
238
+ # Lists the formats that should be treated as navigational. Formats like
239
+ # :html, should redirect to the sign in page when the user does not have
240
+ # access, but formats like :xml or :json, should return 401.
241
+ #
242
+ # If you have any extra navigational formats, like :iphone or :mobile, you
243
+ # should add them to the navigational formats lists.
244
+ #
245
+ # The "*/*" below is required to match Internet Explorer requests.
246
+ # config.navigational_formats = ['*/*', :html]
247
+
248
+ # The default HTTP method used to sign out a resource. Default is :delete.
249
+ config.sign_out_via = :delete
250
+
251
+ # ==> OmniAuth
252
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
253
+ # up on your models and hooks.
254
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
255
+
256
+ # ==> Warden configuration
257
+ # If you want to use other strategies, that are not supported by Devise, or
258
+ # change the failure app, you can configure them inside the config.warden block.
259
+ #
260
+ # config.warden do |manager|
261
+ # manager.intercept_401 = false
262
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
263
+ # end
264
+
265
+ # ==> Mountable engine configurations
266
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
267
+ # is mountable, there are some extra configurations to be taken into account.
268
+ # The following options are available, assuming the engine is mounted as:
269
+ #
270
+ # mount MyEngine, at: '/my_engine'
271
+ #
272
+ # The router that invoked `devise_for`, in the example above, would be:
273
+ # ============== DON'T CHANGE IT ===============
274
+ config.router_name = :binda
275
+ # ============== =============== ===============
276
+
277
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
278
+ # so you need to do it manually. For the users scope, it would be:
279
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
280
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate binda:setup
6
+
7
+ This will populate the database with initial settings.
8
+
@@ -0,0 +1,43 @@
1
+ require 'colorize'
2
+ require 'securerandom'
3
+
4
+ module Binda
5
+ class SetupGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def setup_settings
9
+ puts
10
+ puts "============================================================================="
11
+ puts " BINDA SETUP"
12
+ puts "============================================================================="
13
+ puts
14
+ puts "We need few details. Don't worry you can modify them later. \n\n"
15
+
16
+ # MAINTENANCE MODE
17
+ Setting.find_or_create_by( name: 'Maintenance Mode' )
18
+
19
+ # WEBSITE NAME
20
+ @website_name = ask("What would you like to name your website? ['MySite']\n").presence || 'MySite'
21
+ Setting.find_or_create_by( name: 'Website Name' ).update_attribute( :content, @website_name )
22
+
23
+ # WEBSITE CONTENT
24
+ @website_description = ask("What is it about? ['A website about the world']\n").presence || 'A website about the world'
25
+ Setting.find_or_create_by( name: 'Website Description' ).update_attribute( :content, @website_description )
26
+ end
27
+
28
+ def create_credentials
29
+ rake 'binda_create_initial_user'
30
+ end
31
+
32
+ def feedback
33
+ puts
34
+ puts "Binda CMS has been succesfully installed! ".colorize(:green)
35
+ puts
36
+ puts "Before deploying to production, remember to uncomment and update the"
37
+ puts "'config.action_mailer.default_url_options' in 'config/environments/production.rb'"
38
+ puts
39
+ puts "============================================================================="
40
+ end
41
+
42
+ end
43
+ end