diff options
author | Peter Karlsson <peterk> | 2002-12-29 16:29:25 +0000 |
---|---|---|
committer | Peter Karlsson <peterk> | 2002-12-29 16:29:25 +0000 |
commit | 72e1154ed24b8ad7ad5cc29a2dfdd8310d6cec41 (patch) | |
tree | 03b80efa7776272a01ddd393771084b6ce898849 | |
parent | 0dc41b7922503d58e884caff8aecf5e55a1f7be7 (diff) |
Generate ICS (Internet Calendar, RFC 2445) files for the Debian events,
using the WML source files as input.
CVS version numbers
remove_stale.pl: 1.9 -> 1.10
english/events/make_ics.pl: INITIAL -> 1.1
english/events/2003/Makefile: 1.1 -> 1.2
english/po/templates.pot: 1.7 -> 1.8
english/template/debian/event.wml: 1.62 -> 1.63
english/template/debian/events_common.wml: 1.32 -> 1.33
swedish/po/templates.sv.po: 1.13 -> 1.14
-rw-r--r-- | english/events/2003/Makefile | 15 | ||||
-rwxr-xr-x | english/events/make_ics.pl | 215 | ||||
-rw-r--r-- | english/po/templates.pot | 4 | ||||
-rw-r--r-- | english/template/debian/event.wml | 3 | ||||
-rw-r--r-- | english/template/debian/events_common.wml | 3 | ||||
-rwxr-xr-x | remove_stale.pl | 26 | ||||
-rw-r--r-- | swedish/po/templates.sv.po | 46 |
7 files changed, 289 insertions, 23 deletions
diff --git a/english/events/2003/Makefile b/english/events/2003/Makefile index aab4477a6a7..59ea464f40f 100644 --- a/english/events/2003/Makefile +++ b/english/events/2003/Makefile @@ -10,7 +10,22 @@ include $(WMLBASE)/Make.lang # Do Not modify the following lines +EVENTFILES := $(wildcard [0-9]*\-*.wml) +ICSFILES := $(EVENTFILES:.wml=.$(LANGUAGE).ics) +DESTICSFILES := $(patsubst %.ics,$(HTMLDIR)/%.ics,$(ICSFILES)) + +all:: $(ICSFILES) + +install:: $(DESTICSFILES) + index.$(LANGUAGE).html: index.wml $(wildcard [0-9]*\-*.wml) $(TEMPLDIR)/template.wml $(TEMPLDIR)/recent_list.wml %.$(LANGUAGE).html: %.wml $(TEMPLDIR)/event.wml $(WML) $(<F) + +%.$(LANGUAGE).ics: %.wml $(ENGLISHSRCDIR)/events/make_ics.pl + $(ENGLISHSRCDIR)/events/make_ics.pl $< $@ + +$(HTMLDIR)/%.ics: %.ics + @echo copying $< to $(HTMLDIR) + -@install -m 644 -p $< $(HTMLDIR) diff --git a/english/events/make_ics.pl b/english/events/make_ics.pl new file mode 100755 index 00000000000..90bd0ab666a --- /dev/null +++ b/english/events/make_ics.pl @@ -0,0 +1,215 @@ +#!/usr/bin/perl -w +# +# This script creates ICS (Internet Calendar, RFC 2445) files for the Debian +# events, using the WML source files as input. +# +# Run this script with the name of the .wml input file and .ics output file +# names as parameters to create the .ics file + +# Originally written 2002-12-29 by Peter Karlsson <peterk@debian.org> +# © Copyright 2002 Software in the public interest, Inc. +# This program is released under the GNU General Public License, v2. + +# $Id$ + +use Time::Local; +use integer; +use POSIX; + +# Check parameters +if ($#ARGV != 1) +{ + die "Usage: $0 input.wml output.lang.ics\n"; +} + +($wmlfile, $icsfile) = @ARGV; + +# Gather data +open INP, $wmlfile or die "Cannot read $wmlfile: $!\n"; + +$abbr = ''; +$pagetitle = ''; +$where = ''; +$startdate = ''; +$enddate = ''; +$coord = ''; +$intro = ''; +$year = ''; + +# Read header +HEADER: while (<INP>) +{ + if (/<define-tag ([^>]+)>(.*)<\/define-tag>/) + { + my ($tag, $data) = ($1, $2); + $data = 'n/a' if $data eq ''; + $abbr = $data, next HEADER if $tag eq 'abbr'; + $pagetitle = $data, next HEADER if $tag eq 'pagetitle'; + $where = $data, next HEADER if $tag eq 'where'; + $startdate = $data, next HEADER if $tag eq 'startdate'; + $enddate = $data, next HEADER if $tag eq 'enddate'; + $coord = $data, next HEADER if $tag eq 'coord'; + $year = $data, next HEADER if $tag eq 'year'; + } + + last HEADER if /<define-tag intro>/; +} + +# Check for sanity +die "No event abbreviation specified\n" if $abbr eq ''; +die "No page title specified\n" if $pagetitle eq ''; +die "No location specified\n" if $where eq ''; +die "No start date specified\n" if $startdate eq ''; +die "Malformed start date: $startdate (must be YYYY-MM-DD)\n" + if $startdate !~ /^\d{4}-\d\d-\d\d$/; +die "No ending date specified\n" if $enddate eq ''; +die "Malformed ending date: $startdate (musg be YYYY-MM-DD)\n" + if $enddate !~ /^\d{4}-\d\d-\d\d$/; +die "No coordinator string specified\n" if $coord eq ''; + +($year, undef) = split /-/, $startdate unless defined $year; + +# Read intro +INTRO: while (<INP>) +{ + last INTRO if m(</define-tag>); # End at end of intro + last INTRO if /<p>/ && $intro ne ''; # End when second paragraph starts + + chomp; + s/^\s+//; # Collapse initial whitespace + $intro .= ' ' if $intro ne ''; # Add whitespace at the end of the string + $intro .= $_; + + last INTRO if /<\/p>/; # End after first paragraph +} +close INP; + +# Get date of source file +(undef, undef, undef, undef, undef, undef, undef, undef, + undef, $mtime, undef, undef, undef) = stat $wmlfile; + +# Kill off HTML code +$coord =~ s/<[^>]+>//g; +$intro =~ s/<[^>]+>//g; + +# Collapse excessive spacing +$intro =~ s/\s{2,}/ /g; + +# Add backslashes in front of commas in the descriptive texts +$intro =~ s/,/\\,/g; +$pagetitle =~ s/,/\\,/g; +$where =~ s/([,;])/\\$1/g; + +# Convert dates into correct representation +$startstring = sprintf("%04d%02d%02dT000000", split(/-/, $startdate)); +$endstring = sprintf("%04d%02d%02dT235959", split(/-/, $enddate)); + +# Figure out the language and encoding of the text, by recursing upwards +# until we find a .wmlrc file +$encoding = ''; +$language = ''; +$wmlrcdir = '.'; +while (! -e $wmlrcdir . '/.wmlrc') +{ + $wmlrcdir .= '/..'; + die "Unable to find .wmlrc file\n" if $wmlrcdir eq ''; +} +open WMLRC, $wmlrcdir . '/.wmlrc' + or die "Unable to read $wmlrcdir/.wmlrc: $!\n"; +RCDATA: while (<WMLRC>) +{ + if (/^-D CHARSET=(.*)$/) + { + $encoding = $1; + last RCDATA if $encoding ne '' && $language ne ''; + } + elsif (/^-D CUR_ISO_LANG=(.*)$/) + { + $language = $1; + last RCDATA if $encoding ne '' && $language ne ''; + } +} +close WMLRC; +die "Unable to find encoding in $wmlrcdir/.wmlrc\n" if $encoding eq ''; +die "Unable to find language in $wmlrcdir/.wmlrc\n" if $language eq ''; + +# Construct the canonic URL to this file +$filebase = $wmlfile; +$filebase =~ s(^.*/([^/]+)$)($1); +$filebase =~ s(^([^/].*)\.wml)($1); +$url = 'http://www.debian.org/events/' . $year . '/' . $filebase . '.' . + $language . '.ics'; + +# Write output +$charsetlanguage = ';CHARSET=' . $encoding . ';LANGUAGE=' . $language; + +open ICS, '>' . $icsfile or die "Cannot create $icsfile: $!\n"; +&calline(ICS, 'BEGIN:VCALENDAR'); +&calline(ICS, 'VERSION:2.0'); +&calline(ICS, 'PRODID:-//Debian//Events//' . uc($language)); +&calline(ICS, 'CALSCALE:GREGORIAN'); # Just for completeness... +&calline(ICS, 'COMMENT:Auto-generated from the Debian Events web pages'); +&calline(ICS, 'BEGIN:VEVENT'); +&calline(ICS, 'UID:' . $abbr . '@events.www.debian.org'); +&calline(ICS, 'URL:' . $url); +&calline(ICS, 'SUMMARY' . $charsetlanguage . ':' . $pagetitle); ### +&calline(ICS, 'DESCRIPTION' . $charsetlanguage . ':' . $pagetitle . ' - ' . $intro); +&calline(ICS, 'CONTACT:' . $coord) unless $coord eq 'none'; +&calline(ICS, 'CLASS:PUBLIC'); +&calline(ICS, 'CATEGORIES:CONFERENCE'); +&calline(ICS, 'X-EPOCAGENDAENTRYTYPE:EVENT'); # My Revo+ adds this on export +&calline(ICS, 'DTSTART:'. $startstring); +&calline(ICS, 'DTEND:' . $endstring); +&calline(ICS, 'TRANSP:TRANSPARENT'); # Can be argued +&calline(ICS, 'LOCATION' . $charsetlanguage . ':' . $where); +&calline(ICS, 'LAST-MODIFIED:' . POSIX::strftime('%Y%m%dT%H%M%SZ', gmtime($mtime))); +&calline(ICS, 'END:VEVENT'); +&calline(ICS, 'END:VCALENDAR'); +close ICS; + +exit 0; + +# Print a calendar line, chopping it up at 75 characters if necessary +sub calline +{ + my ($handle, $line) = @_; + while (length $line > 74) + { + $len = 74; + -- $len while substr($line, $len, 1) eq '\\'; + print $handle substr($line, 0, $len), "\r\n "; + $line = substr($line, $len); + } + print $handle $line, "\r\n"; +} + +__END__ +-- Here are two sample files generated from my Revo+, for a sample event -- + +* Exported by Agenda: +BEGIN:VCALENDAR +VERSION:1.0 +BEGIN:VEVENT +X-EPOCAGENDAENTRYTYPE:EVENT +DESCRIPTION:Debian Test Event +UID:4 +CLASS:PUBLIC +DCREATED:20021229T000000Z +LAST-MODIFIED:20021229T140600Z +DTSTART:20030101T000000Z +DTEND:20030104T000000Z +END:VEVENT +END:VCALENDAR + +* Exported using vCAL: +BEGIN:VCALENDAR +PRODID:-//vCalendar for EPOC +VERSION:1.0 +BEGIN:VEVENT +CATEGORIES:MISCELLANEOUS +DTSTART:20030101T000000 +DTEND:20030103T000000 +SUMMARY:Debian Test Event +PRIORITY:1 +END:VEVENT +END:VCALENDAR diff --git a/english/po/templates.pot b/english/po/templates.pot index 6c4cf3a0d67..cea468b09b4 100644 --- a/english/po/templates.pot +++ b/english/po/templates.pot @@ -217,6 +217,10 @@ msgstr "" msgid "Latest News" msgstr "" +#: ../../english/template/debian/events_common.wml:36 +msgid "Download calendar entry" +msgstr "" + #: ../../english/template/debian/fixes_link.wml:11 msgid "not needed" msgstr "" diff --git a/english/template/debian/event.wml b/english/template/debian/event.wml index 9e5de0548a1..1ea7cb87140 100644 --- a/english/template/debian/event.wml +++ b/english/template/debian/event.wml @@ -22,6 +22,9 @@ else <: if (length ("<infolink/>")) { :> <strong><langinfo/>:</strong> <a href="<infolink/>"><infolink/></a><br /> <: } :> +<: if (<year> >= 2003) { + print qq' <a href="$(WML_SRC_BASENAME).$(CUR_ISO_LANG).ics"><getics></a>\n'; +} :> <hrline/> diff --git a/english/template/debian/events_common.wml b/english/template/debian/events_common.wml index 2baf385a1bb..0dd4ba6865d 100644 --- a/english/template/debian/events_common.wml +++ b/english/template/debian/events_common.wml @@ -32,6 +32,9 @@ <define-tag latestnews whitespace=delete> <gettext>Latest News</gettext> </define-tag> +<define-tag getics whitespace=delete> + <gettext>Download calendar entry</gettext> +</define-tag> # Do NOT translate anything below this point. If you feel something needs to # be modified, write to debian-www list. diff --git a/remove_stale.pl b/remove_stale.pl index 44dc6f040c7..5e5351204a6 100755 --- a/remove_stale.pl +++ b/remove_stale.pl @@ -6,8 +6,8 @@ # a removing a WML file from CVS causes the corresponding HTML file to go # away. -# Written 2001-03-22 by peter karlsson <peterk@debian.org> -# © Copyright 2001 Software in the public interest, Inc. +# Originally written 2001-03-22 by peter karlsson <peterk@debian.org> +# © Copyright 2001-2002 Software in the public interest, Inc. # This program is released under the GNU General Public License, v2. # $Id$ @@ -123,6 +123,12 @@ sub recurse my $installed = $direntry; $installed =~ s(^\./[^/]*/)(../www/); + # Name of corresponding ICS file for events. + my $icslocal = $direntry; + $icslocal =~ s/html$/ics/; + my $icsinstalled = $installed; + $icsinstalled =~ s/html$/ics/; + # Remove or report. if ($opt_d) { @@ -132,6 +138,18 @@ sub recurse unlink $installed or die "Unable to remove $installed: $!\n"; } + if (-f $icsinstalled) + { + print "Removing $icsinstalled\n"; + unlink $icsinstalled + or die "Unable to remove $icsinstalled: $!\n"; + } + if (-f $icslocal) + { + print "Removing $icslocal\n"; + unlink $icslocal + or die "Unable to remove $icslocal: $!\n"; + } print "Removing $direntry\n"; unlink $direntry @@ -143,6 +161,10 @@ sub recurse print " installed file is $installed\n"; print " (does not exist)\n" unless -f $installed; + print " installed ICS file: $icsinstalled\n" + if -f $icsinstalled; + print " local ICS file: $icslocal\n" + if -f $icslocal; } } } diff --git a/swedish/po/templates.sv.po b/swedish/po/templates.sv.po index 0686b727eda..4037f2b4aa3 100644 --- a/swedish/po/templates.sv.po +++ b/swedish/po/templates.sv.po @@ -234,6 +234,10 @@ msgstr "Relaterade länkar" msgid "Latest News" msgstr "Senaste nytt" +#: ../../english/template/debian/events_common.wml:36 +msgid "Download calendar entry" +msgstr "Hämta kalenderpost" + #: ../../english/template/debian/fixes_link.wml:11 msgid "not needed" msgstr "ej nödvändigt" @@ -665,25 +669,16 @@ msgstr "" "Redaktörer för Debian Weekly News är <a href=\"mailto:dwn@debian.org\">%s</" "a>." -#~ msgid "pik" -#~ msgstr "pik" - -#~ msgid "download with pik" -#~ msgstr "hämta med pik" - -#~ msgid "" -#~ "Debian Weekly News is edited by <a href=\"mailto:dwn@debian.org\">Martin " -#~ "'Joey' Schulze</a>." -#~ msgstr "" -#~ "Redaktör för Debian Weekly News är <a href=\"mailto:dwn@debian.org" -#~ "\">Martin \"Joey\" Schulze</a>." +#~ msgid "%0 (dead link)" +#~ msgstr "%0 (död länk)" #~ msgid "" -#~ "Debian Weekly News is edited by <a href=\"mailto:dwn@debian.org" -#~ "\">Yooseong Yang and Martin 'Joey' Schulze</a>." +#~ "Debian Weekly News is edited by <a href=\"mailto:dwn@debian.org\">Joe " +#~ "'Zonker' Brockmeier, Jean-Christophe Helary and Tollef Fog Heen</a>." #~ msgstr "" #~ "Redaktörer för Debian Weekly News är <a href=\"mailto:dwn@debian.org" -#~ "\">Yooseong Yang och Martin \"Joey\" Schulze</a>." +#~ "\">Joe \"Zonker\" Brockmeier, Jean-Christophe Helary och Tollef Fog Heen</" +#~ "a>." #~ msgid "" #~ "Debian Weekly News is edited by <a href=\"mailto:dwn@debian.org\">Joe " @@ -693,12 +688,21 @@ msgstr "" #~ "\">Joe \"Zonker\" Brockmeier och Martin \"Joey\" Schulze</a>." #~ msgid "" -#~ "Debian Weekly News is edited by <a href=\"mailto:dwn@debian.org\">Joe " -#~ "'Zonker' Brockmeier, Jean-Christophe Helary and Tollef Fog Heen</a>." +#~ "Debian Weekly News is edited by <a href=\"mailto:dwn@debian.org" +#~ "\">Yooseong Yang and Martin 'Joey' Schulze</a>." #~ msgstr "" #~ "Redaktörer för Debian Weekly News är <a href=\"mailto:dwn@debian.org" -#~ "\">Joe \"Zonker\" Brockmeier, Jean-Christophe Helary och Tollef Fog Heen</" -#~ "a>." +#~ "\">Yooseong Yang och Martin \"Joey\" Schulze</a>." -#~ msgid "%0 (dead link)" -#~ msgstr "%0 (död länk)" +#~ msgid "" +#~ "Debian Weekly News is edited by <a href=\"mailto:dwn@debian.org\">Martin " +#~ "'Joey' Schulze</a>." +#~ msgstr "" +#~ "Redaktör för Debian Weekly News är <a href=\"mailto:dwn@debian.org" +#~ "\">Martin \"Joey\" Schulze</a>." + +#~ msgid "download with pik" +#~ msgstr "hämta med pik" + +#~ msgid "pik" +#~ msgstr "pik" |