battis.net and I'm all out of bubble gum…

As noted earlier, there is a slick trick for taking a publicly accessible calendar in FirstClass and generating an iCalendar feed. Also noted earlier, the big problem with this feed is that it doesn’t contain timezone information, which makes some calendar systems (most notably Google Calendar) assume that everything is happening at Greenwich Mean Time. Which it usually isn’t. And I have written a PHP script that adds Pacific Timezone information to the iCalendar feed.

Let’s put all this together and take a current FirstClass calendar, make it readable from the web, feed it through the script and then add the result to your calendar program of choice.

  1. Right-click (or control-click, on a Mac) on the calendar in question and Add to Desktop. A second calendar icon will appear, possibly named with the name of whoever’s calendar it is. Possibly not. FirstClass is a mystery.
  2. Drag the new calendar into your Web Publishing folder (on some versions, Web Publishing may be called Home Page Folder — why is this? FirstClass is a mystery.)
  3. At this point you’re faced with a choice: either blithely disregard security, rely on security through obscurity, or be ready to generate a somewhat more aggravating URL to be more (but still not fully) secure.
    1. Disregard security: leave the calendar named whatever it’s currently named. You need to change the permissions (right-click/control-click and choose Permissions) so that All Users has Schedule+Details permissions on the calendar. This will change permissions for not just the copy in the Web Publishing folder, but also for the original calendar — since the “copy” in Web Publishing is just an alias to the original anyway.
    2. Security through obscurity: rename the calendar something else (I usually do this, and use a password generating application to give me a random collection of letters and numbers — e.g. a2612GhxU). Change permissions as described in 3(a) above.
    3. Better security: follow the directions here for generating your URL. Don’t tinker with permissions.
  4. Point a web browser at calendar in your Web Publishing folder, add the iCalendar feed get parameters, and copy that new URL to the clipboard.
  5. Point your web browser your copy of the time zone script and paste the URL you just copied into the Calendar URL field and click Generate.
  6. Copy the new URL that appears below. You can paste that URL into whatever calendaring system you want (that can subscribe to iCalendar feeds).
    1. In Google Calendar, you would Add a new calendar by URL and paste in your URL. (caveat: Google doesn’t seem to be too fantastic about actually updating iCalendar feeds — they allege that this is a sporadic issue, but I have experienced it as more prevalent than sporadic).
    2. In iCal, you would choose Subscribe… from the Calendar menu and paste in your URL.
    3. You could also paste this URL (via some contortions — e.g. email it to yourself and copy-paste from that) into a phone calendar app.

June 14th, 2011

Posted In: How To

Tags: , , , , , ,

This is really just a quick hack: all it does is insert the correct timezone description in the header of an iCalendar feed. But if the server that is generating the iCalendar feed doesn’t do it, someone has to. The script generates a URL that can then be subscribed to by your Calendar reader of choice. (I’m running this on my server and using it daily to good effect, but decline to share bandwidth with the world for this one):

$filename = "calendar";
 
if (isset($_GET["url"]))
{
	$url = $_GET["url"];
 
	if (!isset($_GET["show_url"]))
	{
		preg_match("|.+\/([^?]+)\??|", $url, $matches);
		if (isset ($matches[1]))
		{
			$filename = $matches[1];
		}
 
		$calendar = file_get_contents ($url);
 
		if ($calendar)
		{
 
			//$output = preg_replace_callback ("/(DATE-TIME:)(\d{4,4})(\d{2,2})(\d{2,2})T(\d{2,2})(\d{2,2})(\d{2,2})[^Z]/", "adjustTimeZone", $calendar);
 
			$timezone = "X-WR-TIMEZONE:America/Los_Angeles\n" .
				"CALSCALE:GREGORIAN\n" .
				"BEGIN:VTIMEZONE\n" .
				"TZID:America/Los_Angeles\n" .
				"BEGIN:DAYLIGHT\n" .
				"TZOFFSETFROM:-0800\n" .
				"RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\n" .
				"DTSTART:20070311T020000\n" .
				"TZNAME:PDT\n" .
				"TZOFFSETTO:-0700\n" .
				"END:DAYLIGHT\n" .
				"BEGIN:STANDARD\n" .
				"TZOFFSETFROM:-0700\n" .
				"RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\n" .
				"DTSTART:20071104T020000\n" .
				"TZNAME:PST\n" .
				"TZOFFSETTO:-0800\n" .
				"END:STANDARD\n" .
				"END:VTIMEZONE\n";
 
			$loc = strpos($calendar, "BEGIN:VEVENT");
 
			$output = substr($calendar, 0, $loc) . $timezone . substr($calendar, $loc, strlen($calendar));
 
		    header("Content-Type: text/calendar");
		    header("Content-Disposition: inline; filename=$filename-pacific-timezone.ics");
			echo $output;
			exit;
		}
	}
}
<h1>vCalendar Time Zone timezone</h1>
	<p>This is quick script to "de-float" calendars in the vCalendar format which do not specify time zones for their events. This script will automatically add the Pacific time zone information to the calendar at the URL entered below. Copy-and-paste the resulting URL below into your calendar reader of choice. <a href="http://battis.net/link/timezonescript">The source of this script is freely available.</a></p>
	<form action="<?= $_SERVER["PHP_SELF"] ?>" method="get">
		<input type="hidden" name="show_url" value="" />
		<p>Calendar URL <input name="url" type="text" value="<?= $url ?/>" /></p>
		< ?php
				$newUrl = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"] . "?url=" . urlencode($url);
				echo "<p><a href=\"$newUrl\">$newUrl</a>";
		?>
		<p><input type="submit" value="Generate"/></p>
	</form>

February 14th, 2011

Posted In: How To

Tags: , , ,

One, largely undocumented, trick that I have discovered is that, if one places a calendar where it is accessible from the web, say:

http://www.mchschool.org/~sbattis/1to1workshops1011

that one can then cause FirstClass to generate an iCalendar feed for that calendar by appending the following GET parameters to the URL:

http://www.mchschool.org/~sbattis/1to1workshops1011?plugin=ical&leaves

Clicking this link will either download an iCalendar file or offer to subscribe you to this calendar, depending on your browser settings — right-clicking will allow you to copy-and-paste this link into your Calendar reader’s subscription settings. In fact, with some tinkering, it turns out that the calendar can be in a secured directory and the username and password can be sent through as part of the URL (in a format that I thought I had seen the last of with the decline of Gopher servers):

http://sbattis:supersekretpassword@www.mschschool.org/~sbattis/1to1workshops1011?plugin=ical&leaves

(Nota bene: the above username and password are fake and won’t work — thereby rendering the link inoperable. But you get the idea.)

February 14th, 2011

Posted In: How To

Tags: , , , ,

css.php