Badges On Eleventy – Stage Two or The Great Escape

Having successfully created an initial javascript powered badges page for my website I wanted to move towards creating a more permanent solution.

So I decided to set up a new Eleventy project and copy over the badge related stuff. This was slightly complicated by the fact that the day I decided to do this was the day Eleventy version 3.0 was released. I’d been thinking about trying it out anyway, so this seemed like a good opportunity. So I switched most of my code over to ESM modules without any difficulty. The only ones that gave me any trouble were the CSP generation files, and I’d copied those from somewhere else, so I initially took the easy way out and let them stay as they were (making them .cjs files). Now I had a working project it was time to generate a real website.

Originally I had assumed that I would copy the URL structure from WordPress thus giving me the option of setting up page by page redirection, however that would mean paying WordPress money and after recent events I felt pretty disinclined to do that, plus paying them to leave felt pretty ridiculous.

So I had free reign to design a new scheme. So I decided on a simple structure
• /badges/badge-number/badge-title for the badges themselves as the date on which they were posted is largely irrelevant (and badge title is not always unique).
• /categories/category-name for categories
• /tags/tag-name for tags
• / for the main page

I started with the individual badge pages. I’d already written code to pull in tags and categories from WordPress at build time, so fetching the data was simple and creating a page from a data object is straightforward.

At this point though the complications multiplied.
I needed to create a ‘processed’ version of the badge data. WordPress provides the title and content as rendered HTML. It also throws in extra non breaking spaces into the title (presumably to prevent orphaned words) but in my masonry view l realised they had to go, as did the escaped characters which were spoiling the title slug (the he library was my friend here).
I wanted each badge to be identified by its collection number which wasn’t data WordPress knew, other than I’ve named all the badge images consistently. Time for a regular expression to retrieve it.
Similarly I wanted a very specific excerpt which needed several regular expressions to create.
The tags and categories come back from WordPress as numeric ids but I needed to look up the names and (worse than that) the names had also been rendered into HTML so again I need to decode them so that they could be used by slugify to generate a link.

(Yes, I’m going to have to rewrite a lot of this when I have static local data).

Now I had badge pages, I could move on. The sidebar links were next as it merely needed the links directing to my pages rather than WordPress.

(I skipped doing the search at this point, we’ll come back to that later).

Once I had some page pages built from data, it was time to move onto the tags and categories. These two things are basically the same, for each I wanted a page with a list of badges. In some cases though there are a lot of badges (the badge category is actually everything), so it was going to need paginating.

For the badge pages I simply used Eleventy pagination with a page size of one. For tags and categories though I wanted pagination for each individual tag, the ‘double pagination problem’. This requires creating a collection (in my case from the badges data) indexed by both tag (or category) and page number. This site was incredibly helpful in giving me an approach to follow.

I discovered a few interesting things (mostly by accident) here:

  • You can create a collection of pages that are generated from data. You need to set.
    pagination:
      data: badges
      addAllPagesToCollections: true

    in the front matter and then you can do

    collection.getFilteredByGlob('**/badge.njk');
  • You can create a collection from your global data directly using
    collection.getAll()[0].data.badges

I wanted to use the former method basing the collection on the pages but I couldn’t work out how to access the badge data for each one. So I used the latter. Then I built a double collection and created pages from that. I added next and previous buttons so all the badges for a category (or tag) could be viewed.

Javascript or no Javascript

Given that I had built this whole thing already in a single page you might be wondering why I went through all that (I certainly was). I had decided I wanted the pagination to work without javascript and only if javascript was on I would replace it with progressive loading.

I’d already written the progressive loading logic in my one page version, all I needed was something to progressively load. For this I created a second template for each category, tag and the index that output json instead of HTML. The trickiest bit was generating valid json containing my HTML excerpt string that I needed for each card. The solution here was to use filters in my template

{
"excerpt" : {{ badge.excerpt | dump | safe}}
}

did the trick. I had to add a little bit more code to handle switching over to progressive loading gracefully and I was done (except of course for a lack of search).

So now I have a working and deployable site. Cue cheering.

At this point I took the time to revisit the CSP generation, as it was pretty slow over the ~1500 pages I now had. I realised that the code I had copied used the JSDOM library and found a similar library, linkedom, which ran significantly faster. Rewriting my code slightly gave me the impetus to convert it into module format as well.

Searching

Being able to search my badges is incredibly important to me. After all the lack of a search box on my main WordPress page was one of the things that triggered all this.

I had been recommended PageFind as a search engine. The documentation made it sound ridiculously easy. Mark up your html, point PageFind at it and go!
At one level it was; in only a few minutes I had a searchable site. I created a search box in the sidebar to take you to a search results page to run the requested search and it felt nearly done.

The tricky bit now was that I wanted the search page to display the same badge cards as the rest of the site.

PageFind is set up to index html pages, and it extracts the text it finds and offers this up as search results. I wanted the same excerpt as elsewhere and that contains a table. Luckily PageFind allows you to add your own metadata to indexed content.

I added an attribute in my page to contain my excerpt but now I needed to insert html containing quote marks into an attribute string. Javascript escape function to the rescue. Creating an Eleventy filter to call that function provided a valid string.
Then my search javascript can unescape the metadata before displaying it. This all feels incredibly clunky and it is possible there’s a better way that I’ve missed but for now I have a search that works.

Creating a static site from WordPress has mostly involved a lot of escaping data in one way or another. I have a sneaking suspicion that the next stage of this project will involve a lot of rewriting, but this stage is done for now.

 

Badges On Eleventy

As you may have noticed I actually have two blogs, this one (obviously) and my badge blog. The badge blog acts as a reference to all my badges and is primarily to enable me to easily find out what badges I have on a specific topic.

I rather like:
• The masonry layout for displaying posts
• Progressively loading posts into the same page (rather than navigating to separate pages)
• The ability to search for badges from the sidebar

There are a few things that I am less happy about though:
• The main page doesn’t have a sidebar so doesn’t have a search link (and I can’t add it to the menu instead).
• Search results don’t show an image of the badge.
• WordPress in general have made the editing experience less enjoyable over time and generally nerfed things in a variety of ways.

In fact as well as editing on WordPress being increasingly difficult, it now seems impossible to pick any kind of modern theme and customise it without paying them money. So maybe I can do better. And because I’m busy, maybe I can improve things in stages, so I don’t have to recreate the entire blog all at once.

It turns out WordPress actually have a really good API which will serve public WordPress content (and private content if you log in but I don’t need that).
So my theoretical plan* is as follows :
• Create a single page with javascript to fetch and display badges (by category, tag or search) direct from WordPress via the API. This will give me a chance to play with layouts and functionality.
• Create a full blown site with pages/data pulling in the data from WordPress at build time (and allowing the pages to pull from that site).
• Work out what to do about blog comments (!)
• Export the content from WordPress into my site (so I can turn off WordPress).

This post details the first stage. As this is an experiment, I have decided to host a single page on my website to act as a front end. Eventually I will need to decide what URL the badges should live at, but for now this is fine.

Firstly I needed to extend my Content Security Policy to allow resources from WordPress. I took advantage of this to make the CSP policy configurable (and set a default for most pages) in the base layout file. Then I created a second CSP which includes WordPress.

I wanted a side bar to display search, categories and tags. Since I have over five hundred badges, the categories and tags aren’t going to change much so I can pull them in as static content (although I realise the post counts will get out of date). This gave me a chance to use the Eleventy Fetch plugin and play with creating the categories list and a tag cloud from the javascript data file.

The list of posts can be dynamically pulled from WordPress via javascript. There are parameters to choose the page size. I chose twelve, of course, because that will produce (roughly) even columns for the most number of columns (without loading them in sixties). There are also parameters to restrict the fields pulled back, so I can limit the data to id, title, link and content. There’s a little bit of jiggery pokery needed (a regexp) to handle the occasional ‘more’ tag in a post, but with very little effort we have a grid layout of posts, fetched by most recent, tag, category or search. The API also provides the total available number of posts in a header, so rather than having automatic infinite scroll, I have added a ‘more’ button to pull them down a page at a time.
At this point, it feels like I should be done. But I am rather attached to the masonry layout, although (I realise) less attached to the floaty animation WordPress does when it rearranges the posts. There are a variety of techniques to do masonry layouts, and I’ve considered several of them, but in the end I decided to keep it simple and go with an approach based on using a grid layout. The basic premise is that you adjust your grid layout by pulling items up (using top margin) to fill in the gaps. Given that my badges all have roughly the same length I feel this is good enough, but it does technically mean the badges won’t strictly be listed going down the page as they will always stay in their column regardless.

The result is a page that gives me a better search experience and has been a lot of fun to create. It might need some tweaking still, so I’ll try it out for a bit and who knows eventually I might move on to the next stage.

*I might stop at any point, who knows, or even refine the plan further.

 

My Eleventy – One Website In

Okay, so the title of this blog was chosen deliberately. And yes, a long time familiarity with hobbits was enough to make me interested in Eleventy just for the name.

I have been wanting to revamp various parts of my online presence for a while, and I have been looking for ways to do that which wouldn’t leave me with a huge maintenance headache. I already have enough things to maintain. So a static website is an attractive option. But equally I didn’t want to give up the templating advantages that I get with something like PHP.

But life is busy, so I hadn’t got around to it yet.

Then my daughter needed a website. Nothing complicated, just a place to list projects she’s worked on and for people to find her. Eleventy seemed like a perfect fit. It would allow me to extract common styling and layout and build a simple site, while keeping the content pages easy to manage and update. And it would create something which would be easy to move in the future.

The Eleventy documentation comes with lists of ‘starter projects’ but each one is basically someone’s website with the content pulled out. They reflect the technology choices of that individual. I figured that not only would they not necessarily align with my preferences but also I wouldn’t really understand how it had gone together and that would make extending it harder in the future. So I started from scratch.

With Eleventy you could write complete html by hand, but the advantage of using it is pulling out common functionality. It’s very much down to the author what that is. I found the following useful.

  • Image plugin This processes images to create responsive images and allows for webp images with a fallback to the original format. For the images I also pulled out some metadata into a file, so I could build a credits list of the photographs.
  • For the menu I started with a data file but then realised the Navigation plugin would also do what I needed without the extra file.
  • I used Terser and CleanCSS for minification, this doesn’t gain me much on such a small site, especially as I hand coded everything but it felt important to have it in place for the future.
  • To add a Content Security policy I pulled in the approach from the Eleventy High Performance Blog but adjusted it to add hashes to both javascript and css tags to avoid needing to use unsafe-inline.
  • Because I wanted to deploy test versions in a sub directory I used the HTML <base> plugin. This required a little more effort to make sure all of the links were updated (including svg references in the css).

On the whole I’ve been very happy with the process and the outcome. It has certainly saved me a lot of copying and pasting over writing raw html and I think will make future updates much easier.

P.S. I enjoyed it so much that it finally motivated me to putting my own website back online. So that’s Eleventy-two!

Little Shop of Horrors – Show Roundup

This was a show that I was thrilled to get involved with. It was a real case off getting the gang back together, as our director had directed our last two musicals, the last one only a year before. So I took on lighting it with real enthusiasm. Naturally, I did what anyone with sense would do, and called up my lighting design support (my daughter) to help me make this show work.

But let’s face it, anyone working on this show really wants to be backstage and I was no exception. So having secured the services of an excellent lighting operator (thank you Harry) I got myself assigned to ‘plant crew’ for the show itself.

(Spoiler alert, if you haven’t seen this show already you might not want to read the rest of this – go see the show instead).

Continue reading

Tom Jones – Show Roundup

I’m not sure why I auditioned for this show originally as I rarely see myself as an actress these days but audition I did. I got offered Betty, a servant who appears briefly in Act II and has the grand total of two lines. Easy enough, although I had visions of being sat in the dressing room for most of the evening being bored.

Then the director asked if I would be happy to appear briefly as Bridget in the opening to Act I, no lines, just a semi-lit dumb show. No problem at all. Then he suggested that Betty should appear in Act III in place of Andrews, another servant, and again line free. Meanwhile other people had pointed out that I was pretty good at props and so maybe I would like to help out with that too? With the caveat that I wouldn’t be able to run them solo I agreed.

I love doing props and the research is the best part. Looking up handwriting styles for the eighteenth century (and styles for official documents). My own handwriting is too messy to produce something period, so I found some obscure but beautiful fonts (and some others for other historical periods that I’m dying to have an excuse to use).
Looking up paper styles (remembering that the paper is new and doesn’t need to be aged).
Investigating wax seals and discovering that they would have used brittle wax whereas modern wax is supple. I let authenticity go on that one, but also learned that wax doesn’t stick to baking parchment, so it can be used under the flap to create a seal on a letter that can then be opened easily on stage.
A bird cage with a fake bird inside and a fabric cover over the top part of the cage.The most fun prop of the show though is the bird cage. It contains a linnet which has to ‘fly away’. A bird cage, a (fake) bird, a little fishing line, some ingenuity and most importantly a costume lady who kindly sewed me a little cover for it and the bird flew.
I got my backstage help (from my ever amazing daughter), never went to the dressing room except to change and the crowd scene at the end meant I was occupied from start to finish.

Around all of this an amazingly fun (and bawdy) romp developed. The costumes and makeup were fabulous, the cast threw themselves in to the show. There was an excellent sword fight (having a proper fight director brought it to life without straying into panto) and a lot of laughs.

Still, the best compliment I think we received was from a gentleman who had bought a ticket expecting a Tom Jones tribute act, who stayed through the show and admitted that although he would never have come deliberately to something like this had in fact loved it and would be coming back in future.
And isn’t that why we do this?

Blackpool Tower, Tram and Tap

I’d never been to Blackpool. So the chance to visit was too good to miss. We were on tour with Wayne Sleep. This was much less glamorous than it sounds; particularly if you’d seen our hotel. However the show itself was excellent, an entertaining talk about his life, complete with videos of his dancing, a chance for audience questions (always fascinating) and yes, even a couple of tap numbers.

Still as well as crewing for the show, I wanted to take advantage of the chance to look around. We did go for a lovely walk along the North Pier (which turns out to be the birthplace of Sooty as well as having a lovely theatre at the end of it). We strolled along the promenade at night and enjoyed the lights. But if you have time to visit only one thing in Blackpool, it surely must be the tower itself.

So off we went in the morning, also squeezing in a ridiculously short tram ride on the way before heading up the tower as far as they would let us, frustratingly nearly, but not quite, all the way to the very top.

I took some pictures too, looking both up and down.

Blackpool

From Depart To Arrive Route
Pleasant Street 09:14 Tower 09:19 1

 

 

Green Space Dark Skies

You may have gathered that I do enjoy a mass artwork project, so when I saw an opportunity to sign up to meet up in the countryside to make patterns with lights I couldn’t resist, especially as the nearest event was in the Chilterns, not very far away at all.

My experience of these events is that when you bring hundreds of people together with a common goal to make something beautiful the atmosphere is itself a beautiful thing and I was not disappointed. On a perfect summer’s afternoon we gathered, we sat and relaxed in the afternoon sunshine and gazed at the view. There was music and dancing and free tea and coffee.

We collected a glowing light each and a radio so we would be able to hear instructions as we made our patterns.

Then came the rehearsal, as in groups we learned what we would be doing. As we struggled to remember several different moves we hoped that the instructions later would be clear.

As dusk fell, we assembled. Hundreds of people, each clutching a glowing light, moving around each other, working together to make something beautiful. And we did.

 

The entire cast

Midsummer Night’s Dream – Show Roundup

What, a play toward! I’ll be an auditor; An actor too, perhaps, if I see cause.

More than two years ago, I auditioned for A Midsummer Night’s Dream. I was excited to be cast as Peaseblossom, I even started learning my lines…and then lockdown happened. So the production was pushed back, and back, and back, until finally, two years after originally intended we finally made it on stage.

Fairies being made upHaving done props for the last show (And Then There Were None) which meant being the first person in the theatre and the last to leave; I’d looked forward to being in the cast. Strolling in a few minutes before curtain up, running away as soon as we went down… I had failed to factor in the make up. As it was, I needed to be the first cast member to arrive alongside our fantastic and very patient make up ladies, who spent each evening making up a whole host of fairies. And after the show, well, despite several wet wipes I still went home each evening with slightly green and glittery eyebrows and a reasonable amount of eyeliner.

A fairy in a treeThe director assembled an amazing cast. The lovers were passionate and their fight scenes were enthusiastically realistic, the mechanicals were hysterically funny and turned out to be able to tap dance a lot better than any of them would have expected, and the fairies…Bored fairies

I’d had worries that perhaps I was too old to be a fairy, but it turned out that my inner six-year-old was up to the task. Climbing trees, causing mischief, stealing sandwiches and sharing them with the audience, playing clapping games, doing magic, and rolling around on the forest floor all seemed to come surprisingly naturally. I managed a bit of sweeping too.

What a show it was. One of the best of Shakespeare’s plays, augmented with so many lovely details by our imaginative director, it really was the most amazing fun. The audiences seemed to enjoy themselves enormously each night, but I suspect not nearly as much as the cast did.

And if you want to see how much fun – you can still watch the stream for yourself.

Cast photo © Brian Holt

If I Were Not Upon The Stage

…in the streaming room I’d be.

So for a little context; spurred on by a pandemic, and with the help of some generous funding, our little theatre now has the technology to live stream our shows to an audience around the world.

So, here we are, in December and it is very definitely panto season. We’re getting ready to live stream one of our panto performances, which means setting up and rehearsing the technology and, of course, watching the pantomime multiple times.

In classic style, one of this year’s panto songs is “If I were not upon the stage”. Watching this, I was struck by the fact that many of the children in the audience would not recognise our first chosen profession of a bus conductor. Whereas as a child I was used to getting on a bus, sitting down and waiting for the conductor to sell me a ticket, modern children expect all that to be managed by the driver. Cheaper for the bus company certainly, but not as friendly a service for the passengers. If you need someone to tell you which stop you need to get off at on a strange route, the bus driver is not really in a position to help, and they are not keen on queries about which ticket you need or indeed anything which slows the ticket buying process down.

This change of responsibilities resonates with me, not least because in working to set up our live streaming capability it has been described as aiming for a ‘one man operated bus’. Certainly, as in many organisations, we are often short of volunteers, and there is no way we could have supported a set up which required a camera operator behind every camera nor do we have the space in our tiny theatre for them. Our little PTZ cameras are unobtrusive and sophisticated allowing them to be controlled from our little streaming studio at the back of the auditorium. However currently we have been working as a duo, two people together in that tiny space. This allows for a split of responsibilities, one person can check the audio feed, and think ahead to what is coming next, while the other keeps ‘flying the plane’ and vision mixing the cameras. It also allows for a change of ‘driver’ and more importantly the possibility for someone to go and fetch a welcome cup of coffee during the show!

I remember when the proposal to change to one man operated buses was proposed there was concern about the extra work the driver was being asked to take on and the implications, and it occurs to me, in our own little bus, that while it is possible to be a driver-conductor, the customers get a better service with a team. So I’m very happy to go on being a bus conductor.

Fares please, room on top, pass right down inside, ting ting!

Writing Joy

reMarkable 2I was recently given a digital paper tablet and it really is as wonderful as you can imagine.  Naturally I had to test it out by writing something. This is what I came up with.

Sonnet XI – Writing Joy

The pen is gently scratchy on the page,
Familiar the sound to all who write,
Whether it be for novels or the stage
Or ramblings poetic late at night.
The words pour out in rough untidy hand,
Corrections adding to the melee there.
In script only the writer understands
They try to capture something they can share.
As ideas grow, the words they need to move.
Reordered to enhance the growing whole.
Our changing text, the poem to improve,
The process thus brings pleasure to the soul.
Remarkable to find such written bliss?
An electronic notepad brought you this.

© CMB