Class: AppyantraAdmin::PagesController
Instance Method Summary
collapse
#add_breadcrumb, #asset_display_name, #current_breadcrumb, #get_object_name, #set_objects
Instance Method Details
#create ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 25
def create
page = Page.new(params[:page])
page.last_updated_by = current_admin
page.created_by = current_admin
page.slug = Page.generate_slug(page.title) if (page.slug == "" || page.slug.nil?)
respond_to do |format|
if page.save
format.html do |format|
flash[:notice] = "Website Page was successfully created"
redirect_to main_app.appyantra_admin_page_path(page)
end
else
end
end
end
|
#destroy ⇒ Object
75
76
77
78
79
80
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 75
def destroy
page = Page.find(params[:id])
page.destroy
flash[:notice] = "Page was successfully deleted."
redirect_to main_app.appyantra_admin_pages_path
end
|
#display ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 82
def display
page = Page.find_by_slug(params[:slug])
if page && page.published
@page = page
@page_title = page.title
page_layout = (page.layout == 'None' ? nil : page.layout)
render '/pages/page', layout: page_layout
else
redirect_to main_app.page_not_found_path
end
end
|
#edit ⇒ Object
51
52
53
54
55
56
57
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 51
def edit
@page = Page.find(params[:id])
@page_title = 'Pages | ' + @page.title
add_breadcrumb([@page.title, main_app.appyantra_admin_page_path(@page)])
current_breadcrumb 'Edit'
render 'edit'
end
|
#index ⇒ Object
13
14
15
16
17
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 13
def index
@page_title = 'Pages'
current_breadcrumb @page_title
@pages = Page.all
end
|
#new ⇒ Object
19
20
21
22
23
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 19
def new
@page_title = 'New Page'
current_breadcrumb 'New'
@page = Page.new
end
|
#page_not_found ⇒ Object
114
115
116
117
118
119
120
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 114
def page_not_found
@page = Page.new
@page_title = 'Page not found'
@page.content = @page_title
render '/pages/page', layout: 'application'
end
|
#show ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 42
def show
@page = Page.find(params[:id])
@page_title = 'Page | ' + @page.title
current_breadcrumb @page.title
respond_to do |format|
format.html
end
end
|
#update ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 59
def update
page = Page.find(params[:id])
page.last_updated_by = current_admin
params[:page][:slug] = Page.generate_slug(params[:page][:title]) if (params[:page][:slug] == "" || params[:page][:slug].nil?)
respond_to do |format|
if page.update_attributes(params[:page])
format.html do |format|
flash[:notice] = "Website Page was successfully updated"
redirect_to main_app.appyantra_admin_page_path(page)
end
else
end
end
end
|
#update_keywords ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'app/controllers/appyantra_admin/pages_controller.rb', line 94
def update_keywords
page = Page.find(params[:id])
keywords_str = params[:keywords]
keywords = keywords_str.split(',')
PageKeyword.where(page_id: page.id).delete_all
unless keywords.empty?
keywords.each do |keyword|
page_keyword = PageKeyword.new(keyword: keyword.strip)
page.keywords << page_keyword
end
end
if page.save
flash[:notice] = "Page keywords were successfully updated"
redirect_to main_app.appyantra_admin_page_path(page)
else
end
end
|