Class: NewsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- NewsController
- Defined in:
- app/controllers/news_controller.rb
Instance Method Summary collapse
- #archive ⇒ Object
- #category ⇒ Object
-
#filter ⇒ Object
The sole purpose of this action is to redirect from a POST to an seo-friendly url.
- #index ⇒ Object
- #show ⇒ Object
Instance Method Details
#archive ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/news_controller.rb', line 58 def archive if Spud::Core.config.multisite_mode_enabled @posts = SpudPost.public_news_posts(params[:page], Spud::Blog.config.posts_per_page).for_spud_site(current_site_id).from_archive(params[:archive_date]) else @posts = SpudPost.public_news_posts(params[:page], Spud::Blog.config.posts_per_page).from_archive(params[:archive_date]) end respond_with @posts do |format| format.html { render 'index' } end end |
#category ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/news_controller.rb', line 42 def category if @post_category = SpudPostCategory.find_by_url_name(params[:category_url_name]) if Spud::Core.config.multisite_mode_enabled @posts = @post_category.posts_with_children.public_news_posts(params[:page], Spud::Blog.config.posts_per_page).for_spud_site(current_site_id).from_archive(params[:archive_date]) else @posts = @post_category.posts_with_children.public_news_posts(params[:page], Spud::Blog.config.posts_per_page).from_archive(params[:archive_date]) end else redirect_to news_path return end respond_with @posts do |format| format.html { render 'index' } end end |
#filter ⇒ Object
The sole purpose of this action is to redirect from a POST to an seo-friendly url
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/news_controller.rb', line 30 def filter if !params[:category_url_name].blank? && !params[:archive_date].blank? redirect_to news_category_archive_path(params[:category_url_name], params[:archive_date]) elsif !params[:category_url_name].blank? redirect_to news_category_path(params[:category_url_name]) elsif !params[:archive_date].blank? redirect_to news_archive_path(params[:archive_date]) else redirect_to news_path end end |
#index ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/controllers/news_controller.rb', line 21 def index @posts = SpudPost.public_news_posts(params[:page], Spud::Blog.config.posts_per_page) if Spud::Core.config.multisite_mode_enabled @posts = @posts.for_spud_site(current_site_id) end respond_with @posts end |
#show ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/news_controller.rb', line 69 def show @post = SpudPost.find_by_url_name(params[:id]) if @post.blank? || @post.is_private? || (Spud::Core.config.multisite_mode_enabled && !@post.spud_site_ids.include?(current_site_id)) flash[:error] = "Post not found!" redirect_to news_path and return false else respond_with @post end end |