Class: Alchemy::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/alchemy/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_config_rbObject



62
63
64
65
# File 'lib/generators/alchemy/install/install_generator.rb', line 62

def copy_config_rb
  @default_config = Alchemy::Configurations::Main.new
  template "#{__dir__}/templates/alchemy.rb.tt", app_config_path.join("initializers", "alchemy.rb")
end

#copy_demo_viewsObject



71
72
73
74
75
76
77
78
# File 'lib/generators/alchemy/install/install_generator.rb', line 71

def copy_demo_views
  return if options[:skip_demo_files]

  copy_file "application.html.erb", app_views_path.join("layouts", "application.html.erb")
  copy_file "_article.html.erb", app_views_path.join("alchemy", "elements", "_article.html.erb")
  copy_file "_standard.html.erb", app_views_path.join("alchemy", "page_layouts", "_standard.html.erb")
  copy_file "alchemy.en.yml", app_config_path.join("locales", "alchemy.en.yml")
end

#copy_dragonfly_configObject



80
81
82
83
84
85
86
# File 'lib/generators/alchemy/install/install_generator.rb', line 80

def copy_dragonfly_config
  template(
    "#{__dir__}/templates/dragonfly.rb.tt",
    app_config_path.join("initializers", "dragonfly.rb"),
    skip: options[:auto_accept]
  )
end

#copy_yml_filesObject



56
57
58
59
60
# File 'lib/generators/alchemy/install/install_generator.rb', line 56

def copy_yml_files
  %w[elements page_layouts menus].each do |file|
    template "#{__dir__}/templates/#{file}.yml.tt", app_config_path.join("alchemy", "#{file}.yml")
  end
end

#finalizeObject



109
110
111
112
113
114
115
116
117
# File 'lib/generators/alchemy/install/install_generator.rb', line 109

def finalize
  header
  say "Alchemy successfully installed!"
  say "Now start the server with:\n\n"
  say "  bin/rails server\n\n"
  say "and point your browser to\n\n"
  say "  http://localhost:3000/admin\n\n"
  say "and follow the onscreen instructions to finalize the installation.\n\n"
end

#install_assetsObject



67
68
69
# File 'lib/generators/alchemy/install/install_generator.rb', line 67

def install_assets
  copy_file "custom.css", app_assets_path.join("stylesheets/alchemy/admin/custom.css")
end

#install_gutentag_migrationsObject



88
89
90
# File 'lib/generators/alchemy/install/install_generator.rb', line 88

def install_gutentag_migrations
  rake "gutentag:install:migrations"
end

#mountObject



50
51
52
53
54
# File 'lib/generators/alchemy/install/install_generator.rb', line 50

def mount
  return if options[:skip_mount]

  install_tasks.inject_routes(options[:auto_accept])
end

#set_primary_languageObject



92
93
94
95
96
97
98
99
# File 'lib/generators/alchemy/install/install_generator.rb', line 92

def set_primary_language
  header
  install_tasks.set_primary_language(
    code: options[:default_language_code],
    name: options[:default_language_name],
    auto_accept: options[:auto_accept]
  )
end

#setupObject



44
45
46
47
48
# File 'lib/generators/alchemy/install/install_generator.rb', line 44

def setup
  header
  say "Welcome to AlchemyCMS!"
  say "Let's begin with some questions.\n\n"
end

#setup_databaseObject



101
102
103
104
105
106
107
# File 'lib/generators/alchemy/install/install_generator.rb', line 101

def setup_database
  rake("db:create", abort_on_failure: true) unless options[:skip_db_create]
  # We can't invoke this rake task, because Rails will use wrong engine names otherwise
  rake("alchemy:install:migrations", abort_on_failure: true)
  rake("db:migrate", abort_on_failure: true)
  install_tasks.inject_seeder
end