Added iCal subscription links.

The feeds page now lists iCal links alongside each RSS and TXT feed link. Copying your chosen link and pasting it in to the text box that appears in iCal when you choose Calendar > Subscribe.. Name your calendar as you wish, but make sure that you get it to refresh periodically and that the 'Remove Todo items' checkbox is UNCHECKED (obviously ;-) ). Then your Tracks next actions should appear as todo items in iCal, with proper due dates assigned, and notes in the notes field. The todos should update periodically in iCal as you add, delete or complete items in Tracks, but the subscription is read-only from iCal's end. However, it does allow you read access on the move if you sync iCal with your Palm or mobile phone.

I don't have Sunbird or any other iCal compatible calendar, but it should work with any of those too, as it follows the [http://www.ietf.org/rfc/rfc2445.txt iCalendar] standard format.



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@221 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2006-04-14 17:07:29 +00:00
parent a2120f6ee1
commit e1cb2b0f29
5 changed files with 63 additions and 2 deletions

View file

@ -34,6 +34,20 @@ class FeedController < ApplicationController
end
@headers["Content-Type"] = "text/plain; charset=utf-8"
end
# Builds an iCal compatible export of uncompleted todos
# so that each action forms a VTODO in your iCal calendar.
# Due dates are supported, and notes are included.
#
def ical
prepare_for_feed
if @params.key?('context')
@contexts = [ @user.contexts.find(@params['context']) ]
else
@contexts = @user.contexts.find_all_by_hide(false, "position ASC")
end
@headers["Content-Type"] = "text/plain; charset=utf-8"
end
protected

View file

@ -121,4 +121,10 @@ module TodoHelper
link_to('<span class="feed">TXT</span>', linkoptions, :title => "Plain text feed" )
end
def ical_feed_link(options = {})
linkoptions = {:controller => 'feed', :action => 'ical', :name => "#{@user.login}", :token => "#{@user.word}"}
linkoptions.merge!(options)
link_to('<span class="feed">iCal</span>', linkoptions, :title => "iCal feed")
end
end

View file

@ -0,0 +1,35 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//rousette.org.uk//Tracks 1.04//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Europe/London
LAST-MODIFIED:<%= Time.now.strftime("%Y%m%dT%H%M%SZ") %>
BEGIN:DAYLIGHT
DTSTART:20060326T020000
TZOFFSETTO:+0100
TZOFFSETFROM:+0000
TZNAME:BST
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20061029T020000
TZOFFSETTO:+0000
TZOFFSETFROM:+0100
TZNAME:GMT
END:STANDARD
END:VTIMEZONE
<% for @todo in @todos -%>
BEGIN:VTODO
DTSTAMP:<%= @todo.created_at.strftime("%Y%m%dT%H%M%SZ") %>
DTSTART;VALUE=DATE:<%= @todo.created_at.strftime("%Y%m%d") %>
SUMMARY:<%= @todo.description %>
<% if @todo.notes? -%>
DESCRIPTION:<%= @todo.notes %>
<% end -%>
<% if @todo.due -%>
DUE;VALUE=DATE:<%= @todo.due.strftime("%Y%m%d") %>
<% end -%>
END:VTODO
<% end -%>
END:VCALENDAR

View file

@ -12,6 +12,7 @@
<dl>
<dt><%= image_tag("feed-icon", :size => "16X16", :border => 0)%></dt><dd>RSS Feed</dd>
<dt><span class="feed">TXT</span></dt><dd>Plain Text Feed</dd>
<dt><span class="feed">iCal</span></dt><dd>iCal feed</dd>
</dl>
<p>Note: All feeds show only actions that have not been marked as done.</p>
</div>
@ -19,21 +20,25 @@
<li>
<%= rss_feed_link({ :limit => 15 }) %>
<%= text_feed_link({ :limit => 15 }) %>
<%= ical_feed_link({ :limit => 15 }) %>
Last 15 actions
</li>
<li>
<%= rss_feed_link %>
<%= text_feed_link %>
<%= ical_feed_link %>
All actions
</li>
<li>
<%= rss_feed_link({ :due => 0 }) %>
<%= text_feed_link({ :due => 0 }) %>
<%= ical_feed_link({ :due => 0 }) %>
Actions due today or earlier
</li>
<li>
<%= rss_feed_link({ :due => 6 }) %>
<%= text_feed_link({ :due => 6 }) %>
<%= ical_feed_link({ :due => 6 }) %>
Actions due in 7 days or earlier
</li>
<li><h4>Feeds for uncompleted actions in a specific context:</h4>
@ -42,6 +47,7 @@
<li>
<%= rss_feed_link({ :context => context }) %>
<%= text_feed_link({ :context => context }) %>
<%= ical_feed_link({ :context => context }) %>
Next actions in <strong><%=h context.name %></strong>
</li>
<% end %>
@ -53,6 +59,7 @@
<li>
<%= rss_feed_link({ :project => project }) %>
<%= text_feed_link({ :project => project }) %>
<%= ical_feed_link({ :project => project }) %>
Next actions for <strong><%=h project.name %></strong>
</li>
<% end %>

View file

@ -50,8 +50,7 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'notes', :controller => 'note', :action => 'index'
# Feed Routes
map.connect 'feed/:action/:name/:token', :controller => 'feed'
map.connect 'feed/:action/:name/:token', :controller => 'feed'
#map.connect 'add_item', :controller => 'todo', :action => 'add_item'