Sha256: 3b410adc985602b15fd6c7bec6d0464dae1f6c9096ad0ed4ab1e4a084eba450c

Contents?: true

Size: 802 Bytes

Versions: 3

Compression:

Stored size: 802 Bytes

Contents

require 'time'

class AtomController < ApplicationController
  layout nil
  caches_page :feed

  def feed
    @posts    = Post.find_all(nil, 'updated_at DESC', @app_config['main']['num_posts'])
    @title    = @app_config['main']['title']
    @subtitle = @app_config['main']['subtitle']
  end

  # +method_missing+ provides the convenient /atom/username URLs to 
  # access a user's feed.  If a non-existent user is passed, it will
  # just return an empty feed.
  def method_missing(method)
    user      = User.find_by_username(method.to_s)
    @title    = user.title
    @subtitle = user.subtitle
    @posts    = user.posts.find_all(nil, 'created_at desc', @app_config['main']['num_posts']) rescue []
    
    render_action 'feed'
    cache_page if ActionController::Base.perform_caching
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
EliteJournal-1.9.400 app/controllers/atom_controller.rb
EliteJournal-1.9.401 app/controllers/atom_controller.rb
EliteJournal-1.9.403 app/controllers/atom_controller.rb