Merge branch 'master' of /users/www/www/

This commit is contained in:
Michael Spang 2008-02-06 13:49:34 -05:00
commit 1f5d04f1c7
7 changed files with 120 additions and 157 deletions

View File

@ -33,7 +33,7 @@ $(OUTDIR)%.atom: %.xml xsl/atom.xsl
$(XSLTPROC) $< $(ROOT)/xsl/atom.xsl $@ $(XSLTARGS) $(XSLTPROC) $< $(ROOT)/xsl/atom.xsl $@ $(XSLTARGS)
$(OUTDIR)%.ics: %.xml $(OUTDIR)%.ics: %.xml
perl scripts/xml2ics.pl $< > $@ $(XSLTPROC) $< $(ROOT)/xsl/ics.xsl $@ $(XSLTARGS)
$(OUTDIR)%.html: %.html $(OUTDIR)%.html: %.html
cp -f $< $@ cp -f $< $@

View File

@ -5,11 +5,27 @@
<!-- Winter 2008 --> <!-- Winter 2008 -->
<eventitem date="2008-01-23" time="5:00 PM" room="TBA" title="Creating Distributed Applications with TIPC"> <eventitem date="2008-02-29" time="5:00 PM" room="TBA" title="Overview of Quantum Computing">
<short>Raymond Laflamme</short>
<abstract><p>
TBA
</p></abstract>
</eventitem>
<eventitem date="2008-02-14" time="TBA" room="TBA" title="CSC Programming Contest 1">
<short>Yes, we know this is Valentine's Day.</short>
<abstract><p>
Details will be released closer to the release date.
</p></abstract>
</eventitem>
<eventitem date="2008-01-23" time="5:00 PM" room="MC 4020" title="Creating Distributed Applications with TIPC">
<short>Elmer Horvath</short>
<abstract><p> <abstract><p>
The problem: coordinating and communicating between multiple processors The problem: coordinating and communicating between multiple processors
in a distributed system (possibly containing heterogeneous elements) in a distributed system (possibly containing heterogeneous elements)
</p><p>
The open source TIPC (transparent interprocess communication) protocol The open source TIPC (transparent interprocess communication) protocol
has been incorporated into the Linux kernel and is available in VxWorks has been incorporated into the Linux kernel and is available in VxWorks
and, soon, other OSes. This emerging protocol has a number of and, soon, other OSes. This emerging protocol has a number of

View File

@ -19,11 +19,8 @@
</p> </p>
<p> <p>
One of our most popular services at the office is providing anybody One of our most popular services at the office is providing anybody
with CD/DVD copies of Free Software and Open Source operating system with <b>free</b> CD/DVD copies of Free Software and Open Source operating
distributions (including, but by no means limited to, Debian GNU/Linux, system distributions.
Mandrake Linux, Red Hat Linux, FreeBSD and NetBSD for various
architectures. The cost is $0.50 per disc at the time of this writing, or
<b>free</b> if you provide your own discs.
</p> </p>
<p> <p>
Another favourite is our $0.50 pop for members. We have a fridge in Another favourite is our $0.50 pop for members. We have a fridge in

View File

@ -1,130 +0,0 @@
#!/usr/bin/perl
use XML::DOM;
use strict;
# get the first element under a node of the given tag
# @param node: node under which to look for elements
# @param tag: the tage to look for
# @return: first element under node with the given tag
sub subvalue($$)
{
my ($class, $tag) = @_;
return value($class->getElementsByTagName($tag)->item(0));
}
# get the node value of the first child of a given node
# @param node: whose child to use
# @return: node value of given node's first child
sub value($)
{
my ($class) = @_;
if (undef == $class) { return undef; }
my $child = $class->getFirstChild();
if (undef == $child) {
return undef;
}
return $child->getNodeValue();
}
print <<END_OF_FILE;
BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:University of Waterloo Computer Science Club
PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
X-WR-RELCALID:3359A191-B19E-4B53-BADC-DFC084FC51C9
X-WR-TIMEZONE:Canada/Eastern
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VTIMEZONE
TZID:Canada/Eastern
LAST-MODIFIED:20060912T200739Z
BEGIN:DAYLIGHT
DTSTART:20060301T070000
TZOFFSETTO:-0400
TZOFFSETFROM:+0000
TZNAME:EDT
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20061029T020000
TZOFFSETTO:-0500
TZOFFSETFROM:-0400
TZNAME:EST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T010000
TZOFFSETTO:-0400
TZOFFSETFROM:-0500
TZNAME:EDT
END:DAYLIGHT
END:VTIMEZONE
END_OF_FILE
my $parser = XML::DOM::Parser->new();
my $doc = $parser->parsefile($ARGV[0]);
my @events = $doc->getElementsByTagName("eventitem");
foreach my $event (@events) {
my $date = $event->getAttribute("date");
my $time = $event->getAttribute("time");
my $talk_title = $event->getAttribute("title");
$talk_title =~ s/[:;,]//g;
my $room = $event->getAttribute("room");
my $short = subvalue($event, "short");
$short =~ s/[:;,]//g;
my $abstract = $event->getElementsByTagName("abstract")->item(0)->toString();
my $ical_date = `date -d"$date" +%Y%m%d`;
chomp $ical_date;
my ($ical_start, $ical_end);
if ($time =~ /(.*)-(.*)/) {
$ical_start = ical_time($1);
$ical_end = ical_time($2);
} else {
$ical_start = ical_time($time);
$ical_end = ical_time("$time + 1 hour");
}
$abstract =~ s/<abstract>//;
$abstract =~ s/<\/abstract>//;
$abstract =~ s/\n/ /sg;
my $ical_abstract = "\"$abstract\"";
sub ical_time {
my ($ds) = @_;
my $d = `date -d"$ds" +\%H\%M\%S`;
chomp $d;
return $d;
}
print <<END_OF_EVENT;
BEGIN:VEVENT
LOCATION:University of Waterloo - $room
DTSTAMP:20060912T200708Z
UID:${ical_date}T${ical_start}\@csclub.uwaterloo.ca
SEQUENCE:11
DTSTART;TZID=Canada/Eastern:${ical_date}T${ical_start}
DTEND;TZID=Canada/Eastern:${ical_date}T${ical_end}
SUMMARY:<a href=http://csclub.uwaterloo.ca>$talk_title</a> -- $short
DESCRIPTION:$ical_abstract
END:VEVENT
END_OF_EVENT
}
print "END:VCALENDAR\n";

View File

@ -1,5 +1,5 @@
#!/usr/bin/python2.4 #!/usr/bin/python
import os, sys, urllib, libxml2, libxslt, ldap, time import os, sys, urllib, libxml2, libxslt, ldap, time, datetime, re, pytz
# #
# globals # globals
@ -24,6 +24,12 @@ cscPositions = {
} }
cscYesNo = { True : 'yes', False : 'no' } cscYesNo = { True : 'yes', False : 'no' }
def xslArgToString(arg):
if type(arg) == type([]):
return libxml2.xmlNode(arg[0]).getContent()
else:
return arg
# #
# cscLdapConnect # cscLdapConnect
# #
@ -35,29 +41,27 @@ def cscLdapConnect():
# #
# csc:encode-for-uri # csc:encode-for-uri
# #
def cscEncodeForUri(ctx, arg): def cscEncodeForUri(ctx, uri):
if type(arg) == type([]): uri = xslArgToString(uri)
arg = libxml2.xmlNode(arg[0]).getContent() return urllib.quote(uri)
return urllib.quote(arg)
# #
# csc:term # csc:term
# #
def cscTerm(ctx, arg): def cscTerm(ctx, date):
if type(arg) == type([]): date = xslArgToString(date)
arg = libxml2.xmlNode(arg[0]).getContent()
try: try:
[year, month, day] = arg.split("-") [year, month, day] = date.split("-")
term = (int(month) - 1) / 4 term = (int(month) - 1) / 4
return cscTerms[term] + " " + year return cscTerms[term] + " " + year
except: except:
print "Invalid term '%s'" % arg print "Invalid date '%s'" % date
raise raise
# #
# csc:member-list # csc:member-list
# #
def cscMemberList(ctx, arg): def cscMemberList(ctx, _):
try: try:
if cscLdap == None: if cscLdap == None:
cscLdapConnect() cscLdapConnect()
@ -83,7 +87,7 @@ def cscMemberList(ctx, arg):
# #
# csc:position-list # csc:position-list
# #
def cscPositionList(ctx, arg): def cscPositionList(ctx, _):
try: try:
if cscLdap == None: if cscLdap == None:
cscLdapConnect() cscLdapConnect()
@ -119,12 +123,48 @@ def cscPositionList(ctx, arg):
print e print e
raise raise
#
# csc:ical-datetime
#
def cscIcalDatetime(ctx, date, time, addmin = "0"):
date = xslArgToString(date)
time = xslArgToString(time)
addmin = int(xslArgToString(addmin))
r = re.search("(\d*)-(\d*)-(\d*)", date)
year, month, day = 0, 0, 0
if r != None:
year, month, day = (int(i) for i in r.groups())
r = re.search("(\d*):(\d*)\s*([apAP])", time)
hour, minute = (0, 0)
if r != None:
hour, minute = (int(i) for i in r.groups()[:2])
hour %= 12 #hour % 12
if r.group(3) in 'pP':
hour += 12
dt = datetime.datetime(year, month, day, hour, minute)
dt = pytz.timezone('Canada/Eastern').localize(dt)
dt += datetime.timedelta(0, 0, 0, 0, addmin)
return dt.astimezone(pytz.utc).strftime("%Y%m%dT%H%M%SZ")
#
# csc:ical-escape
#
def cscIcalEscape(ctx, str):
str = xslArgToString(str)
str = str.replace("\n", " ")
#str = str.replace(":", "")
#str = str.replace(";", "")
#str = str.replace(",", "")
str = re.sub("\s+", " ", str)
str = re.sub("^\s+", "", str)
str = re.sub("\s+$", "", str)
return str
# #
# csc:email # csc:email
# #
def cscEmail(ctx, arg): def cscEmail(ctx, email):
if type(arg) == type([]): email = xslArgToString(email)
str = libxml2.xmlNode(arg[0]).getContent()
return "_EMAIL_TODO_" return "_EMAIL_TODO_"
# #
@ -156,6 +196,8 @@ try:
libxslt.registerExtModuleFunction("term", cscUri, cscTerm) libxslt.registerExtModuleFunction("term", cscUri, cscTerm)
libxslt.registerExtModuleFunction("member-list", cscUri, cscMemberList) libxslt.registerExtModuleFunction("member-list", cscUri, cscMemberList)
libxslt.registerExtModuleFunction("position-list", cscUri, cscPositionList) libxslt.registerExtModuleFunction("position-list", cscUri, cscPositionList)
libxslt.registerExtModuleFunction("ical-datetime", cscUri, cscIcalDatetime)
libxslt.registerExtModuleFunction("ical-escape", cscUri, cscIcalEscape)
libxslt.registerExtModuleFunction("email", cscUri, cscEmail) libxslt.registerExtModuleFunction("email", cscUri, cscEmail)
# parse xml/xslt and apply style-sheet # parse xml/xslt and apply style-sheet
@ -166,4 +208,5 @@ try:
ret = style.saveResultToFilename(outFile, res, 0) ret = style.saveResultToFilename(outFile, res, 0)
except Exception, e: except Exception, e:
print e
sys.exit(1) sys.exit(1)

View File

@ -25,9 +25,7 @@
<tr> <tr>
<td colspan="2">CSClub: <td colspan="2">CSClub:
<a href="http://cacti.csclub.uwaterloo.ca/graph_view.php">More Graphs</a> | <a href="http://cacti.csclub.uwaterloo.ca/graph_view.php">More Graphs</a> |
<a href="http://bittorrent.csclub.uwaterloo.ca/">BitTorrent Tracker</a> | <a href="http://bittorrent.csclub.uwaterloo.ca/">BitTorrent Tracker</a>
<a href="http://csclub.uwaterloo.ca/webalizer">caffeine Webalizer Stats</a> |
<a href="http://mirror.csclub.uwaterloo.ca/webalizer">mirror.csclub Webalizer Stats</a>
</td> </td>
</tr> </tr>
<tr> <tr>

39
xsl/ics.xsl Normal file
View File

@ -0,0 +1,39 @@
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:csc="http://csclub.uwaterloo.ca/xsltproc"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="csc">
<xsl:output method="text" encoding="ISO-8859-1" />
<xsl:template match="//eventdefs">BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:University of Waterloo Computer Science Club
PRODID:-//Apple Computer, Inc//iCal 2.0//EN
X-WR-RELCALID:3359A191-B19E-4B53-BADC-DFC084FC51C9
CALSCALE:GREGORIAN
METHOD:PUBLISH
<xsl:for-each select="eventitem"><xsl:call-template name="eventitem" /></xsl:for-each>
END:VCALENDAR
</xsl:template>
<xsl:template name="eventitem">
<xsl:variable name="room" select="@room" />
<xsl:variable name="start" select="csc:ical-datetime(@date, @time)" />
<xsl:variable name="end" select="csc:ical-datetime(@date, @time, 60)" />
<xsl:variable name="title" select="csc:ical-escape(@title)" />
<xsl:variable name="short" select="csc:ical-escape(string(short))" />
<xsl:variable name="abstract" select="csc:ical-escape(string(abstract))" />
BEGIN:VEVENT
LOCATION:University of Waterloo - <xsl:value-of select="$room" />
DTSTAMP:20060912T200708Z
UID:<xsl:value-of select="$start" />@csclub.uwaterloo.ca
SEQUENCE:11
DTSTART:<xsl:value-of select="$start" />
DTEND:<xsl:value-of select="$end" />
SUMMARY:<xsl:value-of select="$title" /><xsl:if test="$short != ''"> -- <xsl:value-of select="$short" /></xsl:if>
DESCRIPTION:<xsl:value-of select="$abstract" />
END:VEVENT
</xsl:template>
</xsl:stylesheet>