Class: Panda::CMS::DemoSiteGenerator
- Inherits:
-
Object
- Object
- Panda::CMS::DemoSiteGenerator
- Defined in:
- lib/panda/cms/demo_site_generator.rb
Instance Attribute Summary collapse
-
#menus ⇒ Object
Returns the value of attribute menus.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#templates ⇒ Object
Returns the value of attribute templates.
Instance Method Summary collapse
-
#create_menus ⇒ Hash
Creates initial menus.
-
#create_pages ⇒ Hash
Creates initial pages.
-
#create_templates ⇒ Object
Creates initial templates and empty blocks.
-
#initialize ⇒ DemoSiteGenerator
constructor
A new instance of DemoSiteGenerator.
Constructor Details
#initialize ⇒ DemoSiteGenerator
Returns a new instance of DemoSiteGenerator.
8 9 10 11 12 |
# File 'lib/panda/cms/demo_site_generator.rb', line 8 def initialize @menus = {} @pages = {} @templates = {} end |
Instance Attribute Details
#menus ⇒ Object
Returns the value of attribute menus.
6 7 8 |
# File 'lib/panda/cms/demo_site_generator.rb', line 6 def @menus end |
#pages ⇒ Object
Returns the value of attribute pages.
6 7 8 |
# File 'lib/panda/cms/demo_site_generator.rb', line 6 def pages @pages end |
#templates ⇒ Object
Returns the value of attribute templates.
6 7 8 |
# File 'lib/panda/cms/demo_site_generator.rb', line 6 def templates @templates end |
Instance Method Details
#create_menus ⇒ Hash
Creates initial menus
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/panda/cms/demo_site_generator.rb', line 75 def @menus = {} @menus[:main] = Panda::CMS::Menu.find_or_create_by(name: "Main Menu") @menus[:footer] = Panda::CMS::Menu.find_or_create_by(name: "Footer Menu") # Automatically create main menu from homepage unless @pages[:home].nil? @menus[:main].update(kind: :auto, start_page: @pages[:home], depth: 1) @menus[:main]. end @menus end |
#create_pages ⇒ Hash
Creates initial pages
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/panda/cms/demo_site_generator.rb', line 38 def create_pages @pages[:home] = Panda::CMS::Page.find_or_create_by({ path: "/", title: "Home", panda_cms_template_id: @templates[:homepage].id }) @pages[:about] = Panda::CMS::Page.find_or_create_by({ path: "/about", title: "About", panda_cms_template_id: @templates[:page].id, parent: @pages[:home] }) @pages[:not_found] = Panda::CMS::Page.find_or_create_by({ path: "/404", title: "Page Not Found", panda_cms_template_id: @templates[:page].id, parent: @pages[:home], status: "hidden" }) @pages[:internal_error] = Panda::CMS::Page.find_or_create_by({ path: "/500", title: "Internal Server Error", panda_cms_template_id: @templates[:page].id, parent: @pages[:home], status: "hidden" }) Panda::CMS::Page.reset_column_information Panda::CMS::Page.rebuild! @pages end |
#create_templates ⇒ Object
Creates initial templates and empty blocks
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/panda/cms/demo_site_generator.rb', line 18 def create_templates # Templates initial_templates = [ {name: "Homepage", file_path: "layouts/homepage"}, {name: "Page", file_path: "layouts/page"} ] initial_templates.each do |template| key = template[:name].downcase.to_sym @templates[key] = Panda::CMS::Template.find_or_create_by(template) end @templates[:homepage].update(max_uses: 1) @templates end |