Class: Birdses::PagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/birdses/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
# File 'app/controllers/birdses/pages_controller.rb', line 16

def create
  name    = params[:page][:name].gsub(/\//, '-')
  content = params[:page][:raw_data]
  @page = Page.create(name, content, @user)
  redirect_to "#{pages_path}/#{name}"
end

#destroyObject



30
31
32
33
# File 'app/controllers/birdses/pages_controller.rb', line 30

def destroy
  Page.destroy(params[:id], @user)
  redirect_to pages_path
end

#indexObject



8
9
10
# File 'app/controllers/birdses/pages_controller.rb', line 8

def index
  @pages = Page.all
end

#newObject



12
13
14
# File 'app/controllers/birdses/pages_controller.rb', line 12

def new
  @page = Page.new
end

#previewObject



35
36
37
38
39
40
41
42
# File 'app/controllers/birdses/pages_controller.rb', line 35

def preview
  md = Page.preview(params[:name], params[:md_content])
  html = md.formatted_data

  respond_to do |format|
    format.json { render :json => { :html => html } }
  end
end

#updateObject



23
24
25
26
27
28
# File 'app/controllers/birdses/pages_controller.rb', line 23

def update
  name    = params[:id]
  content = params[:page][:raw_data]
  Page.update(name, content, @user)
  redirect_to "#{pages_path}/#{name}"
end