Grid Reference Links for oileain.org

An interesting requirement to allow an author to maintain a WordPress page in the same way they always have, while presenting an enhanced version of it to the public.

Like many enthusiastic, Irish sea kayak paddlers, I own a copy of Oieáin – the wonderful book by David Walsh that catalogues almost 600 islands around Ireland’s coastline, as well as many points along the mainland between them. The book is available online at oileain.org, which is a WordPress site, both as a HTML page and a PDF download.

I was inspired by David’s generosity in making available for free what he has worked long and hard on for many years (and also sells through the website), so I got in touch with him to suggest that I could enhance the HTML version of the book’s text by turning the plain-text grid references into links that take visitors to a mapping service with the point highlighted. This was something I had considered doing locally just for myself, using a browser plugin script, but I thought if I was considering doing the work anyway, why not see if the author was interested in it? This would be a free service to David, in the same spirit as the website. I was delighted when he indicated he was open to the idea, and I got to work.

In the end, it took a long time between starting discussion and the project being completed. David decided to review all the grid references in the book prior to this new feature going live. That’s almost 1,600 references that had to be checked manually against a map, and it took almost five months to complete – a lot more work for him than for me!

We discussed a number of options in relation to how the automation of “linkifying” the grid references would work. One option was simply to add some javascript to the site that would identify the links based on a regular expression, then replace them with links to https://irish.gridreferencefinder.com/; the mapping service I had identified as being easily usable with the grid references. I wasn’t too keen on the idea as the text is long and I didn’t want to do anything to slow the page load down.

We I agreed that I would write a plugin that made the required changes in the WordPress database. The solution was to keep a shadow copy of the book’s text page every time it is saved. David can make any edits to the source document and when it is saved, the plugin writes the updated text to the shadow copy, transforming the grid references into links in the process. When visitors view the page, the shadow copy is loaded in the content section, replacing the source document’s content.

The coding solution for this is very simple, but I really enjoyed the process of working with David to figure out what would work best for him. Solving the problem in such a way that nothing had changed for his process as an author – not even visually – felt like a great result and he was very happy with it.

You can read Oileáin here.