Class: Gluttonberg::Public::ArticlesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Gluttonberg::Public::ArticlesController
- Defined in:
- app/controllers/gluttonberg/public/articles_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 5 def index @blog = Gluttonberg::Blog.published.first(:conditions => {:slug => params[:blog_id]}, :include => [:articles]) raise ActiveRecord::RecordNotFound.new if @blog.blank? @articles = @blog.articles.published respond_to do |format| format.html format.rss { render :layout => false } end end |
#preview ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 59 def preview @blog = Gluttonberg::Blog.first(:conditions => {:slug => params[:blog_id]}) raise ActiveRecord::RecordNotFound.new if @blog.blank? @article = Gluttonberg::Article.first(:conditions => {:slug => params[:article_id], :blog_id => @blog.id}) @article.load_localization(Locale.where(params[:locale_id]).first) raise ActiveRecord::RecordNotFound.new if @article.blank? render :show end |
#show ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 16 def show @blog = Gluttonberg::Blog.published.first(:conditions => {:slug => params[:blog_id]}) if @blog.blank? @blog = Gluttonberg::Blog.published.first(:conditions => {:previous_slug => params[:blog_id]}) unless @blog.blank? redirect_to blog_article_path(:blog_id => @blog.slug , :id => params[:id]) , :status => 301 return end end raise ActiveRecord::RecordNotFound.new if @blog.blank? @article = Gluttonberg::Article.published.first(:conditions => {:slug => params[:id], :blog_id => @blog.id}) if @article.blank? @article = Gluttonberg::Article.published.first(:conditions => {:previous_slug => params[:id], :blog_id => @blog.id}) unless @article.blank? redirect_to blog_article_path(:blog_id => @blog.slug , :id => @article.slug) , :status => 301 return end end raise ActiveRecord::RecordNotFound.new if @article.blank? @article.load_localization(env['gluttonberg.locale']) @comments = @article.comments.where(:approved => true) @comment = Comment.new(:subscribe_to_comments => true) end |
#tag ⇒ Object
45 46 47 48 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 45 def tag @articles = Article.tagged_with(params[:tag]).includes(:blog).published @tags = Gluttonberg::Article.published.tag_counts_on(:tag) end |
#unsubscribe ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 50 def unsubscribe @subscription = CommentSubscription.find(:first , :conditions => {:reference_hash => params[:reference] }) unless @subscription.blank? @subscription.destroy flash[:notice] = "You are successfully unsubscribe from comments of \"#{@subscription.article.title}\"" redirect_to blog_article_url(@subscription.article.blog.slug, @subscription.article.slug) end end |