Class: Dust::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper, ActionView::Helpers::TextHelper, Menu::ItemDependency
Defined in:
app/models/dust/page.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Menu::ItemDependency

#active, #active=, #filename, #filename=, #match_path, #menu, #menu=, #nav_link, #nav_link=

Class Method Details

.page(search, page) ⇒ Object

– ActiveRecord Queries –#



18
19
20
# File 'app/models/dust/page.rb', line 18

def self.page(search, page)
  search(search).order("meta_title").paginate(:per_page => 12, :page => page)
end

.search(search) ⇒ Object



22
23
24
25
26
27
28
# File 'app/models/dust/page.rb', line 22

def self.search(search)
  if search
    where("meta_title LIKE ? OR meta_description LIKE ?", "%#{search}%", "%#{search}%")
  else
    scoped
  end
end

Instance Method Details

#create_descriptionObject



35
36
37
# File 'app/models/dust/page.rb', line 35

def create_description
  meta_description
end

#create_starter_blockObject



39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/dust/page.rb', line 39

def create_starter_block
  Block.new(
    :show_title => true,
    :title => "#{self.meta_title} Page Content", 
    :body => "<h1> #{self.meta_title} </h1> <p>New content.</p>", 
    :classes => "twelve columns", 
    :where_to_show => Dust.config.default_region,
    :show => "/#{self.filename}",
    :weight => 0
  ).save
end

#front_end_contentObject



30
31
32
33
# File 'app/models/dust/page.rb', line 30

def front_end_content
  options = { :page => self }
  Handlebar.render(content, options)
end