Jun 08 2005

non-us.debian.org

At work we’ve got a load of Mepis installs, and attempting to apt-get update for the last couple of days has failed from the non-us.debian.org respositories with the error “Unable to fetch file, server said ‘unable to open file. ‘”.

Now I’m quite new to Debian-based distros (I learned on and still use Slackware for the most part) but this is obviously some kind of server issue (I’ve updated before without problems). Thankfully there’s a list of mirrors available at the Debian website and ftp.uk.debian.org/debian-non-us works fine. Maybe I’ll do a bit of digging when I’ve got the time.

Update

Solved: sounds this is due to non-us being obsoleted with the release two days ago of Debian 3.1. I assume the mirrors have yet to catch up.

Jun 07 2005

Javascript mailto links

I generate the mailto: link on my contact page using javascript. The intention is to make my address less visible to address-harvesting web crawlers. I have no idea how effective this is, but as I had never written any javascript before it seemed like a nice simple project to start with.

The function looks for elements with id attributes matching its argument list. For the script to make sense these elements should be anchor tags without href attributes. It replaces their contents with a link of the form argument@domain (domain should be set to something appropriate inside the script), so the original content of the tags should be the text to be displayed to user-agents that do not support javascript, so something like this: user [at] example [dot] com, perhaps.

/*
 * Copyright 2005, Sam Pearson 
 *
 * Available under the terms of the GNU Public License:
 * http://www.gnu.org/copyleft/gpl.html
 *
 */

function write_mailto_links() {
  var at = '@';
  var domain = 'sgp.me.uk';
  for  ( var i = 0 ; i < arguments.length; i++ ) {
    var user = arguments[i];
    var linktext = document.createTextNode( user + at + domain );
    if ( document.getElementById( user ) ) {
      var mlink = document.getElementById( user );
      var oldtext = mlink.firstChild;
      mlink.setAttribute('href', "mailto:" + user + at + domain);
      mlink.replaceChild( linktext, oldtext );
    }
  }
}

I'm sure that there's a better way to do this, but this works so I'm using it for the time being. I'd like to play around a bit more with javascript, but for various reasons I haven't had the time recently. Any feedback is appreciated.

Jun 06 2005

Technical Notes

This website is constructed with the help of Apache, Blosxom (with several plugins), a bit of javascript and Web Standards. It is very much a work in progress, but then point me to a weblog that isn’t. Here are some notes on the techniques used here.

Apache tricks

I use a couple of simple .htaccess tricks to help create more human-friendly URLs. Most of these hacks use mod_rewrite, and none are particularly esoteric. The comments in the following extract from the site-wide .htaccess should explain what’s going on:

# This little trick allows me to rename the blosxom
# script from the cumbersome script.cgi format to
# something simpler (in this case, 'sam'):

  SetHandler cgi-script

# Rewrite rules:
RewriteEngine On

# As I prefer to use just 'sgp.me.uk' as the base
# domain, this rule redirects requests for
# 'www.sgp.me.uk'.  This both allows the use of the
# 'www.' prefix while hopefully encouraging people
# not to use it by visibly redirecting rather than
# simply rewriting.
RewriteCond %{HTTP_HOST} ^www\.sgp\.me\.uk$ [NC]
RewriteRule ^(.*)$ http://sgp.me.uk/$1 [R=301,L]

# Pages devoted to baby photos have been integrated
# into my blog. This rule preserves the old
# hierarchy and provides me with a really simple
# URL to point family to for these photos:
RewriteRule ^uma(.*)$ /sam/uma$1

# I liked the idea of losing the required
# 'index.$flavour' suffixes for rss feeds:
RewriteRule ^sam(.*)/rss$ /sam$1/index.rss
RewriteRule ^sam(.*)/rdf$ /sam$1/index.rdf

Blosxom configuration

The site uses Blosxom 2.0. The script has been slightly modified to remove the code used to escape HTML when outputting RSS (see this post for more information on this and a patch). I also use the following plugins, some of which I wrote myself:

Standards

The website is designed to be accessible in all of the major browsers (having said that, it does render best in Firefox because of -moz-border-radius). It uses vaguely semantic HTML for structure and CSS for layout. The HTML template is written to validate against the XHTML 1.0 Strict Doctype, and the xhtmlmime plugin means that non-well-formed entries quickly get picked up. The RSS feeds are all validated against the Feed Validator from time to time.

To do

  • application/xhtml+xmldone!
  • Sort out some better page titlesdone!
  • Comments/Writebacks
  • Tags (think del.icio.us). Probably implement this using a hacked version of the meta plugin
  • Atom feed, once the spec is finaliseddone!
  • More stuff as I think of it
  • Oh yeah, actually post some real content
Jun 06 2005

Blosxom and application/xhtml+xml

Since this website is written to the XHTML 1.0 Strict Doctype, I thought it would be nice to serve it with the correct MIME type to conforming user-agents. I remembered hearing about a plugin called xhtml that would do this, but after a cursory search came up with nothing I decided that I’d just write my own.

So here’s xhtmlmime. It uses CGI.pm to sniff the Accept: HTTP header from the user-agent and then serves blosxom with the preferred MIME type. There are two variables that need to be set:

  • $flavours needs to be set to a list of flavours upon which to act. This defaults to empty, and the plugin will exit quietly until you set it.
  • $charset should be set to the character encoding used on your weblog. This defaults to utf-8.

You can force the plugin to send the application/xhtml+xml MIME type by specifying a URL parameter of mime=xhtml. Setting mime to anything else will result in the user getting text/html.

Update 2005-07-21

The plugin now exports a variable – $xhtmlmime::meta_http_equiv – for use in your head templates. If you use the http-equiv element, set it as follows:

And the plugin will ensure that it is set correctly.

Warning

As noted by Bill Lovett, serving as application/xhtml+xml raises a couple of issues. The most important one is that this will lead to very strict interpretation of your pages by the web browser, so unless your pages are well-formed – contain no mistakes in the markup – your visitors will just get error messages! Bad plugin!

So, before using this plugin you need to be confident that this is the case, and that you have some method for ensuring that only well-formed, valid markup ends up on your pages.

Feedback

If you have any feedback, either contact me directly or post a message to the blosxom mailing list.

Jun 05 2005

Uma Update 1

Back due to popular demand :-)

25th May

Kicking! Those little legs are a lot stronger than they look.

alt="[Uma sitting up in her car seat looking into the camera]"
class="portrait-photo"
id="u3108"/>

2nd June

She’s quite noticably more alert these days:

alt="[Uma sitting up in her car seat looking into the camera]"
class="portrait-photo"
id="u3118"/>
Jun 05 2005

Uma Jane Pearson (ObBabyPictures)

I’ll be using this part of the website to post further pictures, so if you are interested either drop by from time to time or subscribe to one of the RSS feeds available: RSS 1 or RSS 2.

Here are the first pictures of Uma:

Just after the birth

Born on the 4th April 2005 at 05:21 BST, Uma weighed 7lbs 8oz. These photos were taken just after she’d been cleaned up and put into her cot for the first time, around an hour or so after the birth.

alt="[Uma Jane Pearson 1]"
class="landscape-photo"
id="u2943" />

alt="[Uma Jane Pearson 2]"
class="landscape-photo"
id="u2953" />

First trip in the car

7th April. Suit by Jacqui.

alt="[Uma in the car seat]"
class="portrait-photo"
id="u2983" />

8th April

Hat by Great Auntie Gillian:

alt="[Uma wearing Gillian's hat]"
class="portrait-photo"
id="u2989" />

Forward planning by Great Auntie Bettine (suit for ages 6-9 months):

alt="[Uma lying on a padded coat several sizes too big]"
class="portrait-photo"
id="u2988" />

WordPress Themes