cybele 1.6.0 → 1.7.0

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +155 -121
  5. data/MIT-LICENSE +2 -2
  6. data/README.md +12 -6
  7. data/cybele.gemspec +17 -15
  8. data/lib/cybele/app_builder.rb +86 -28
  9. data/lib/cybele/generators/app_generator.rb +29 -3
  10. data/lib/cybele/version.rb +4 -3
  11. data/templates/app/controllers/hq/admin_profiles_controller.rb +10 -2
  12. data/templates/app/controllers/hq/sessions_controller.rb +13 -0
  13. data/templates/app/controllers/user_profiles_controller.rb +10 -2
  14. data/templates/app/views/devise/mailer/reset_password_instructions.html.haml +8 -5
  15. data/templates/app/views/devise/passwords/edit.html.haml +5 -5
  16. data/templates/app/views/devise/passwords/new.html.haml +4 -3
  17. data/templates/app/views/devise/registrations/edit.html.haml +5 -5
  18. data/templates/app/views/devise/registrations/new.html.haml +3 -2
  19. data/templates/app/views/devise/sessions/new.html.haml +7 -6
  20. data/templates/app/views/devise/shared/_links.haml +9 -8
  21. data/templates/app/views/hq/sessions/new.html.haml +4 -3
  22. data/templates/app/views/layouts/application.html.haml.erb +1 -0
  23. data/templates/config/database.yml.erb +9 -1
  24. data/templates/config/deploy.rb +56 -0
  25. data/templates/config/locales/en.yml +2 -0
  26. data/templates/config/locales/models.en.yml +54 -0
  27. data/templates/config/locales/models.tr.yml +56 -0
  28. data/templates/config/locales/responders.tr.yml +1 -0
  29. data/templates/config/locales/show_for.en.yml +7 -0
  30. data/templates/config/locales/show_for.tr.yml +8 -0
  31. data/templates/config/locales/simple_form.en.yml +30 -0
  32. data/templates/config/locales/simple_form.tr.yml +6 -1
  33. data/templates/config/locales/tr.yml +1 -31
  34. data/templates/config/locales/view.en.yml +51 -0
  35. data/templates/config/locales/view.tr.yml +52 -0
  36. data/templates/config/settings.yml +0 -0
  37. data/templates/cybele_Gemfile +47 -43
  38. data/templates/ruby-version +1 -1
  39. metadata +17 -7
  40. data/Gemfile.lock +0 -92
@@ -1,26 +1,28 @@
1
- # coding: utf-8
1
+ # encoding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require File.expand_path('../lib/cybele/version', __FILE__)
5
+ require 'date'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = 'cybele'
8
- spec.version = Cybele::VERSION
9
- spec.authors = %w[lab2023]
10
- spec.email = %w[info@lab2023.com]
11
- spec.description = %q{Rails 4.x template with responder, simple form, haml, exception notification, etc etc ...}
12
- spec.summary = %q{Rails 4.x template with responder, simple form, haml, exception notification, etc etc ...}
13
- spec.homepage = 'https://github.com/kebab-project/cybele'
14
- spec.license = 'MIT'
8
+ spec.name = 'cybele'
9
+ spec.version = Cybele::VERSION
10
+ spec.authors = %w[lab2023]
11
+ spec.email = %w[info@lab2023.com]
12
+ spec.description = %q{Rails 4.x template with responder, simple form, haml, exception notification, etc etc ...}
13
+ spec.summary = %q{Rails 4.x template with responder, simple form, haml, exception notification, etc etc ...}
14
+ spec.homepage = 'https://github.com/kebab-project/cybele'
15
+ spec.license = 'MIT'
16
+ spec.date = Date.today.strftime('%Y-%m-%d')
15
17
 
16
- spec.required_ruby_version = '>= 2.0.0'
18
+ spec.required_ruby_version = ">= #{Cybele::RUBY_VERSION}"
17
19
  spec.add_dependency 'bundler', '~> 1.5'
18
- spec.add_dependency 'rails', '~> 4.0'
20
+ spec.add_dependency 'rails', Cybele::RAILS_VERSION
19
21
 
20
- spec.files = `git ls-files`.split($/)
21
- spec.executables = %w[cybele]
22
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
- spec.require_paths = %w[lib]
22
+ spec.files = `git ls-files`.split($/)
23
+ spec.executables = %w[cybele]
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths= %w[lib]
24
26
 
25
27
  spec.add_development_dependency 'rake'
26
28
 
@@ -81,7 +81,7 @@ module Cybele
81
81
 
82
82
  config = <<-RUBY
83
83
 
84
-
84
+ config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
85
85
  config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
86
86
  config.sass.preferred_syntax = :sass
87
87
  RUBY
@@ -106,8 +106,15 @@ module Cybele
106
106
 
107
107
  config = <<-RUBY
108
108
  config.action_mailer.delivery_method = :smtp
109
- config.action_mailer.raise_delivery_errors = false
110
- config.action_mailer.smtp_settings = Settings.smtp.mandrill
109
+ config.action_mailer.raise_delivery_errors = false
110
+ config.action_mailer.smtp_settings = {
111
+ address: Settings.smtp.mandrill.address,
112
+ port: Settings.smtp.mandrill.port,
113
+ enable_starttls_auto: Settings.smtp.mandrill.enable_starttls_auto,
114
+ user_name: Settings.smtp.mandrill.user_name,
115
+ password: Settings.smtp.mandrill.password,
116
+ authentication: Settings.smtp.mandrill.authentication
117
+ }
111
118
  RUBY
112
119
 
113
120
  configure_environment 'production', config
@@ -121,7 +128,7 @@ config.after_initialize do
121
128
  Bullet.alert = true
122
129
  Bullet.bullet_logger = true
123
130
  end
124
- RUBY
131
+ RUBY
125
132
 
126
133
  configure_environment 'development', config
127
134
  end
@@ -134,14 +141,14 @@ config.after_initialize do
134
141
 
135
142
  config = <<-YML
136
143
  email:
137
- noreply: noreply@appname.org
144
+ noreply: no-reply@#{app_name}.com
138
145
  YML
139
146
  prepend_file 'config/settings.yml', config
140
147
  end
141
148
 
142
149
  def configure_action_mailer
143
- action_mailer_host 'development', "#{app_name}.dev"
144
- action_mailer_host 'test', "#{app_name}.com"
150
+ action_mailer_host 'development', "localhost:3000"
151
+ action_mailer_host 'staging', "staging.#{app_name}.com"
145
152
  action_mailer_host 'production', "#{app_name}.com"
146
153
  end
147
154
 
@@ -180,7 +187,7 @@ require 'capybara/rspec'
180
187
  end
181
188
 
182
189
  def generate_simple_form
183
- generate 'simple_form:install --bootstrap'
190
+ generate 'simple_form:install --bootstrap --force'
184
191
  copy_file 'config/locales/simple_form.tr.yml', 'config/locales/simple_form.tr.yml'
185
192
  copy_file 'config/locales/tr.yml', 'config/locales/tr.yml'
186
193
  end
@@ -191,12 +198,12 @@ require 'capybara/rspec'
191
198
 
192
199
  def add_exception_notification_to_environments
193
200
  config = <<-CODE
194
- config.middleware.use ExceptionNotification::Rack,
195
- :email => {
196
- :email_prefix => "[Whatever] ",
197
- :sender_address => %{"notifier" <notifier@example.com>},
198
- :exception_recipients => %w{exceptions@example.com}
199
- }
201
+ config.middleware.use ExceptionNotification::Rack,
202
+ :email => {
203
+ :email_prefix => "[#{app_name}]",
204
+ :sender_address => %{"Notifier" <notifier@#{app_name}.com>},
205
+ :exception_recipients => %w{your_email@address.com}
206
+ }
200
207
  CODE
201
208
 
202
209
  configure_environment('production', config)
@@ -224,7 +231,7 @@ require 'capybara/rspec'
224
231
  def generate_devise_settings
225
232
  generate 'devise:install'
226
233
  gsub_file 'config/initializers/filter_parameter_logging.rb', /:password/, ':password, :password_confirmation'
227
- gsub_file 'config/initializers/devise.rb', /please-change-me-at-config-initializers-devise@example.com/, 'CHANGEME@example.com'
234
+ gsub_file 'config/initializers/devise.rb', /please-change-me-at-config-initializers-devise@example.com/, "no-reply@#{app_name}.com"
228
235
  end
229
236
 
230
237
  def generate_devise_model(model_name)
@@ -254,7 +261,7 @@ require 'capybara/rspec'
254
261
  path_names: {sign_in: 'login', sign_out: 'logout', password: 'secret',
255
262
  confirmation: 'verification'}"
256
263
  gsub_file 'app/models/admin.rb', /:registerable,/, ''
257
-
264
+
258
265
  say 'Configuring profile editors...'
259
266
  setup_profile_editors
260
267
  end
@@ -264,14 +271,14 @@ require 'capybara/rspec'
264
271
  inject_into_file 'config/routes.rb', :after => "namespace :hq do\n" do <<-RUBY
265
272
  root to: 'dashboard#index'
266
273
  resource :admin_profile, except: [:destroy], path: 'profile'
267
- RUBY
274
+ RUBY
268
275
  end
269
276
 
270
- inject_into_file 'config/routes.rb', :after => "'welcome#index'\n" do <<-RUBY
277
+ inject_into_file 'config/routes.rb', :after => "to: 'welcome#index'\n" do <<-RUBY
271
278
 
272
- resource :user_profile, except: [:destroy], path: 'profile'
279
+ resource :user_profile, except: [:destroy], path: 'profile'
273
280
 
274
- RUBY
281
+ RUBY
275
282
  end
276
283
  end
277
284
 
@@ -299,13 +306,42 @@ require 'capybara/rspec'
299
306
  copy_file 'config/initializers/simple_form.rb', 'config/initializers/simple_form.rb'
300
307
  copy_file 'config/initializers/simple_form_bootstrap.rb', 'config/initializers/simple_form_bootstrap.rb'
301
308
  end
302
-
309
+
303
310
  def setup_capistrano
304
- run 'capify .'
311
+ run 'bundle exec cap install'
305
312
  end
306
313
 
307
- def setup_recipes
314
+ def setup_capistrano_settings
308
315
  run 'rm config/deploy.rb'
316
+ # Copy teplates/config/deploy.rb to app directory
317
+ copy_file 'config/deploy.rb', 'config/deploy.rb'
318
+ # Change my_app_name string in the deploy.rb file with app_name that is created
319
+ gsub_file 'config/deploy.rb', /my_app_name/, "#{app_name}"
320
+
321
+ inject_into_file 'Capfile', :after => "require 'capistrano/deploy'\n" do <<-RUBY
322
+ require 'capistrano/rails'
323
+ require 'capistrano/bundler'
324
+ require 'sshkit/sudo'
325
+ require 'capistrano/maintenance'
326
+ RUBY
327
+ end
328
+
329
+ append_to_file 'config/deploy/production.rb' do
330
+ 'server "example.com", user: "#{fetch(:local_user)}", roles: %w{app db web}, primary: true, port: 22
331
+ set :rails_env, "production"
332
+ set :branch, "master"
333
+ set :project_domain, "example.com"'
334
+ end
335
+ append_to_file 'config/deploy/staging.rb' do
336
+ 'server "staging.example.com", user: "#{fetch(:local_user)}", roles: %w{app db web}, primary: true, port: 22
337
+ set :rails_env, "staging"
338
+ set :branch, "develop"
339
+ set :project_domain, "staging.example.com"'
340
+ end
341
+ end
342
+
343
+ # Nor using
344
+ def setup_recipes
309
345
  generate 'recipes_matic:install'
310
346
  end
311
347
 
@@ -326,9 +362,9 @@ require 'capybara/rspec'
326
362
  copy_file 'app/views/errors/internal_server_error.html.haml', 'app/views/errors/internal_server_error.html.haml'
327
363
  inject_into_file 'app/controllers/application_controller.rb', :before => 'protected' do <<-CODE
328
364
 
329
- rescue_from Exception, :with => :server_error
365
+ # rescue_from Exception, :with => :server_error
330
366
  def server_error(exception)
331
- ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
367
+ # ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
332
368
  respond_to do |format|
333
369
  format.html { render template: 'errors/internal_server_error', layout: 'layouts/application', status: 500 }
334
370
  format.all { render nothing: true, status: 500}
@@ -354,6 +390,30 @@ require 'capybara/rspec'
354
390
  end
355
391
  end
356
392
 
393
+ # Add default admin user and admin profile seeder
394
+ def add_seeds
395
+ say 'Add seeds'
396
+ inject_into_file 'db/seeds.rb', :after => "# Mayor.create(name: 'Emanuel', city: cities.first)\n" do <<-RUBY
397
+
398
+ admin = Admin.create(email: "admin@#{app_name}.com", password: '12341234', password_confirmation: '12341234')
399
+ admin.admin_profile = AdminProfile.create(first_name: 'Admin', last_name: "#{app_name}")
400
+
401
+ RUBY
402
+ end
403
+ end
404
+
405
+ # Copy locale files
406
+ def copy_locales
407
+ say 'Coping files..'
408
+ copy_file 'config/locales/models.en.yml', 'config/locales/models.en.yml'
409
+ copy_file 'config/locales/models.tr.yml', 'config/locales/models.tr.yml'
410
+ copy_file 'config/locales/show_for.en.yml', 'config/locales/show_for.en.yml'
411
+ copy_file 'config/locales/show_for.tr.yml', 'config/locales/show_for.tr.yml'
412
+ copy_file 'config/locales/simple_form.tr.yml', 'config/locales/simple_form.tr.yml'
413
+ copy_file 'config/locales/view.en.yml', 'config/locales/view.en.yml'
414
+ copy_file 'config/locales/view.tr.yml', 'config/locales/view.tr.yml'
415
+ end
416
+
357
417
  private
358
418
 
359
419
  def action_mailer_host(rails_env, host)
@@ -398,9 +458,7 @@ require "#{path}"
398
458
 
399
459
  def devise_parameter_sanitizer(model_name)
400
460
  inject_into_file 'app/controllers/application_controller.rb', :after => 'protect_from_forgery with: :exception' do <<-CODE
401
-
402
461
  protected
403
-
404
462
  def devise_parameter_sanitizer
405
463
  if resource_class == #{model_name.classify}
406
464
  #{model_name.classify}::ParameterSanitizer.new(#{model_name.classify}, :#{model_name.parameterize}, params)
@@ -440,7 +498,6 @@ require "#{path}"
440
498
  def set_user_time_zone
441
499
  Time.zone = current_user.time_zone if user_signed_in? && current_user.time_zone.present?
442
500
  end
443
-
444
501
  CODE
445
502
  end
446
503
  inject_into_file 'app/controllers/application_controller.rb', :after => 'class ApplicationController < ActionController::Base' do <<-CODE
@@ -473,5 +530,6 @@ require "#{path}"
473
530
  RUBY
474
531
  end
475
532
  end
533
+
476
534
  end
477
535
  end
@@ -42,7 +42,7 @@ module Cybele
42
42
  invoke :setup_time_zone
43
43
  invoke :setup_bullet_config
44
44
  invoke :setup_hq_namespace
45
- invoke :setup_profiles
45
+ invoke :setup_profiles
46
46
  end
47
47
 
48
48
  def customize_gemfile
@@ -181,53 +181,79 @@ module Cybele
181
181
  build :create_profile
182
182
  end
183
183
 
184
- def run_bundle
185
- end
184
+ # def run_bundle
185
+ # say 'Run bundle'
186
+ # end
186
187
 
187
188
  def setup_hierapolis
189
+ say 'Setup hierapolis'
188
190
  build :create_hierapolis_theme
189
191
  end
190
192
 
191
193
  def setup_sipmle_form_wrapper
194
+ say 'Setup sipmle form wrapper'
192
195
  build :replace_simple_form_wrapper
193
196
  end
194
197
 
195
198
  def setup_exception_notification_to_environments
199
+ say 'Setup exception notification for environments'
196
200
  build :add_exception_notification_to_environments
197
201
  end
198
202
 
199
203
  def install_capistrano
204
+ say 'Setup capistrano'
200
205
  build :setup_capistrano
201
206
  end
202
207
 
208
+ def setup_capistrano_settings
209
+ say 'Setup capistrano settings'
210
+ build :setup_capistrano_settings
211
+ end
212
+
203
213
  def setup_recipes
204
214
  build :setup_recipes
205
215
  end
206
216
 
207
217
  def setup_secret_token
218
+ say 'Setup secret token'
208
219
  build :update_secret_token
209
220
  end
210
221
 
211
222
  def setup_bullet_config
223
+ say 'Setup bullet config'
212
224
  build :configure_bullet
213
225
  end
214
226
 
215
227
  def install_show_for
228
+ say 'Setup show_for'
216
229
  build :setup_show_for
217
230
  end
218
231
 
219
232
  def create_dev_rake
233
+ say 'Create dev_rake'
220
234
  build :create_dev_rake
221
235
  end
222
236
 
223
237
  def custom_exception_page
238
+ say 'Setup custom exception pages'
224
239
  build :custom_exception_page
225
240
  end
226
241
 
227
242
  def custom_404
243
+ say 'Setup 404 page'
228
244
  build :custom_404
229
245
  end
230
246
 
247
+ def add_seeds
248
+ say 'Add seeds main'
249
+ build :add_seeds
250
+ end
251
+
252
+ def copy_locales
253
+ say 'Copy config/locale files'
254
+ build :copy_locales
255
+ end
256
+
231
257
  def goodbye
232
258
  say 'Congratulations! That\'s all...'
233
259
  end
@@ -1,4 +1,5 @@
1
1
  module Cybele
2
- VERSION = '1.6.0'.freeze
3
- end
4
-
2
+ RAILS_VERSION = '~> 4.2.3'
3
+ RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
+ VERSION = '1.7.0'
5
+ end
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  class Hq::AdminProfilesController < Hq::ApplicationController
3
- before_action :profile_controller
4
- before_action :set_admin_profile, only: [:show, :edit, :update, :destroy]
3
+
4
+ before_action :check_profile, only: [:new, :create]
5
+ before_action :profile_controller, except: [:new, :create]
6
+ before_action :set_admin_profile, only: [:show, :edit, :update]
5
7
  add_breadcrumb I18n.t('activerecord.models.admin_profiles'), :hq_admin_profile_path
6
8
 
7
9
  def show
@@ -38,6 +40,12 @@ class Hq::AdminProfilesController < Hq::ApplicationController
38
40
  end
39
41
  end
40
42
 
43
+ def check_profile
44
+ if current_admin.admin_profile.present?
45
+ redirect_to user_profile_path
46
+ end
47
+ end
48
+
41
49
  def set_admin_profile
42
50
  @admin_profile = current_admin.admin_profile
43
51
  end
@@ -1,3 +1,16 @@
1
1
  class Hq::SessionsController < Devise::SessionsController
2
2
  layout 'login'
3
+
4
+ private
5
+
6
+ # Overwriting the sign_out redirect path method
7
+ def after_sign_in_path_for(resource_or_scope)
8
+ hq_root_path
9
+ end
10
+
11
+ # Overwriting the sign_out redirect path method
12
+ def after_sign_out_path_for(resource_or_scope)
13
+ new_admin_session_path
14
+ end
15
+
3
16
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  class UserProfilesController < ApplicationController
3
- before_action :profile_controller
4
- before_action :set_user_profile, only: [:show, :edit, :update, :destroy]
3
+ before_action :authenticate_user!
4
+ before_action :check_profile, only: [:new, :create]
5
+ before_action :profile_controller, except: [:new, :create]
6
+ before_action :set_user_profile, only: [:show, :edit, :update]
5
7
  add_breadcrumb I18n.t('activerecord.models.user_profiles'), :user_profile_path
6
8
 
7
9
  def show
@@ -38,6 +40,12 @@ class UserProfilesController < ApplicationController
38
40
  end
39
41
  end
40
42
 
43
+ def check_profile
44
+ if current_user.user_profile.present?
45
+ redirect_to user_profile_path
46
+ end
47
+ end
48
+
41
49
  def set_user_profile
42
50
  @user_profile = current_user.user_profile
43
51
  end
@@ -1,6 +1,9 @@
1
1
  %p
2
- Hello #{@resource.email}!
3
- %p Someone has requested a link to change your password. You can do this through the link below.
4
- %p= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token)
5
- %p If you didn't request this, please ignore this email.
6
- %p Your password won't change until you access the link above and create a new one.
2
+ = t( 'email.salut', email: @resource.email )
3
+ %p
4
+ = t( 'email.devise.reset_password.desc1')
5
+ %p= link_to t( 'email.devise.reset_password.change'), edit_password_url(@resource, :reset_password_token => @token)
6
+ %p
7
+ = t( 'email.devise.reset_password.desc2')
8
+ %p
9
+ = t( 'email.devise.reset_password.desc3')