Class: Whatson::PostsController
- Inherits:
-
WhatsonController
- Object
- ApplicationController
- WhatsonController
- Whatson::PostsController
- Defined in:
- app/controllers/whatson/posts_controller.rb
Instance Method Summary collapse
Instance Method Details
#archive ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/whatson/posts_controller.rb', line 52 def archive if params[:month].present? date = "#{params[:month]}/#{params[:year]}" @archive_date = Time.parse(date) @date_title = @archive_date.strftime('%B %Y') @whatson_posts = WhatsonPost.live.by_archive(@archive_date).paginate({ :page => params[:page], :per_page => RefinerySetting.find_or_set(:whatson_posts_per_page, 10) }) else date = "01/#{params[:year]}" @archive_date = Time.parse(date) @date_title = @archive_date.strftime('%Y') @whatson_posts = WhatsonPost.live.by_year(@archive_date).paginate({ :page => params[:page], :per_page => RefinerySetting.find_or_set(:whatson_posts_per_page, 10) }) end respond_with (@whatson_posts) end |
#comment ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/whatson/posts_controller.rb', line 29 def comment if (@whatson_comment = @whatson_post.comments.create(params[:whatson_comment])).valid? if WhatsonComment::Moderation.enabled? or @whatson_comment.ham? begin Whatson::CommentMailer.notification(@whatson_comment, request).deliver rescue logger.warn "There was an error delivering a whatson comment notification.\n#{$!}\n" end end if WhatsonComment::Moderation.enabled? flash[:notice] = t('thank_you_moderated', :scope => 'whatson.posts.comments') redirect_to whatson_post_url(params[:id]) else flash[:notice] = t('thank_you', :scope => 'whatson.posts.comments') redirect_to whatson_post_url(params[:id], :anchor => "comment-#{@whatson_comment.to_param}") end else render :action => 'show' end end |
#index ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/controllers/whatson/posts_controller.rb', line 10 def index # Rss feeders are greedy. Let's give them every whatson post instead of paginating. (@whatson_posts = WhatsonPost.live.includes(:comments, :categories).all) if request.format.rss? respond_with (@whatson_posts) do |format| format.html format.rss end end |
#show ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/whatson/posts_controller.rb', line 19 def show @whatson_comment = WhatsonComment.new @canonical = url_for(:locale => ::Refinery::I18n.default_frontend_locale) if canonical? respond_with (@whatson_post) do |format| format.html { present(@whatson_post) } format.js { render :partial => 'post', :layout => false } end end |
#tagged ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'app/controllers/whatson/posts_controller.rb', line 73 def tagged @tag = ActsAsTaggableOn::Tag.find(params[:tag_id]) @tag_name = @tag.name @whatson_posts = WhatsonPost.tagged_with(@tag_name).paginate({ :page => params[:page], :per_page => RefinerySetting.find_or_set(:whatson_posts_per_page, 10) }) end |