mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-19 16:50:12 +01:00
fix #1078 and document it on the REST_API page
This commit is contained in:
parent
ed2154b94b
commit
174becee81
3 changed files with 67 additions and 23 deletions
|
|
@ -26,7 +26,7 @@ class TodosController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html &render_todos_html
|
format.html &render_todos_html
|
||||||
format.m &render_todos_mobile
|
format.m &render_todos_mobile
|
||||||
format.xml { render :xml => @todos.to_xml( :except => :user_id ) }
|
format.xml { render :xml => @todos.to_xml( *to_xml_params ) }
|
||||||
format.rss &render_rss_feed
|
format.rss &render_rss_feed
|
||||||
format.atom &render_atom_feed
|
format.atom &render_atom_feed
|
||||||
format.text &render_text_feed
|
format.text &render_text_feed
|
||||||
|
|
@ -230,7 +230,7 @@ class TodosController < ApplicationController
|
||||||
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
@return_path=cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||||
render :action => 'show'
|
render :action => 'show'
|
||||||
end
|
end
|
||||||
format.xml { render :xml => @todo.to_xml( :root => 'todo', :except => :user_id, :include => [:tags] ) }
|
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -305,7 +305,7 @@ class TodosController < ApplicationController
|
||||||
end
|
end
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
|
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
|
||||||
format.html do
|
format.html do
|
||||||
if @saved
|
if @saved
|
||||||
# TODO: I think this will work, but can't figure out how to test it
|
# TODO: I think this will work, but can't figure out how to test it
|
||||||
|
|
@ -325,7 +325,7 @@ class TodosController < ApplicationController
|
||||||
@saved = true # cannot determine error
|
@saved = true # cannot determine error
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
|
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
|
||||||
format.html { redirect_to request.referrer}
|
format.html { redirect_to request.referrer}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -345,7 +345,7 @@ class TodosController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js { render :action => :update }
|
format.js { render :action => :update }
|
||||||
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
|
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -385,7 +385,7 @@ class TodosController < ApplicationController
|
||||||
@status_message = t('todos.added_new_project') + ' / ' + @status_message if @new_project_created
|
@status_message = t('todos.added_new_project') + ' / ' + @status_message if @new_project_created
|
||||||
@status_message = t('todos.added_new_context') + ' / ' + @status_message if @new_context_created
|
@status_message = t('todos.added_new_context') + ' / ' + @status_message if @new_context_created
|
||||||
}
|
}
|
||||||
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
|
format.xml { render :xml => @todo.to_xml( *to_xml_params ) }
|
||||||
format.m do
|
format.m do
|
||||||
if @saved
|
if @saved
|
||||||
if cookies[:mobile_url]
|
if cookies[:mobile_url]
|
||||||
|
|
@ -473,6 +473,11 @@ class TodosController < ApplicationController
|
||||||
@done_this_week = get_done_this_week(completed_todos)
|
@done_this_week = get_done_this_week(completed_todos)
|
||||||
@done_this_month = get_done_this_month(completed_todos)
|
@done_this_month = get_done_this_month(completed_todos)
|
||||||
@count = @done_today.size + @done_this_week.size + @done_this_month.size
|
@count = @done_today.size + @done_this_week.size + @done_this_month.size
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.xml { render :xml => completed_todos.to_xml( *to_xml_params ) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_done
|
def all_done
|
||||||
|
|
@ -497,7 +502,7 @@ class TodosController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.m { render :action => 'mobile_list_deferred' }
|
format.m { render :action => 'mobile_list_deferred' }
|
||||||
format.xml { render :xml => @not_done_todos.to_xml( :except => :user_id ) }
|
format.xml { render :xml => @not_done_todos.to_xml( *to_xml_params ) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -687,6 +692,19 @@ class TodosController < ApplicationController
|
||||||
@due_all = current_user.todos.not_completed.are_due.find(:all, :order => "due")
|
@due_all = current_user.todos.not_completed.are_due.find(:all, :order => "due")
|
||||||
render :action => 'calendar', :layout => false, :content_type => Mime::ICS
|
render :action => 'calendar', :layout => false, :content_type => Mime::ICS
|
||||||
}
|
}
|
||||||
|
format.xml {
|
||||||
|
@due_all = current_user.todos.not_completed.are_due.find(:all, :order => "due")
|
||||||
|
render :xml => @due_all.to_xml( *to_xml_params )
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def list_hidden
|
||||||
|
@hidden = current_user.todos.hidden
|
||||||
|
respond_to do |format|
|
||||||
|
format.xml {
|
||||||
|
render :xml => @hidden.to_xml( *to_xml_params )
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -754,6 +772,14 @@ class TodosController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def to_xml_params
|
||||||
|
if params[:limit_fields] == 'index'
|
||||||
|
return [:only => [:id, :created_at, :updated_at, :completed_at] ]
|
||||||
|
else
|
||||||
|
return [:except => :user_id, :include => [:tags] ]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get_todo_from_params
|
def get_todo_from_params
|
||||||
# TODO: this was a :append_before but was removed to tune performance per
|
# TODO: this was a :append_before but was removed to tune performance per
|
||||||
# method. Reconsider re-enabling it
|
# method. Reconsider re-enabling it
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>/todos.xml</li>
|
<li>/todos.xml</li>
|
||||||
<li>/todos/<code>ID</code>.xml</li>
|
<li>/todos/<code>ID</code>.xml</li>
|
||||||
|
<li>/tickler.xml</li>
|
||||||
|
<li>/done.xml</li>
|
||||||
|
<li>/hidden.xml</li>
|
||||||
|
<li>/calendar.xml</li>
|
||||||
<li>/contexts.xml</li>
|
<li>/contexts.xml</li>
|
||||||
<li>/contexts/<code>ID</code>.xml</li>
|
<li>/contexts/<code>ID</code>.xml</li>
|
||||||
<li>/contexts/<code>ID</code>/todos.xml</li>
|
<li>/contexts/<code>ID</code>/todos.xml</li>
|
||||||
|
|
@ -64,6 +68,17 @@
|
||||||
<li>/projects/<code>ID</code>/todos.xml</li>
|
<li>/projects/<code>ID</code>/todos.xml</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<p>For the todo resources (todos, tickler, done, hidden and calendar) you can limit the returned
|
||||||
|
field to <code>ID, created_at, modified_at, completed_at</code> by adding the parameter
|
||||||
|
<code>limit_fields</code> and setting it to <code>index</code>. For example:</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
<code>
|
||||||
|
$ curl -u username:p4ssw0rd -H "Content-Type: text/xml" \
|
||||||
|
<%= home_url %>tickler.xml?limit_fields=index
|
||||||
|
</code>
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h2>Writing to the API</h2>
|
<h2>Writing to the API</h2>
|
||||||
|
|
||||||
<p>The API provides mechanisms for adding, updating and deleting resources using the HTTP methods <code>PUT</code>, <code>POST</code> and <code>DELETE</code> in combination with the content.</p>
|
<p>The API provides mechanisms for adding, updating and deleting resources using the HTTP methods <code>PUT</code>, <code>POST</code> and <code>DELETE</code> in combination with the content.</p>
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,11 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
todos.auto_complete_for_predecessor 'auto_complete_for_predecessor', :action => 'auto_complete_for_predecessor'
|
todos.auto_complete_for_predecessor 'auto_complete_for_predecessor', :action => 'auto_complete_for_predecessor'
|
||||||
|
|
||||||
todos.calendar 'calendar.ics', :action => "calendar", :format => 'ics'
|
todos.calendar 'calendar.ics', :action => "calendar", :format => 'ics'
|
||||||
|
todos.calendar 'calendar.xml', :action => "calendar", :format => 'xml'
|
||||||
todos.calendar 'calendar', :action => "calendar"
|
todos.calendar 'calendar', :action => "calendar"
|
||||||
|
|
||||||
|
todos.hidden 'hidden.xml', :action => "list_hidden", :format => 'xml'
|
||||||
|
|
||||||
todos.mobile 'mobile', :action => "index", :format => 'm'
|
todos.mobile 'mobile', :action => "index", :format => 'm'
|
||||||
todos.mobile_abbrev 'm', :action => "index", :format => 'm'
|
todos.mobile_abbrev 'm', :action => "index", :format => 'm'
|
||||||
todos.mobile_abbrev_new 'm/new', :action => "new", :format => 'm'
|
todos.mobile_abbrev_new 'm/new', :action => "new", :format => 'm'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue