# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /Users/Florian/Dev/RubyProjects/redmine-svn # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: app/controllers/application.rb --- app/controllers/application.rb Base (BASE) +++ app/controllers/application.rb Locally Modified (Based On LOCAL) @@ -22,6 +22,8 @@ include Redmine::MenuManager::MenuController helper Redmine::MenuManager::MenuHelper + require 'icalendar' + REDMINE_SUPPORTED_SCM.each do |scm| require_dependency "repository/#{scm.underscore}" end @@ -155,6 +157,27 @@ render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml' end + 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) Index: app/controllers/projects_controller.rb --- app/controllers/projects_controller.rb Base (BASE) +++ app/controllers/projects_controller.rb Locally Modified (Based On LOCAL) @@ -336,6 +336,9 @@ @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') events = [] + if (request.format == Mime::ICS) + @calendar.startdt = @project.created_on.to_s(:db) + end @project.issues_with_subprojects(@with_subprojects) do events += Issue.find(:all, :include => [:tracker, :status, :assigned_to, :priority, :project], @@ -346,8 +349,11 @@ end @calendar.events = events - render :layout => false if request.xhr? + respond_to do |format| + format.html { render :layout => false if request.xhr? } + format.ics { render_ics(events) } end + end def gantt @trackers = @project.rolled_up_trackers Index: app/views/common/calendar.ics.erb --- app/views/common/calendar.ics.erb Locally New +++ app/views/common/calendar.ics.erb Locally New @@ -0,0 +1 @@ +<%= @cal_string %> \ No newline at end of file Index: app/views/projects/calendar.rhtml --- app/models/query.rb Base (BASE) +++ app/models/query.rb Locally Modified (Based On LOCAL) @@ -227,7 +227,7 @@ <%= image_tag 'arrow_to.png' %>  <%= l(:text_tip_task_end_day) %>
<%= image_tag 'arrow_bw.png' %>  <%= l(:text_tip_task_begin_end_day) %>
+

+ <%= l(:label_export_to) %> + <%= link_to 'iCal', { :format => :ics, :key => User.current.rss_key }, :class => 'feed' %> +

<% content_for :sidebar do %>

<%= l(:label_calendar) %>

Index: lib/redmine/helpers/calendar.rb --- lib/redmine/helpers/calendar.rb Base (BASE) +++ lib/redmine/helpers/calendar.rb Locally Modified (Based On LOCAL) @@ -45,6 +45,10 @@ end end + def startdt=(dt) + @startdt = dt + end + # Sets calendar events def events=(events) @events = events