Class: Workarea::BlogSeeds

Inherits:
Object
  • Object
show all
Defined in:
app/seeds/workarea/blog_seeds.rb

Instance Method Summary collapse

Instance Method Details

#add_blog_navigationObject



29
30
31
32
33
34
35
36
37
38
# File 'app/seeds/workarea/blog_seeds.rb', line 29

def add_blog_navigation
  blog_root = add_blogs_index
  blogs = Workarea::Content::Blog.all

  blogs.each do |blog|
    blog_root.children.create!(navigable: blog)
  end

  add_taxonomy_content_block(blog_root)
end

#add_blogs_indexObject



40
41
42
# File 'app/seeds/workarea/blog_seeds.rb', line 40

def add_blogs_index
  Navigation::Taxon.root.children.create!(name: 'Blog', url: '/blogs')
end

#add_taxonomy_content_block(blog_root) ⇒ Object



44
45
46
47
48
49
50
51
# File 'app/seeds/workarea/blog_seeds.rb', line 44

def add_taxonomy_content_block(blog_root)
  menu = Navigation::Menu.create!(taxon: blog_root)
  content = Content.for(menu)
  content.blocks.create!(
    type: 'taxonomy',
    data: { start: blog_root.id.to_s }
  )
end

#create_landing_page_contentObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/seeds/workarea/blog_seeds.rb', line 15

def create_landing_page_content
  landing_page_content = Workarea::Content.for('Blog Landing Page')

  landing_page_content.blocks.create!(
    area: 'header_content',
    type: 'text',
    data: {
      text: Faker::Hipster.paragraph(4)
    }
  )

  landing_page_content.save!
end

#performObject



3
4
5
6
7
8
9
10
11
12
13
# File 'app/seeds/workarea/blog_seeds.rb', line 3

def perform
  puts 'Adding blogs...'

  Sidekiq::Callbacks.disable do
    Content::Blog.create!(name: 'Hi, Fashion')
    Content::Blog.create!(name: 'HowTo Couture')
  end

  create_landing_page_content
  add_blog_navigation
end