The contexts controller gets more RESTy. It now supports XML, RSS, ATOM, HTML and plain text views of the contexts list.

Changes include:

    * Update the URL on the Feeds page to use /contexts.rss or /contexts.txt instead of FeedController? link
    * Add created_at and updated_at timestamps to contexts table to support ATOM feeds

    Notes:

    * This will break previous context listing feed subscriptions.
    


git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@423 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-02-04 05:12:19 +00:00
parent 6045a7a986
commit fcab16a5c2
15 changed files with 202 additions and 40 deletions

View file

@ -4,12 +4,29 @@ class ContextsController < ApplicationController
before_filter :init, :except => [:create, :destroy, :order]
before_filter :init_todos, :only => :show
skip_before_filter :login_required, :only => [:index]
prepend_before_filter :login_or_feed_token_required, :only => [:index]
session :off, :only => :index, :if => Proc.new { |req| ['rss','atom','txt'].include?(req.parameters[:format]) }
def index
@page_title = "TRACKS::List Contexts"
respond_to do |wants|
wants.html
wants.xml { render :xml => @contexts.to_xml( :except => :user_id ) }
respond_to do |format|
format.html do
@page_title = "TRACKS::List Contexts"
render
end
format.xml { render :xml => @contexts.to_xml( :except => :user_id ) }
format.rss do
render_rss_feed_for @contexts, :feed => Context.feed_options(@user),
:item => { :description => lambda { |c| c.summary(count_undone_todos(c)) } }
end
format.atom do
render_atom_feed_for @contexts, :feed => Context.feed_options(@user),
:item => { :description => lambda { |c| c.summary(count_undone_todos(c)) },
:author => lambda { |c| nil } }
end
format.text do
render :action => 'index_text', :layout => false, :content_type => Mime::TEXT
end
end
end