Class: LeanCms::Generators::DemoGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- LeanCms::Generators::DemoGenerator
- Defined in:
- lib/generators/lean_cms/demo/demo_generator.rb
Instance Method Summary collapse
- #add_routes ⇒ Object
- #copy_pages_controller ⇒ Object
- #copy_structure_yaml ⇒ Object
- #copy_views ⇒ Object
- #print_instructions ⇒ Object
- #seed_content ⇒ Object
Instance Method Details
#add_routes ⇒ Object
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_controller ⇒ Object
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_yaml ⇒ Object
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: [:force] end |
#copy_views ⇒ Object
14 15 16 |
# File 'lib/generators/lean_cms/demo/demo_generator.rb', line 14 def copy_views directory "views/pages", "app/views/pages" end |
#print_instructions ⇒ Object
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_content ⇒ Object
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.}", :yellow end |