Photo Corners headlinesarchivemikepasini.com


A   S C R A P B O O K   O F   S O L U T I O N S   F O R   T H E   P H O T O G R A P H E R

Enhancing the enjoyment of taking pictures with news that matters, features that entertain and images that delight. Published frequently.

Site Tweak: Counting Matinees Share This on LinkedIn   Tweet This   Forward This

7 June 2021

Later this week we'll publish our 400th matinee. We started the weekly series in September 2013 and we haven't missed a Saturday since.

Over that span, we have kept count of the total (which we include just above the video) several ways. First manually, then with a variable we saved and now with yet another entirely different method.

We were inspired to revise our approach by the Great Corrective: a mistake.

We discovered the mistake (which had us off by some 90 or so entries) when we decided to convert the listing from a static file to a JSON array. The idea was that the HTML file you see would be a lot smaller and remain small as we continue to add to the array.

We were inspired to revise our approach by the Great Corrective: a mistake.

It would also mean we could just update the list with one new listing rather than update the matinee HTML file with two URLs (for the current year and the full list).

It was easy enough to convert the static list of links to JSON using a regexp. And because we duplicate the listings for the full year, to eliminate the repeats.

But we were puzzled why we still had those extra 90 or so in the JSON file.

For the first time in a long time, we were getting an accurate count. That's why. We'd made a mistake a while back, transposing numerals (something like "21x" to "12x") and didn't catch it.

(For our punishment, we edited a couple hundred matinee files on Saturday, fixing their count and uploading them to the server.)

Our saved variable worked much better when we finally implemented it. But it too had an issue. The variable wasn't copied to our second computer so when we traveled, we lost count. We could, of course, just reference the last matinee to see the count but that meant the saved variable wouldn't be updated on the computer that didn't travel.

So we liked the idea of using a JSON array. But then the fun began.

The matinee HTML displays each title in the year we published it, with yearly quarters divided by rules. And the Full List repeats all that.

We didn't want to change that so we resorted to an old friend, Adobe Spry, which the company no longer develops (but which can still be found in Dreamweaver). Much of what it does has been swallowed by jQuery and we've even duplicated the data handling in jQuery as a proof of concept. But we still rely on Spry to manipulate data because, well, we prefer it to jQuery.

So we rebuilt the matinee HTML page in Spry and that worked just as quickly as the old static page. We checked and rechecked and couldn't tell the difference.

That left us with the count to deal with.

A JSON array's zero element happens to be the count. So without counting entries, we had a count variable at our disposal.

We just had to retrieve it from the JSON file rather than the saved variable in our Keyboard Maestro macro and we were ready to go.

Except we wanted to also format a JSON listing when we compiled our matinee story into HTML. So we added that to our publishing system (which sets five strings as Keyboard Maestro macros when it compiles a story).

All of which is to say, we're ready for the 400th matinee next Saturday (and that "400th" there was typed by our new counter macro).

P.S. We liked the new arrangement so well, we implemented it for the obituaries too. Just so we no longer have to make double entries for the full list.


BackBack to Photo Corners