Class: FeatherCms::PagesController

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

Instance Method Summary collapse

Instance Method Details

#all_pageObject



79
80
81
# File 'app/controllers/feather_cms/pages_controller.rb', line 79

def all_page
  @pages = Page.order(:name)
end

#createObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/feather_cms/pages_controller.rb', line 28

def create
  @page = Page.new(params[:page])
  @page.name = @page.name.parameterize

  @page.status = 'draft'
  @page.template_type = 'html'

  if @page.save
    redirect_to pages_path
  else
    render :new
  end
end

#destroyObject



57
58
59
60
# File 'app/controllers/feather_cms/pages_controller.rb', line 57

def destroy
  @page.destroy
  redirect_to pages_path
end

#editObject



23
24
25
26
# File 'app/controllers/feather_cms/pages_controller.rb', line 23

def edit
  @draft_page = Page.where(:name => @page.name, :status => 'draft').first
  @published_page = Page.where(:name => @page.name, :status => 'published').first
end

#find_pageObject



75
76
77
# File 'app/controllers/feather_cms/pages_controller.rb', line 75

def find_page
  @page = Page.find(params[:id])
end

#indexObject



15
16
# File 'app/controllers/feather_cms/pages_controller.rb', line 15

def index
end

#newObject



18
19
20
21
# File 'app/controllers/feather_cms/pages_controller.rb', line 18

def new
  @page = Page.new
  @page.status = 'draft'
end

#previewObject



62
63
64
# File 'app/controllers/feather_cms/pages_controller.rb', line 62

def preview
  render :inline => @page.content.html_safe, :type => @page.template_type, :layout => @page.layout
end

#publishedObject



66
67
68
69
70
71
72
73
# File 'app/controllers/feather_cms/pages_controller.rb', line 66

def published
  @page = Page.where(:name => params[:name], :status => 'published').first 
  if @page
    render :inline => @page.content, :type => @page.template_type, :layout => @page.layout
  else
    redirect_to '/404.html'
  end
end

#updateObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/feather_cms/pages_controller.rb', line 42

def update
  status = params[:page].delete(:status)

  @page.attributes = params[:page]
  @page.name = @page.name.parameterize
  @page.status = status
  @page.template_type = 'html'

  if @page.save
    redirect_to pages_path
  else
    render :new
  end
end