Week Beginning 29th January 2018

I spent the majority of this week beginning on the implementation of the front-end for the REELS project.  I’d finished an initial version of my specification document last week and had sent it to the team for comment.  After receiving some feedback and thinking through some issues further myself, I created a slightly revised version and then set to work on the actual development.  As with other recent projects, I decided to create an API for the front-end, so that all querying, whether it comes from server-side PHP scripts or client-side JavaScript files, is handled via the same interface.  It keeps things nice and compartmentalised and ensures the data can easily be returned in different formats and by different systems now and in the future.  I based the API on the one I’d already created for the SCOSYA project, so thankfully I just had to adapt this code for the specific queries required by REELS rather than having to start from scratch.

I began with the implementation of the quick search.  This searches a variety of fields such as place-name and element.  I implemented wildcard searches for single characters using MySQL’s ‘_’ search and beginning, end and middle searches using MySQL’s ‘%’ search, and added in an exact search using double quotes too.  The API can return the results as either JSON or CSV, and with the addition of a few new indexes the queries return data pretty speedily.  I also ensured that data which doesn’t meet the criteria is included in the JSON view of the data, so that I’ll be able to add these as ‘grey spots’ on the map in addition to the actual data.

With an initial end point for the API in place I then decided to begin work on the map interface for the front-end.  As with previous projects, I decided to use Leaflet for the map, as it is a simple, lightweight library with no external dependencies that you can easily install on your own server (unlike Google Maps where everything has to get sent to Google’s servers for processing).  I set Leaflet up with an initial MapBox basemap (which I am still going to work with to improve the interface) and managed to connect the map to the API in order to display the search results.  I then split the results up into different map layers based on the place-name type, and assigned each type a different coloured dot.  Eventually I will replace these with icons, but this was a good first step.  With this in place and the legend visible it then became possible to turn on or off a particular type, for example hiding all of the settlements, or hiding all of the grey dots.  Here’s an example of the map, showing a search for ‘h_ll’ (all names with these characters somewhere in them):

I then updated the API to add in a further endpoint for retrieving the data required for the popup and updated the map to add in popups.  These are AJAX powered – none of the map markers actually includes the content of their pop-ups until the user clicks on the map marker.  At that point an AJAX request is sent and the data is retrieved in JSON format, then formatted by the script and the pop-up is displayed.  If the user clicks to open a popup a second time the system can tell that the popup is already populated and therefore a second AJAX request is not made.  Still lots to do for the project, but I feel that I’ve made really good progress this week.

In addition to REELS I worked for some other projects as well this week.  I made some further updates to the NRECT website for Stuart Gillespie, I provided some information to old colleagues in the DCC about the AHRC’s decision to drop Technical Plans, I performed some App account management duties, which involved setting up a new account for a developer who is working with MVLS, and I made a few corrections to some information on the DSL website.  I also tweaked a couple of fields in The People’s Voice database and updated the way poem titles are ordered in the front-end, basically adding a new ‘order’ field that ignores any non-alphanumeric characters.  I also spent a bit of time investigating why an old website had stopped working.  It turned out that the site (and others) had recently been moved to a new server, and the old website (written more than 15 years ago) used a couple of functions that are no longer supported.  A quick find and replace sorted the issue, but I will still need to address the problem in a couple of other old sites next week.  I had to head home at lunchtime on Friday as I was feeling unwell.