diff -urN redmine.org/app/controllers/application.rb redmine/app/controllers/application.rb --- redmine.org/app/controllers/application.rb 2009-09-07 10:13:31.000000000 +0200 +++ redmine/app/controllers/application.rb 2009-09-04 14:55:52.000000000 +0200 @@ -17,6 +17,7 @@ require 'uri' require 'cgi' +require 'icalendar' class ApplicationController < ActionController::Base layout 'base' @@ -163,6 +164,29 @@ render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml' end +#EDIT +def render_ics(items, options={}) + cal = Icalendar::Calendar.new + items.each { |i| + event = Icalendar::Event.new + event.dtstart = i.start_date + event.dtend = i.due_date + if i.is_a? Issue + event.summary = i.subject + else + event.summary = "V. " + i.name + end + + if !i.description.nil? + event.description = i.description + end + cal.add_event(event) + } + @cal_string = cal.to_ical + render :template => "common/calendar.ics.erb", :layout => false , :content_type => Mime::ICS +end + + def self.accept_key_auth(*actions) actions = actions.flatten.map(&:to_s) write_inheritable_attribute('accept_key_auth_actions', actions) diff -urN redmine.org/app/controllers/issues_controller.rb redmine/app/controllers/issues_controller.rb --- redmine.org/app/controllers/issues_controller.rb 2009-09-07 10:13:31.000000000 +0200 +++ redmine/app/controllers/issues_controller.rb 2009-09-04 14:50:42.000000000 +0200 @@ -366,6 +366,10 @@ retrieve_query if @query.valid? events = [] + #EDIT + if (request.format == Mime::ICS) + @calendar.startdt = @project.created_on.to_s(:db) + end events += Issue.find(:all, :include => [:tracker, :status, :assigned_to, :priority, :project], :conditions => ["(#{@query.statement}) AND ((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] @@ -376,7 +380,12 @@ @calendar.events = events end - render :layout => false if request.xhr? + #render :layout => false if request.xhr? + #EDIT + respond_to do |format| + format.html { render :layout => false if request.xhr? } + format.ics { render_ics(events) } + end end def context_menu diff -urN redmine.org/app/views/common/calendar.ics.erb redmine/app/views/common/calendar.ics.erb --- redmine.org/app/views/common/calendar.ics.erb 1970-01-01 01:00:00.000000000 +0100 +++ redmine/app/views/common/calendar.ics.erb 2009-09-04 14:59:00.000000000 +0200 @@ -0,0 +1 @@ +<%= @cal_string %> diff -urN redmine.org/lib/redmine/helpers/calendar.rb redmine/lib/redmine/helpers/calendar.rb --- redmine.org/lib/redmine/helpers/calendar.rb 2009-09-07 10:13:29.000000000 +0200 +++ redmine/lib/redmine/helpers/calendar.rb 2009-09-04 14:39:59.000000000 +0200 @@ -45,6 +45,10 @@ end end + def startdt=(dt) + @startdt = dt + end + # Sets calendar events def events=(events) @events = events