Skip to content

Commit

Permalink
KBP-119 #time 3h - Welcome controller and views created
Browse files Browse the repository at this point in the history
  • Loading branch information
esref.viduslu committed Dec 1, 2017
2 parents 941958b + edcbf38 commit ff21cca
Show file tree
Hide file tree
Showing 111 changed files with 1,864 additions and 130 deletions.
10 changes: 5 additions & 5 deletions bin/build_app
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
echo "Build cybele gem"
./bin/build_gem

# Remove example
echo "Remove test"
rm -rf tmp/example
# Remove dummy_app
echo "Remove dummy_app"
rm -rf tmp/dummy_app

# Disable spring
export DISABLE_SPRING=1
# or you can run this command
# ps ax | grep spring | grep dummy_app | cut -f1 -d' ' | xargs kill

# Create dummy_app
echo "Create example"
cybele tmp/example --skip-ask
echo "Create dummy_app"
cybele tmp/dummy_app --skip-create-database
12 changes: 9 additions & 3 deletions lib/cybele.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +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/helpers/landing_pages'
require 'cybele/app_builder'
14 changes: 10 additions & 4 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,11 +16,17 @@ 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
include Cybele::Helpers::LandingPages

def readme
template 'README.md.erb',
Expand Down
38 changes: 26 additions & 12 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 docker_development_env
return if @options[:skip_docker]
say 'Setup docker development environment', :green
Expand All @@ -256,9 +249,30 @@ def setup_pronto_config
build :configure_pronto
end

def setup_landing_pages
say 'Generate Landing Pages'
build :generate_landing_pages
def setup_audited
say 'Setup audited gem', :green
build :configure_audited
end

def customize_view_files
return if @options[:skip_view_files]
say 'Customize view files', :green
build :customize_assets_files
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 setup_git_and_git_flow
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
17 changes: 17 additions & 0 deletions lib/cybele/helpers/app_files/controller_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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'

# Welcome controller
copy_file 'app_files/app/controllers/welcome_controller.rb', 'app/controllers/welcome_controller.rb'
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
24 changes: 24 additions & 0 deletions lib/cybele/helpers/app_files/view_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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'
directory 'app_files/app/views/welcome', 'app/views/welcome'
template 'app_files/app/views/layouts/application.html.haml.erb',
'app/views/layouts/application.html.haml', force: true
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
28 changes: 0 additions & 28 deletions lib/cybele/helpers/landing_pages.rb

This file was deleted.

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
18 changes: 18 additions & 0 deletions lib/cybele/helpers/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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 ff21cca

Please sign in to comment.