Sha256: a3886b99cb17ad3560f4ab44961547c447f6e6b0d858f16461f267b028a68777

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

# The filters added to this controller will be run for all controllers in the application.
# Likewise will all the methods added be available for all controllers.
class ContentController < ApplicationController
  class ExpiryFilter
    def before(controller)
      @request_time = Time.now
    end

    def after(controller)
       future_article =
         Article.find(:first,
                      :conditions => ['published = ? AND published_at > ?', true, @request_time],
                      :order =>  "published_at ASC" )
       if future_article
         delta = future_article.published_at - Time.now
         controller.response.lifetime = (delta <= 0) ? 0 : delta
       end
    end
  end

  include LoginSystem
  before_filter :setup_themer
  helper :theme

  protected

  # TODO: Make this work for all content.
  def auto_discovery_feed(options = { })
    with_options(options.reverse_merge(:only_path => true)) do |opts|
      @auto_discovery_url_rss = opts.url_for(:format => 'rss')
      @auto_discovery_url_atom = opts.url_for(:format => 'atom')
    end
  end

  def theme_layout
    this_blog.current_theme.layout(self.action_name)
  end

  helper_method :contents
  def contents
    if @articles
      @articles
    elsif @article
      [@article]
    elsif @page
      [@page]
    else
      []
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
typo-5.5 app/controllers/content_controller.rb
typo-5.4.4 app/controllers/content_controller.rb
typo-5.4.3 app/controllers/content_controller.rb
typo-5.4.2 app/controllers/content_controller.rb
typo-5.4.1 app/controllers/content_controller.rb