Class: LeanCms::Generators::DemoGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/lean_cms/demo/demo_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_routesObject



23
24
25
26
27
28
29
30
# File 'lib/generators/lean_cms/demo/demo_generator.rb', line 23

def add_routes
  route <<~RUBY
    get 'about',   to: 'pages#about',   as: :about
    get 'contact', to: 'pages#contact',  as: :contact
    post 'contact', to: 'pages#submit_contact'
    root 'pages#home'
  RUBY
end

#copy_pages_controllerObject



10
11
12
# File 'lib/generators/lean_cms/demo/demo_generator.rb', line 10

def copy_pages_controller
  template "pages_controller.rb", "app/controllers/pages_controller.rb"
end

#copy_structure_yamlObject



18
19
20
21
# File 'lib/generators/lean_cms/demo/demo_generator.rb', line 18

def copy_structure_yaml
  template "lean_cms_structure.yml", "config/lean_cms_structure.yml",
           force: options[:force]
end

#copy_viewsObject



14
15
16
# File 'lib/generators/lean_cms/demo/demo_generator.rb', line 14

def copy_views
  directory "views/pages", "app/views/pages"
end


39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/generators/lean_cms/demo/demo_generator.rb', line 39

def print_instructions
  say "\n#{"=" * 60}", :green
  say "Lean CMS demo pages installed!", :green
  say "=" * 60, :green
  say ""
  say "Demo pages:"
  say "  /           -> Home (hero, features cards, intro text)"
  say "  /about      -> About (rich text, image, bullets, boolean toggle)"
  say "  /contact    -> Contact (URL, color, dropdown, form)"
  say ""
  say "Log in at /lean-cms to see in-context editing in action."
  say ""
end

#seed_contentObject



32
33
34
35
36
37
# File 'lib/generators/lean_cms/demo/demo_generator.rb', line 32

def seed_content
  say "Seeding demo content...", :yellow
  rake "lean_cms:load_structure"
rescue StandardError => e
  say "  Could not auto-seed (run 'rails lean_cms:load_structure' manually): #{e.message}", :yellow
end