On 30/01/15 16:20, Christophe Siraut wrote: > Hi Daniel, > >> If my proposed solution seems reasonable I'll go ahead and code it >> (...) > > It seems perfectly reasonable to me. I just want to mention that while > we started refactoring DMD in order to provide RSS, YAML and JSON, we > did not finish isolating the data from the presentation. In consequence > you might end up with HTML code in calendar tasks, please fix or fill > bugs if it happens. (There should be no HTML in dmd-data.rb nor in > dmd.cgi; data should be parsed in dmd-data.rb only; dmd.cgi should be a > lot simpler) >
I've done the following: - initial implementation using the feeditems array - requested to join collab-qa on alioth so I can push this, otherwise somebody else can apply it - sent an RT request (#5713) to DSA to install the vpim package on ullmann - updated the wiki to include the extra dependency Please let me know if any other action is needed to get this deployed. There are other potential improvements but they can be made later: - setting the priority field of the VTODO to a higher value for RC bugs, I think the prioritization logic should be somewhere else in the UDD code and the iCalendar code should only translate the UDD priority value into the format for iCalendar (1=High, etc). Is anything like this already available or on the roadmap? - setting the email of the bug reporter as task creator, currently it just uses debian-qa as the creator for all tasks - setting an ID on each task based on the Debian bug ID or some other unique ID (Lightning appears to consume the VTODO feed without any ID being present) - setting the created and modified dates where applicable
>From e8901fd530b344b4b6a24fe0c78a222709417d7d Mon Sep 17 00:00:00 2001 From: Daniel Pocock <dan...@pocock.pro> Date: Sat, 31 Jan 2015 10:47:51 +0100 Subject: [PATCH] Initial iCalendar support. (Closes: #775180) --- web/inc/cal.rb | 32 ++++++++++++++++++++++++++++++++ web/inc/page.rb | 3 +++ web/templates/dmd.erb | 1 + 3 files changed, 36 insertions(+) create mode 100755 web/inc/cal.rb diff --git a/web/inc/cal.rb b/web/inc/cal.rb new file mode 100755 index 0000000..da0d941 --- /dev/null +++ b/web/inc/cal.rb @@ -0,0 +1,32 @@ +#!/usr/bin/ruby +require 'vpim/icalendar' +require 'vpim/vtodo' +require 'date' + +# Note: +# +# Requires the vpim package. +# +# The VTODO support in the Vpim code is not quite as polished +# as the VEVENT support. For example, there is a convenient +# add_event() method for VEVENT but there is no add_todo() +# so we have to create the VTODO using the create() method. +# Rendering of the required VTODO fields appears to work fine. + +class TodoCalendar + def initialize(items, title) + cal = Vpim::Icalendar.create2 + + items.each do |e| + t = Vpim::Icalendar::Vtodo.create( + 'SUMMARY' => e[:title], + 'DESCRIPTION' => e[:title], + 'URL' => e[:link], + 'ORGANIZER' => 'debian-qa@lists.debian.org') + cal.push(t) + end + puts "Content-type: text/calendar\n" + puts "Content-Disposition: attachment; filename=\"dmd.ics\"\n\n" + puts cal.encode + end +end diff --git a/web/inc/page.rb b/web/inc/page.rb index 601d798..45e5842 100644 --- a/web/inc/page.rb +++ b/web/inc/page.rb @@ -3,6 +3,7 @@ require "erb" require 'oj' require 'yaml' require File.expand_path(File.dirname(__FILE__))+'/feed' +require File.expand_path(File.dirname(__FILE__))+'/cal' class Page attr_accessor :data, :format, :template, :title, :feeditems @@ -28,6 +29,8 @@ class Page puts Oj.load(Oj.dump(@data)).to_yaml elsif @format == 'rss' TodoFeed.new(@feeditems, @title) + elsif @format == 'ics' + TodoCalendar.new(@feeditems, @title) else content = File.read(File.expand_path(@template)) t = ERB.new(content) diff --git a/web/templates/dmd.erb b/web/templates/dmd.erb index 559d81c..338d5b7 100644 --- a/web/templates/dmd.erb +++ b/web/templates/dmd.erb @@ -86,6 +86,7 @@ <label><input type='radio' name='format' value='json'/> JSON</label> <label><input type='radio' name='format' value='yaml'/> YAML</label> <label><input type='radio' name='format' value='rss'/> RSS</label> + <label><input type='radio' name='format' value='ics'/> iCalendar</label> </td> </tr> <tr> -- 2.1.4