Sha256: b873faa3d7f1dce1240c6d0ba767fac42d8474c4641bf0a8ad3ebbfd0cac4ce2

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

class ArticlesController < ApplicationController
  unloadable
  
  def index
    @page_title = 'Articles'
    if params[:category_id]
      @category = Category.find_by_permalink(params[:category_id])
      @page_title << " in category #{@category.title}"
    end
    if params[:tag]
      @page_title << " tagged with '#{params[:tag]}'"
    end
    if params[:permalink]
      @user = User.find_by_permalink(params[:permalink])
      @page_title << " writen by #{@user.name}"
    end
    if params[:year]
      @page_title << " from #{params[:day]} #{Date::MONTHNAMES[params[:month].to_i] unless params[:month].nil?} #{params[:year]}"
    end
    
    @articles = Article.in_time_delta( params[:year], params[:month], params[:day] ).published.tagged_with(params[:tag], :on => :tags).authored_by(@user).categorised(@category).paginate( :page => params[:page], :per_page => params[:per_page] || Article.per_page, :include => [:created_by] )
    
    @tags = Article.published.authored_by(@user).categorised(@category).tag_counts(:limit => 20)
    
    respond_to do |format|
      format.html # index.html.erb
      format.xml { render :xml => @articles }
      format.json { render :json => @articles }
      format.rss 
      format.js 
    end
  end

  def show
    @article = Article.published.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
    
    @page_title = @article.title
    @page_description = @article.description
    @page_keywords = @article.tag_list
    
    @tags = @article.tag_counts
    
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @article }
    end
  end
  
  def preview
    @page_class = 'show'
    @article = Article.new(session[:article_preview])
    @article.id = 0
    @article.published_at = Time.now
    @article.created_by = current_user
    @article.permalink = 'preview'
    session[:article_preview] = nil
    render :action => "show"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
beef-articles-0.3.34 app/controllers/articles_controller.rb
beef-articles-0.4.5 app/controllers/articles_controller.rb
beef-articles-0.4.4 app/controllers/articles_controller.rb
beef-articles-0.4.3 app/controllers/articles_controller.rb
beef-articles-0.4.2 app/controllers/articles_controller.rb
beef-articles-0.4.1 app/controllers/articles_controller.rb
beef-articles-0.4.0 app/controllers/articles_controller.rb
beef-articles-0.3.35 app/controllers/articles_controller.rb