Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail Akbudak committed Jun 21, 2016
1 parent 6df8ef1 commit bda5265
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 45 deletions.
56 changes: 11 additions & 45 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ def convert_application_css_to_sass
end

def copy_vendor_assets
copy_file 'vendor/assets/javascripts/jquery.datetimepicker.js', 'vendor/assets/javascripts/jquery.datetimepicker.js'
copy_file 'vendor/assets/javascripts/nprogress.js', 'vendor/assets/javascripts/nprogress.js'
copy_file 'vendor/assets/javascripts/jquery.maskedinput.min.js', 'vendor/assets/javascripts/jquery.maskedinput.min.js'
copy_file 'vendor/assets/javascripts/trix.js', 'vendor/assets/javascripts/trix.js'

copy_file 'vendor/assets/stylesheets/jquery.datetimepicker.css', 'vendor/assets/stylesheets/jquery.datetimepicker.css'
copy_file 'vendor/assets/stylesheets/nprogress.css', 'vendor/assets/stylesheets/nprogress.css'
copy_file 'vendor/assets/stylesheets/trix.css', 'vendor/assets/stylesheets/trix.css'
directory 'vendor/assets', 'vendor/assets'
end

def configure_smtp
Expand Down Expand Up @@ -288,34 +281,12 @@ def generate_welcome_page
def setup_namespaces
generate 'devise Admin name:string surname:string is_active:boolean'

copy_file 'app/controllers/hq/application_controller.rb', 'app/controllers/hq/application_controller.rb'

copy_file 'app/controllers/hq/dashboard_controller.rb', 'app/controllers/hq/dashboard_controller.rb'
template 'app/views/hq/dashboard/index.html.haml.erb', 'app/views/hq/dashboard/index.html.haml', force: true

copy_file 'app/controllers/hq/passwords_controller.rb', 'app/controllers/hq/passwords_controller.rb'
directory 'app/views/hq/passwords', 'app/views/hq/passwords'

copy_file 'app/controllers/hq/registrations_controller.rb', 'app/controllers/hq/registrations_controller.rb'
directory 'app/views/hq/registrations', 'app/views/hq/registrations'

copy_file 'app/controllers/hq/sessions_controller.rb', 'app/controllers/hq/sessions_controller.rb'
directory 'app/views/hq/sessions', 'app/views/hq/sessions'
directory 'app/controllers/hq', 'app/controllers/hq'
directory 'app/views/hq', 'app/views/hq'

# User controllers
copy_file 'app/controllers/user/user_application_controller.rb', 'app/controllers/user/user_application_controller.rb'

copy_file 'app/controllers/user/dashboard_controller.rb', 'app/controllers/user/dashboard_controller.rb'
directory 'app/views/user/dashboard', 'app/views/user/dashboard'

copy_file 'app/controllers/user/passwords_controller.rb', 'app/controllers/user/passwords_controller.rb'
directory 'app/views/user/passwords', 'app/views/user/passwords'

copy_file 'app/controllers/user/registrations_controller.rb', 'app/controllers/user/registrations_controller.rb'
directory 'app/views/user/registrations', 'app/views/user/registrations'

copy_file 'app/controllers/user/sessions_controller.rb', 'app/controllers/user/sessions_controller.rb'
directory 'app/views/user/sessions', 'app/views/user/sessions'
directory 'app/controllers/user', 'app/controllers/user'
directory 'app/views/user', 'app/views/user'

end

Expand Down Expand Up @@ -407,17 +378,14 @@ def add_seeds
def copy_files
# Locale files
say 'Coping files..'
copy_file 'config/locales/models.tr.yml', 'config/locales/models.tr.yml'
copy_file 'config/locales/show_for.tr.yml', 'config/locales/show_for.tr.yml'
copy_file 'config/locales/simple_form.tr.yml', 'config/locales/simple_form.tr.yml'
copy_file 'config/locales/view.tr.yml', 'config/locales/view.tr.yml'
copy_file 'config/locales/email.tr.yml', 'config/locales/email.tr.yml'
remove_file 'config/locales/en.yml'
remove_file 'config/locales/simple_form.en.yml'
directory 'config/locales', 'config/locales'

# Model files
remove_file 'app/models/admin.rb'
copy_file 'app/models/admin.rb', 'app/models/admin.rb'
remove_file 'app/models/user.rb'
copy_file 'app/models/user.rb', 'app/models/user.rb'
directory 'app/models', 'app/models'

# Route file
say 'Restore routes.rb'
Expand All @@ -437,13 +405,11 @@ def copy_files

# Hq assets files
remove_file 'app/assets/javascripts/hq/application.js.coffee'
copy_file 'app/assets/javascripts/hq/application.js.coffee', 'app/assets/javascripts/hq/application.js.coffee'

remove_file 'app/assets/stylesheets/hq/application.css.sass'
copy_file 'app/assets/stylesheets/hq/application.css.sass', 'app/assets/stylesheets/hq/application.css.sass'
directory 'app/assets', 'app/assets'

# Partial files in layouts folder
copy_file 'app/views/layouts/partials/_warnings.html.haml', 'app/views/layouts/partials/_warnings.html.haml'
directory 'app/views/layouts/partials', 'app/views/layouts/partials'

# Root folder files
copy_file 'cybele_version.txt', 'VERSION.txt'
Expand Down
10 changes: 10 additions & 0 deletions templates/app/mailers/admin_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AdminMailer < BaseMailer

def send_login_information(admin_id, password)
@admin = Admin.find admin_id
@password = password
@subject = t('email.admin.send_login_information.title')
mail(to: @admin.email, subject: @subject)
end

end
4 changes: 4 additions & 0 deletions templates/app/mailers/base_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class BaseMailer < ActionMailer::Base
default from: Settings.email.noreply
layout 'mailer'
end
10 changes: 10 additions & 0 deletions templates/app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class UserMailer < BaseMailer

def send_login_information(user_id, password)
@user = User.find user_id
@password = password
@subject = t('email.user.send_login_information.title')
mail(to: @user.email, subject: @subject)
end

end

0 comments on commit bda5265

Please sign in to comment.