Class: Maglev::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_initializerObject



14
15
16
17
# File 'lib/generators/maglev/install_generator.rb', line 14

def create_initializer
  directory 'config'
  directory 'public'
end

#generate_blank_themeObject



19
20
21
# File 'lib/generators/maglev/install_generator.rb', line 19

def generate_blank_theme
  generate 'maglev:theme'
end

#instructionsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/maglev/install_generator.rb', line 35

def instructions
  $stdout.puts <<~INFO
    Done! 🎉

    You can now tweak the settings in `config/initializers/maglev.rb`.
    You can also modify your theme (`app/theme` and `app/views/theme`)
    and generate new sections with `rails g maglev:section`.

    👉 The next step is to create a site with `rails maglev:create_site`.

    🚨 Don't forget to run the last command in production as well!
  INFO
end

#migrationsObject



9
10
11
12
# File 'lib/generators/maglev/install_generator.rb', line 9

def migrations
  rake 'maglev:install:migrations'
  rake 'db:migrate'
end

#mount_engineObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/maglev/install_generator.rb', line 23

def mount_engine
  inject_into_file 'config/routes.rb', before: /^end/ do
    <<-CODE
  # Mount Maglev engine (mainly used for the content editor)
  mount Maglev::Engine => '/maglev'

  # Handle "/:path" + "/sitemap" requests by Maglev engine
  draw 'maglev/public_preview'
    CODE
  end
end