Module: Birdses::Page

Extended by:
Page
Included in:
Page
Defined in:
app/models/birdses/page.rb

Constant Summary collapse

WIKI_FORMAT =
:markdown

Instance Method Summary collapse

Instance Method Details

#allObject



8
9
10
# File 'app/models/birdses/page.rb', line 8

def all
  wiki.pages
end

#create(page_name, content, user) ⇒ Object



16
17
18
19
# File 'app/models/birdses/page.rb', line 16

def create(page_name, content, user)
  wiki.write_page(page_name, WIKI_FORMAT, content,
                  build_commit(user, "creating #{page_name}"))
end

#destroy(page_name, user) ⇒ Object



27
28
29
30
# File 'app/models/birdses/page.rb', line 27

def destroy(page_name, user)
  page = find_by_name(page_name)
  wiki.delete_page(page, build_commit(user, "delete #{page_name}"))
end

#find_by_name(name) ⇒ Object



32
33
34
# File 'app/models/birdses/page.rb', line 32

def find_by_name(name)
  wiki.page(name)
end

#newObject



12
13
14
# File 'app/models/birdses/page.rb', line 12

def new
  Struct.new(:name, :raw_data).new('New Page', '')
end

#preview(page_name, content) ⇒ Object



36
37
38
# File 'app/models/birdses/page.rb', line 36

def preview(page_name, content)
  wiki.preview_page(page_name, content, WIKI_FORMAT)
end

#update(page_name, content, user) ⇒ Object



21
22
23
24
25
# File 'app/models/birdses/page.rb', line 21

def update(page_name, content, user)
  page = find_by_name(page_name)
  wiki.update_page(page, page.name, page.format, content,
                   build_commit(user, "updating #{page_name}"))
end