Replacing legacy web galleries while preserving links

Back in 2002 my friend, Kyle, wrote an easy to use image gallery in PHP called “phish”. It was so good that many other people on the same web server used it on their own site, and since we were all sharing a single student webserver, deploying it was a matter of copying the files from his (world-readable) home directory to your own, and he kindly licensed the code under the GPL to allow us to do that.

Twenty years later phish was, until yesterday, still being used to display the older photographs on this website. The original code was written for PHP version 4, and over the years I had made minor fixes to keep it running on modern versions. These were published on GitHub to ensure I was complying with the original licence.

The PHP language keeps moving forward and the challenge of keeping such old code working meant I had been considering for some time how to modernise these older galleries. I evaluated a few options before settling on sigal as being the simplest to use, but then hit the problem of how to preserve my incoming links. The disadvantage of running your own software may be keeping up with maintenance, but the advantage is the control it gives you when it comes to replacement. In this case, I was able to replace the phish index.php with a new script which calculates the new location of the piece of content your web browser has requested and seamlessly redirects you. Having tested all the links I could find within my own site, it seems to work pretty well but please do let me know if you spot any problems.

So what about the next migration? Sigal generates static webpages rather than creating them on-the-fly for each request but the gallery theme (photoswipe) uses Javascript and CSS to display the images and provide the navigation. In the short term I hope that sigal will continue to be maintained by its author so I do not need to do the maintenance work. Longer term, whilst I currently have no experience with Javascript, I hope I can learn enough in the future to perform the same redirection trick for its gallery parameters (the #&gid=1&pid=3 after index.html) when the time comes.

Thanks for reading and you can now visit the new (old) galleries.

Return to Taronga Zoo

After an amazing trip to Taronga Zoo on our last visit to Sydney I was a little unsure about returning this time in case the magic failed to repeat itself. What I had forgotten is that, (a) the children love animals and (b) they are 4 years older and thus were engaged in completely different ways to before. As a result, it was a fantastic outing for all, and likely one of the highlights of the holiday. Fewer photographs of animals this time as keeping up with excited, enthusiastic children (and later, carrying very tired children) took all my time!

Synchronisation woes with macOS Signatures

This blog post applies to macOS 12 (Monterey), other versions may differ.

It used to be that setting up a new computer involved the difficult choice of spending hours tweaking settings and trying to remember what arcane incantations were required to obtain the perfect setup, or cloning your old computer and importing years of cruft which quickly removed much of the sheen and speed. To its credit, Apple have been quietly chipping away at the configuration synchronisation for many years now, with Mail settings such as accounts, signatures and rules magically appearing on a new machine when you set it up. Typical of Apple’s slow-but-steady approach, it turns out that for Mail this is actually achieved via iCloud Drive so it is to some extent controllable via the toggle in Preferences➡Apple ID➡iCloud Drive➡Mail.

One reason that developers shy away from synchronisation is that it is a feature fraught with edge cases that make it deceptively hard to do reliably, and unreliable synchronisation is worse than none, at best leading to head scratching frustration and worse, loss of data. This was illustrated to me when my email signatures were failing to appear on a newly configured Mac. I was happy to import them manually but locating the correct place to put them was hard to track down, and iCloud Drive synchronisation meant that it took many attempts to get everything working.

The symptom of the problem was that all my accounts were showing up with 0 signatures. Moreover when I added one manually, it would disappear as soon as I quit Mail. iCloud Drive appeared to be working correctly, with all my other files present. In hindsight I suspect the download process was stuck but iCloud remains frustratingly opaque to troubleshoot and when even a reboot could not persuade the missing files to appear, it was time to attempt surgery.

Confusingly, Mail configuration is stored in multiple places. After much trial and error, my conclusion is that the iCloud synchronised files live in Library/Mobile\ Documents/com\~apple\~mail/Data/V4/Signatures/ (all paths relative to your home directory unless otherwise stated). However adding files to this directory did not fix the problem and at one point I tried deleting this directory and that deletion synchronised to another computer–be warned ⚠️ (Thank goodness for Time Machine backups.)

I was finally able to make signatures work again on the errant Mac by shutting down Mail, and then adding them to Library/Mail/V9/MailData/Signatures/. I believe I also disabled Mail in iCloud Drive but then I restored it afterwards and it did not complain. However on the second Mac where iCloud Drive copied down bad data, any files added to Library/Mail/V9/MailData/Signatures/ were removed the next time Mail started if Mail was enabled in iCloud Drive. Trying to convince iCloud this was a file newer than the server copy by editing the .plist file did not work. This was eventually fixed by copying the contents of Library/Mail/V9/MailData/Signatures/ to Library/Mobile\ Documents/com\~apple\~mail/Data/V4/Signatures/ and re-enabling Mail in iCloud Drive.

And so our tale of synchronisation woe has a happy ending. Credit to Apple for continuing to use text files for configuration, the ability to manipulate these via the terminal and easily restore them from a Time Machine backup were crucial to the successful outcome.