Class: PostsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PostsController
show all
- Includes:
- BlogUrlHelpers
- Defined in:
- app/controllers/posts_controller.rb
Instance Method Summary
collapse
#admin_post_comments_path, #admin_post_path, #admin_post_post_comments_path, #admin_posts_path, #edit_admin_post_path, #new_admin_post_path, #post_archive_path, #post_category_archive_path, #post_category_path, #post_path, #posts_path
Instance Method Details
#archive ⇒ Object
54
55
56
57
58
59
|
# File 'app/controllers/posts_controller.rb', line 54
def archive
@posts = SpudPost.for_user(current_user).visible.for_blog(params[:blog_key]).from_archive(params[:archive_date]).paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
respond_with @posts do |format|
format.html { render view_for_action 'index' }
end
end
|
#category ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/posts_controller.rb', line 31
def category
page = 1
if params[:page].blank? == false
page = params[:page].to_i
if page.to_s != params[:page].to_s
if(page > 1)
redirect_to post_category_path(:page => page),:status => :moved_permanently and return
else
redirect_to post_category_path(:page => nil),:status => :moved_permanently and return
end
end
end
if @post_category = SpudPostCategory.find_by_url_name(params[:category_url_name])
@posts = @post_category.posts.for_user(current_user).visible.for_blog(params[:blog_key]).from_archive(params[:archive_date]).paginate(:page => page, :per_page => Spud::Blog.config.posts_per_page)
else
redirect_to posts_path
return
end
respond_with @posts do |format|
format.html { render view_for_action 'index' }
end
end
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'app/controllers/posts_controller.rb', line 70
def
unless params[:comment_validation].blank?
render :nothing => true
return
end
= @post..new()
.user_agent = request.env["HTTP_USER_AGENT"]
.user_ip = request.remote_ip
.referrer = request.referrer
.approved = Spud::Blog.
.permalink = post_path(@post.url_name)
if .save
if .approved?
flash[:notice] = 'Your comment has been posted.'
else
flash[:notice] = 'Your comment has been saved and will appear after being reviewed by an administrator.'
end
= .new()
end
respond_with do |format|
format.html { render view_for_action 'show' }
end
end
|
#filter ⇒ Object
The sole purpose of this action is to redirect from a POST to an seo-friendly url
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/posts_controller.rb', line 19
def filter
if !params[:category_url_name].blank? && !params[:archive_date].blank?
redirect_to post_category_archive_path(params[:category_url_name], params[:archive_date])
elsif !params[:category_url_name].blank?
redirect_to post_category_path(params[:category_url_name])
elsif !params[:archive_date].blank?
redirect_to post_archive_path(params[:archive_date])
else
redirect_to posts_path
end
end
|
#index ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'app/controllers/posts_controller.rb', line 9
def index
@posts = SpudPost.for_user(current_user).visible.for_blog(params[:blog_key]).ordered.paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
respond_with @posts do |format|
format.html{
render view_for_action('index')
}
end
end
|
#show ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'app/controllers/posts_controller.rb', line 61
def show
if @post.
= .new()
end
respond_with @post do |format|
format.html { render view_for_action 'show' }
end
end
|