Skip to content

Commit

Permalink
Merged in feature/make_hq_side (pull request #28)
Browse files Browse the repository at this point in the history
KBP-118 #time 2d - Hq side was done without simple admin template

Approved-by: İsmail Akbudak <[email protected]>
  • Loading branch information
Hamdi Bayhan committed Nov 30, 2017
2 parents 3fb4c48 + 0ae610a commit edcbf38
Show file tree
Hide file tree
Showing 103 changed files with 1,830 additions and 68 deletions.
11 changes: 9 additions & 2 deletions lib/cybele.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
require 'cybele/helpers/devise'
require 'cybele/helpers/docker'
require 'cybele/helpers/error_pages'
require 'cybele/helpers/view_files/assets_files'
require 'cybele/helpers/view_files/view_gems'
require 'cybele/helpers/audited'
require 'cybele/helpers/routes'
require 'cybele/helpers/app_files/assets_files'
require 'cybele/helpers/app_files/controller_files'
require 'cybele/helpers/app_files/model_files'
require 'cybele/helpers/app_files/mailer_files'
require 'cybele/helpers/app_files/helper_files'
require 'cybele/helpers/app_files/view_files'
require 'cybele/helpers/app_files/view_gems'
require 'cybele/helpers/pronto'
require 'cybele/app_builder'
13 changes: 10 additions & 3 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Cybele
class AppBuilder < Rails::AppBuilder
class AppBuilder < Rails::AppBuilder # rubocop:disable Metrics/ClassLength
include Cybele::Helpers
include Cybele::Helpers::Staging
include Cybele::Helpers::Sidekiq
Expand All @@ -16,8 +16,15 @@ class AppBuilder < Rails::AppBuilder
include Cybele::Helpers::Paperclip
include Cybele::Helpers::Devise
include Cybele::Helpers::ErrorPages
include Cybele::Helpers::ViewFiles::AssetsFiles
include Cybele::Helpers::ViewFiles::ViewGems
include Cybele::Helpers::Audited
include Cybele::Helpers::Routes
include Cybele::Helpers::AppFiles::AssetsFiles
include Cybele::Helpers::AppFiles::ControllerFiles
include Cybele::Helpers::AppFiles::ModelFiles
include Cybele::Helpers::AppFiles::MailerFiles
include Cybele::Helpers::AppFiles::HelperFiles
include Cybele::Helpers::AppFiles::ViewFiles
include Cybele::Helpers::AppFiles::ViewGems
include Cybele::Helpers::Docker
include Cybele::Helpers::Pronto

Expand Down
31 changes: 22 additions & 9 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ def setup_paperclip_and_add_aws
def setup_devise
say 'Generate devise'
build :generate_devise_settings
say 'Adding devise user model'
build :generate_devise_user
build :generate_devise_views
say 'Adding devise models'
build :generate_devise_models
say 'Generate devise'
end

Expand All @@ -239,12 +238,6 @@ def configure_error_pages
build :configure_error_pages
end

def customize_view_files
return if @options[:skip_view_files]
say 'Customize view files', :green
build :customize_assets_files
end

def setup_git_and_git_flow
say 'Initialize git and git flow'
build :git_and_git_flow_commands
Expand All @@ -261,6 +254,26 @@ def setup_pronto_config
build :configure_pronto
end

def setup_audited
say 'Setup audited gem', :green
build :configure_audited
end

def customize_app_files
build :customize_model_files
build :customize_mailer_files
build :customize_default_view_files
return if @options[:skip_view_files]
say 'Customize app files', :green
build :customize_assets_files
build :customize_helper_files
build :customize_view_files_with_option
build :generate_devise_views
build :configure_routes
build :customize_controller_files
build :add_devise_authenticate_admin
end

def goodbye
say 'Congratulations! That\'s all...', :green
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

module Cybele
module Helpers
module ViewFiles
module AppFiles
module AssetsFiles
def customize_assets_files
# Javascript Assets files
remove_file 'app/assets/javascripts/application.js', force: true

template 'view_files/app/assets/javascripts/application.js',
template 'app_files/app/assets/javascripts/application.js',
'app/assets/javascripts/application.js',
force: true

template 'view_files/app/assets/javascripts/hq/application.js',
template 'app_files/app/assets/javascripts/hq/application.js',
'app/assets/javascripts/hq/application.js',
force: true

# Css Assets files
remove_file 'app/assets/stylesheets/application.css', force: true

template 'view_files/app/assets/stylesheets/application.css.sass',
template 'app_files/app/assets/stylesheets/application.css.sass',
'app/assets/stylesheets/application.css.sass',
force: true

template 'view_files/app/assets/stylesheets/hq/application.css.sass',
template 'app_files/app/assets/stylesheets/hq/application.css.sass',
'app/assets/stylesheets/hq/application.css.sass',
force: true
end
Expand Down
14 changes: 14 additions & 0 deletions lib/cybele/helpers/app_files/controller_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Cybele
module Helpers
module AppFiles
module ControllerFiles
def customize_controller_files
# HQ controller files
directory 'app_files/app/controllers/hq', 'app/controllers/hq'
end
end
end
end
end
15 changes: 15 additions & 0 deletions lib/cybele/helpers/app_files/helper_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Cybele
module Helpers
module AppFiles
module HelperFiles
def customize_helper_files
# Helper files
remove_file 'app/helpers/application_helper.rb', force: true
template 'app_files/app/helpers/application_helper.rb.erb', 'app/helpers/application_helper.rb'
end
end
end
end
end
15 changes: 15 additions & 0 deletions lib/cybele/helpers/app_files/mailer_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Cybele
module Helpers
module AppFiles
module MailerFiles
def customize_mailer_files
# Model files
remove_file 'app/mailers/application_mailer.rb', force: true
directory 'app_files/app/mailers', 'app/mailers'
end
end
end
end
end
15 changes: 15 additions & 0 deletions lib/cybele/helpers/app_files/model_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Cybele
module Helpers
module AppFiles
module ModelFiles
def customize_model_files
# Model files
remove_file 'app/models/admin.rb', force: true
directory 'app_files/app/models', 'app/models'
end
end
end
end
end
21 changes: 21 additions & 0 deletions lib/cybele/helpers/app_files/view_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Cybele
module Helpers
module AppFiles
module ViewFiles
def customize_view_files_with_option
# View files with option
directory 'app_files/app/views/hq', 'app/views/hq'
directory 'app_files/app/views/layouts/hq', 'app/views/layouts/hq'
directory 'app_files/app/views/layouts/partials', 'app/views/layouts/partials'
end

def customize_default_view_files
# Default view files
directory 'app_files/app/views/admin_mailer', 'app/views/admin_mailer'
end
end
end
end
end
23 changes: 23 additions & 0 deletions lib/cybele/helpers/app_files/view_gems.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module Cybele
module Helpers
module AppFiles
module ViewGems
def add_required_view_gems
# Add bootstrap gem
append_file('Gemfile', template_content('app_files/bootstrap_Gemfile.erb'))

# Add blankable gem
append_file('Gemfile', template_content('app_files/blankable_Gemfile.erb'))

# Add breadcrumb gem
append_file('Gemfile', template_content('app_files/breadcrumb_Gemfile.erb'))

# Add fontawesome gem
append_file('Gemfile', template_content('app_files/fontawesome_Gemfile.erb'))
end
end
end
end
end
12 changes: 12 additions & 0 deletions lib/cybele/helpers/audited.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Cybele
module Helpers
module Audited
def configure_audited
# Generate Audited
generate 'audited:install'
end
end
end
end
11 changes: 9 additions & 2 deletions lib/cybele/helpers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ def generate_devise_settings
end
end

def generate_devise_user
def generate_devise_models
generate 'devise User name:string surname:string is_active:boolean time_zone:string'
generate 'devise Admin name:string surname:string is_active:boolean time_zone:string'
remove_file 'config/locales/devise.en.yml', force: true
end

def generate_devise_views
generate 'devise:views'
directory 'devise/devise_views', 'app/views/devise'
end

def add_devise_authenticate_admin
inject_into_file 'app/controllers/hq/application_controller.rb',
template_content('devise/devise_authenticate_admin.rb.erb'),
after: 'class Hq::ApplicationController < ApplicationController'
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/cybele/helpers/locale_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ module Helpers
module LocaleLanguage
def configure_locale_language
copy_file 'config/locales/tr.yml', 'config/locales/tr.yml'
copy_file 'config/locales/email.tr.yml', 'config/locales/email.tr.yml'
copy_file 'config/locales/en.yml', 'config/locales/en.yml'
copy_file 'config/locales/mailer.tr.yml', 'config/locales/mailer.tr.yml'
copy_file 'config/locales/models.tr.yml', 'config/locales/models.tr.yml'
copy_file 'config/locales/view.tr.yml', 'config/locales/view.tr.yml'
copy_file 'config/locales/email.en.yml', 'config/locales/email.en.yml'
copy_file 'config/locales/mailer.en.yml', 'config/locales/mailer.en.yml'
copy_file 'config/locales/models.en.yml', 'config/locales/models.en.yml'
copy_file 'config/locales/view.en.yml', 'config/locales/view.en.yml'
end
Expand Down
17 changes: 17 additions & 0 deletions lib/cybele/helpers/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Cybele
module Helpers
module Routes
def configure_routes
# HQ routes
replace_in_file 'config/routes.rb',
'devise_for :admins',
''

inject_into_file 'config/routes.rb', template_content('config/routes.rb.erb'),
before: 'if Rails.env.production? || Rails.env.staging?'
end
end
end
end
14 changes: 0 additions & 14 deletions lib/cybele/helpers/view_files/view_gems.rb

This file was deleted.

Loading

0 comments on commit edcbf38

Please sign in to comment.