So yesterday's project got sidetracked by old Hewlett-Packard handheld computers. That's another story.

But I couldn't sleep, so I figured I'd just get up and play around with Tinderbox. It's taken about an hour, but I've achieved success! The project isn't complete yet, but this progress is "noteworthy."

I created a "blog test vehicle" Tinderbox document. A file that I know I'd want to export as a web page in the form of a blog, and one that, not coincidentally, somewhat resembles the marmot.

One of the "features" of a blog is an archive of past posts. I put "features" in scare-quotes, because none of this is carved in stone, it's just the convention most familiar to me. You can structure your blog however you want.

I've organized my archives by year, each year containing twelve monthly archives, an html file of a month's posts, named by month and year.

Each year, I have to create a new container for that year's archives. I figured that's where I'd start in automating some of the maintenance features. Why not let the Archive container create the container for the year's archive?

Notes are containers in Tinderbox. They contain the text of the note, and a lot of other things called "attributes." Some of those attributes are little programs that work on other notes and other attributes. There's an "Inspector" window that let's you work on many of those attributes, the one's you're most likely to want to have easy access to in one convenient facility. One of the tabs in the Inspector is the Action Inspector, where you can store the code or little program. This is the place where much frustration, sorrow and suffering often resides.

It's also the place where the cool stuff happens.

I figured I'd have to write a bunch of logic that would tell the Archive note to look at all the other notes and see if any of them are named the current year, and if not, then create a new note with the current year as its name. I was kind of dreading this, but it was pretty damn simple.

Since I only need to create this container once a year, I placed the program in the Edict pane of the Action Inspector. An "edict" is a rule that's run relatively infrequently, you can read about when it's run here. My little program looks like this:

$MyDate="today";

$MyString=$MyDate.year;

create($MyString);

The cool part is "create" checks to see if the note it's trying to create already exists. If it does, it doesn't do anything. All that comparison logic (Which wouldn't be that hard, except it's parsing "date" data types, which I wasn't looking forward to because it can get a little tricky.)

Now that I have a container for the year, I want that container to create the container for the current month's posts. So I add an Edict to that note.

That little program looks like this:

$MyDate="today";

$MyString=$MyDate.format("MM y");

create($MyString);

What saves you a lot of hassle is that ".format" operator. Names of notes are strings, so we need to coerce a "date" data-type into a string in order to look for notes with the same name (which "create" does automatically, in the background). We want our month name to follow a particular convention, and that convention is defined by the variables in the ".format" operator, where "MM" connotes the full name of the month, i.e. "August," and "y" connotes the 4-digit year. The space between "MM" and "y" is relevant as well.

So the Edict looks at today's date, converts it to a string that looks like "August 2023," then checks to see if there's already a note by that name. If not, it creates the note, and does nothing if there already is.

In order to not have to type that little program in, we need to make a prototype year container, which contains this program already baked-in.

That's a topic for another day. It seems I may be building a generic Tinderbox blog file.

But gosh, don't I feel smart?!

Originally posted at Nice Marmot 05:47 Wednesday, 2 August 2023