Class: PostsController
Instance Method Summary
collapse
#render_post_action
#admin_post_path, #admin_post_preview_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
46
47
48
49
50
51
|
# File 'app/controllers/posts_controller.rb', line 46
def archive
@posts = SpudPost.for_user(current_user).visible.for_blog(params[:blog_key]).from_archive(params[:archive_date]).paginate(page: @page_number, per_page: Spud::Blog.config.posts_per_page)
respond_with @posts do |format|
format.html { render_post_action :index }
end
end
|
#category ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/posts_controller.rb', line 34
def category
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]).ordered.paginate(page: @page_number, per_page: Spud::Blog.config.posts_per_page)
else
redirect_to posts_path
return
end
respond_with @posts do |format|
format.html { render_post_action :index }
end
end
|
#filter ⇒ Object
The sole purpose of this action is to redirect from a POST to an seo-friendly url
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/posts_controller.rb', line 22
def filter
if params[:category_url_name].present? && params[:archive_date].present?
redirect_to post_category_archive_path(params[:category_url_name], params[:archive_date])
elsif params[:category_url_name].present?
redirect_to post_category_path(params[:category_url_name])
elsif params[:archive_date].present?
redirect_to post_archive_path(params[:archive_date])
else
redirect_to posts_path
end
end
|
#index ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/posts_controller.rb', line 11
def index
@posts = SpudPost.for_user(current_user).visible.for_blog(params[:blog_key]).ordered.paginate(page: @page_number, per_page: Spud::Blog.config.posts_per_page)
@posts = @posts.search(params[:search]) if params[:search]
respond_with @posts do |format|
format.html do
render_post_action :index
end
end
end
|
#show ⇒ Object
53
54
55
56
57
|
# File 'app/controllers/posts_controller.rb', line 53
def show
respond_with @post do |format|
format.html { render_post_action :show }
end
end
|