Thursday, February 22


That's Going To Need Stitches

The second most confusing and problematical aspect of Minx is the system of implicit containers.*

I've mentioned before that Minx has multiple hierachies, defined by Sites, Folders, Threads, Posts and Attachments. You can have as many of each as you want, and they can be nested any way you want, and can be intersected and unioned and what not in many strange and wonderful ways.

For a simple example, let's say you want to go to

The part specifies the site; the blog/post part specifies the folder; and the thats_going_to_need_stitches specifies the thread.** Which is all fine and dandy. That thread will likely have a category assigned to it, which is in fact another folder - in this case the "geek" folder - so that it can also be reached at (or something like that). And that category, even though it's actually just another folder which is attached to the entry in question, is to your template an implicit secondary immediate parent structure, so it has to be automatically provided as an appropriate set of template tags.

With me so far?

The problem with this is context. My test site just blew up because the inline comments decided that they needed to be paged (so that only the first 20 comments were displayed inline, and for the rest you had to go to the next page); the problem being that because the page itself was a folder context rather than a thread context, the pager data for the comments (which are posts) wasn't set up. The fix was simply to have the comment paging code check first whether the requisite data was set up... which was a good idea in any case.

This just gets more complicated when you consider that certain objects - the Entry object is a good example - combine the aspects of two or more other objects. An Entry is essentially a Thread combined with a Post, but it also provides access to one or more Author objects and optionally a Folder object, and has to automatically create all the contexts involved. And since an Entry is always viewed inside a Folder context anyway, this can get a little fiddly.

For me. For the user, it's supposed to Just Work™.

One of the solutions I've put in place is explicit substructure tags to complement the implicit tags. Example: The [comments] tag creates a list of comments relevant to the current context, which might be a Folder, a User, a Thread, a Post, or possibly something else. It works out the applicable context automatically, prepares the necessary SQL queries, processes the data, and interprets your template for you. Easy-peasy, unless you wanted it to do something different.

So now, in addition to the semi-automatic [comments] tag and the fully-automatic [comments:here] tag, you have a set of tags such as [entry:comments], [user:comments], [folder:comments], [site:comments], and so on.

The problem with this is that there are, at last count, 12 specialised variants of the [sites] tag, 12 variants of [folders], 6 of [threads], 6 of [posts], and currently 9 of [attachments], and every one of them has to have a complete set of explicit substructure (and superstructure!) tags. So my structural tag table is now dynamically rather than statically generated.

The saving grace, or rather the two saving graces, are these: First, the code for this is largely O(1); the whole template engine works on hash tables, so this doesn't slow it down; and second, because all these variants are variants rather than explicit structures in their own right, this is all actually very well organised. The [category] structure is independent of the [folder] structure (and the [section] structure and the [area] structure and the [archive] and [subforum] and [directory] structures and so on...) but the fields in each one are identical. So as long as you know that [category] is a variant of [folder], you're all set.

How I'm going to structure the documentation for this I don't quite know yet.

* The most confusing and problematical aspect of Minx right now is the user interface customisation system. It doesn't give you a life-jacket, just a whole lot of rope. It's not hard to customise it to the point that you're effectively locked out of your own blog. I will be putting a failsafe in there that lets you log in to the maintenance system using the default settings, but that's not there yet...

** Well, in terms of a blog, it specifies the entry, but keep reading.

Posted by: Pixy Misa at 08:24 PM | Comments (11) | Add Comment | Trackbacks (Suck)
Post contains 751 words, total size 5 kb.



I'd go with dynamically generated documentation.

Posted by: TallDave at Thursday, February 22 2007 11:42 PM (odS+4)

2 Yeah, I'm probably going to set up the documentation as a bliki.

Posted by: Pixy Misa at Friday, February 23 2007 01:05 AM (FSeIE)

3 wow, I was glad you laid that out as you did, because I was able to follow part of the way. I'm looking forward to readin the documentation.

Posted by: michele at Friday, February 23 2007 11:51 AM (oRqqq)

4 The whole thing runs on hash tables? Wow. A friend of mine tried to ship one of those into the country may years ago and almost got away with it.

Posted by: triticale at Saturday, February 24 2007 12:10 AM (9YuSf)

5 :P

Actually, the back end is MySQL as you'd expect.  But the template engine uses hash tables.  Template tags retrieve data from the database into the hash table, and extract data from the hash table and put it into the page, depending on the type of tag.

So [comments] sets up a SQL query and iterates through the results, updating the hash table as it goes, and tags like [comments.text] retrieve data from the hash table.

Posted by: Pixy Misa at Saturday, February 24 2007 01:19 AM (FSeIE)

6 Triticale, sorry, that was a really old joke among programmers, one of those "We've heard it a hundred times and it wasn't even funny the first time" kinds of things. That's why we ignore it.

Posted by: Steven Den Beste at Saturday, February 24 2007 01:23 AM (+rSRq)

7 Guess that shows my noobness, I'd never heard it before and thought it was hilarious.

Posted by: TallDave at Saturday, February 24 2007 03:18 PM (odS+4)

8 It happens to be true. He had a carpenter over in Pakistan construct an item of furniture for him but made the mistake of shipping it air freight which drew Customs attention. His conviction was overturned on appeal because customs would have been wrong to damage the table as they did had he not been smuggling.

Posted by: triticale at Saturday, February 24 2007 10:54 PM (r8DWN)

9 "Bliki"?  I'm not even sure what "wiki" means and now there's another one!

Posted by: BeckoningChasm at Sunday, February 25 2007 10:52 PM (pGYvN)

10 :D

Posted by: Pixy Misa at Monday, February 26 2007 01:38 AM (VImBE)

11 Must be "bling wiki".

Pixy, Livejournal is still banned.

Posted by: Pete Zaitcev at Monday, February 26 2007 02:31 PM (9imyF)

Hide Comments | Add Comment

Comments are disabled. Post is locked.
52kb generated in CPU 0.0217, elapsed 0.5791 seconds.
56 queries taking 0.5664 seconds, 344 records returned.
Powered by Minx 1.1.6c-pink.