Class: PandaCms::DemoSiteGenerator
- Inherits:
-
Object
- Object
- PandaCms::DemoSiteGenerator
- Defined in:
- app/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.
5 6 7 8 9 |
# File 'app/lib/panda_cms/demo_site_generator.rb', line 5 def initialize @menus = {} @pages = {} @templates = {} end |
Instance Attribute Details
#menus ⇒ Object
Returns the value of attribute menus.
3 4 5 |
# File 'app/lib/panda_cms/demo_site_generator.rb', line 3 def @menus end |
#pages ⇒ Object
Returns the value of attribute pages.
3 4 5 |
# File 'app/lib/panda_cms/demo_site_generator.rb', line 3 def pages @pages end |
#templates ⇒ Object
Returns the value of attribute templates.
3 4 5 |
# File 'app/lib/panda_cms/demo_site_generator.rb', line 3 def templates @templates end |
Instance Method Details
#create_menus ⇒ Hash
Creates initial menus
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/lib/panda_cms/demo_site_generator.rb', line 50 def @menus = {} @menus[:main] = PandaCms::Menu.find_or_create_by(name: "Main Menu") @menus[:footer] = PandaCms::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
35 36 37 38 39 40 41 42 43 44 |
# File 'app/lib/panda_cms/demo_site_generator.rb', line 35 def create_pages @pages[:home] = PandaCms::Page.find_or_create_by({path: "/", title: "Home", template: @templates[:homepage]}) @pages[:about] = PandaCms::Page.find_or_create_by({path: "/about", title: "About", template: @templates[:page], parent: @pages[:home]}) @pages[:terms] = PandaCms::Page.find_or_create_by({path: "/terms-and-conditions", title: "Terms & Conditions", template: @templates[:page], parent: @pages[:home], status: "hidden"}) PandaCms::Page.reset_column_information PandaCms::Page.rebuild! @pages end |
#create_templates ⇒ Object
Creates initial templates and empty blocks
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/lib/panda_cms/demo_site_generator.rb', line 15 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] = PandaCms::Template.find_or_create_by(template) end @templates[:homepage].update(max_uses: 1) @templates end |