June 12, 2006

Minx 101

Some time this week - assuming we don't get torpedoed again - I will be switching Munuviana over to Minx.

Yes, Minx.

Or mostly Minx. What I've done is adapted Minx to the Movable Type database. That way, you don't need to import your posts, change your logins, anything. You can keep using the existing Movable Type interface until the Minx interface is up to scratch. It just works.™

Except for templates, which are a bit different. Here's a quick overview of how templates work in Minx. There are (currently) three main templates that control the layout of your site: The Page template, the Post template, and the Comment template:

Page Template
<html><head>
<title>Minx Dynamic Pages for Movable Type</title>
<link rel="stylesheet" href="http://ai.mu.nu/styles-site.css" type="text/css" />
<script language="JavaScript" src="http://blog2.mu.nu/cgi/showhide.js"></script>
</head>
<body>
<div id="container"><div id="center"><div class="content">
<center><b>[blog.name]</b></center><p>
[posts:here]
[magic.pager]
[magic.stats]
</div></div></div>
</body></html>
Very simple. You start with a standard HTML/XHTML page, and the Minx tags are marked with [square brackets]. If you have something in your template that's in square brackets that's not a Minx tag - intentionally or unintentionally - it just gets spat out unchanged. (The divs look a bit odd, but that's because I'm using an unmodified MT3 stylesheet for testing.)

We can see three types of tags here:
A simple tag, [blog.name], which just looks up the matching database field for the currently active blog and inserts it into the page at that point.

A here tag, which is used to simplify block processing. The [posts.here] and [comments.here] are the most common examples of this. Without any parameters** they loop through the posts or comments using the default settings for your blog and the default post/comment template, as appropriate.

The Post and Comment templates look like this:

Post Template
<h2>[post.newdate]</h2><p>
<b>[post.title]</b><p>
[post.text]  
<p class="posted">
Posted by: [post.authorlink] at
<a href="[post.url]">[post.time]</a>
| <a href="#" onClick="ShowHide('cc[post.id]'); return false;">Comments ([post.comments])</a>
| <a href="http://blog2.mu.nu/cgi/mcomment.cgi?post=[post.id]">Add Comment</a>
| Trackbacks (Suck)
</p>   
<div id="cc[post.id]" style="display:none">
[comments:here]
<p class="posted">
<a href="#" onClick="ShowHide('cc[post.id]'); return false;">Hide Comments</a>
| <a href="http://blog2.mu.nu/cgi/mcomment.cgi?post=[post.id]">Add Comment</a>
</p>   
</div>

Comment Template

<div id="c[comment.id]">[comment.text]</div>
<p class="posted">
Posted by: [comment.authorlink] at [comment.datetime] </p>
Again, we have regular HTML, with just a bunch of simple tags to insert the desired values. The Post template might look a bit complicated, but it is handling inline comments; a Post template without comments might be just:
<h2>[post.newdate]</h2><p>
<b>[post.title]</b><p>
[post.text]  
<p class="posted">
Posted by: [post.authorlink] at
<a href="[post.url]">[post.time]</a>
| <a href="http://blog2.mu.nu/cgi/mcomment.cgi?post=[post.id]">Comments ([post.comments])</a>
| Trackbacks (Suck)
</p>

Minx is intended to let you have full control of post and comment selection from the template, overriding the default settings, but those tags are more complex to process and don't work yet.

Finally, we have magic tags. We have two examples of this, the pager and the stats. Magic tags do magic stuff that isn't necessarily available using regular template substitution. The pager lets you go to the next/previous page of the blog (a fancier pager is coming); the stats show performance information (and a fancier version of that is coming too).

The central idea is to make as much of the feature set as possible available without making the templates scary. So you don't need to have a complex nested structure of post tags and comment tags. Just put [posts.here] in your page template (with maybe some optional parameters) and [comments:here] in your post template. Set the appropriate settings on your blog options screen and you're in business!

Maintaining Your Templates

Minx pulls its templates dynamically from the MT database. If you create index templates called mxPage, mxPost, and mxComment, Minx will use them to override the default templates. (Which are loaded dynamically as well, from blog number 1 - the old Ambient Irony blog.)

You can just use Movable Type to do this right now, but in the next week or so we will have a very nifty WYSIWYG (well, WYSIMOLWYG) template editor, which should make things a lot easier. No need for rebuilds to see your changes, either; it's in-stan-taneous!

Advanced Features

You can also include templates using the [include template] tag. The template to be included must also begin with "mx", since Minx only looks at those, but you don't actually specify the "mx" when you use the tag. So, for example, you can create a blogroll template called mxBlogroll and include it with the tag [include blogroll]. (It's not case-sensitive.)

Minx supports conditional processing with if and ifn. if and ifn can be used with any simple tag to test whether the value of that tag is "true" or not. A tag is true if it is a non-zero number or a non-empty string, otherwise it is false. Any text between [if tag] and [/if] is included if the value of the tag is true. And any text between [ifn tag] and [/ifn] is included only if the value of the tag is false.

You can't nest if tags, though you can nest an ifn inside an if and vice-versa. If you want to get more complicated than that, for now you'll need to use sub-templates with include.

For example:

[if post.comments]| <a href="#" onClick="ShowHide('cc[post.id]'); return false;">
Comments ([post.comments])</a> [/if]
[ifn post.comments]| No Comments [/ifn]
That will show the inline comments clicky if there are comments, but just the test No Comments if there aren't.

More tomorrow.

Although... If anyone can work out why the examples have gone all shrinky in the test version of Minx, that would be much appreciated. It's the same stylesheet as my blog, but the examples there are normal size.

Update: It was the DTD?! I didn't know the DTD could do that. What. Ever.

Update: Fine now in Firefox, but still squishy in IE 6. But then, so's pre'd text on my blog, so at least it's consistent. Fine in Opera. Fine in Konqueror, so probably also fine in Safari. Weird in IE7, which resizes the entire page.

I blame Microsoft.

Posted by Pixy Misa at June 12, 2006 01:13 PM | TrackBack

Comments
#1

Okay, I could just assume, but we all know where that leads... ;)

This will have no effect whatsoever on the WP blogs, correct?

Thanks, Pixy... for everything!

Posted by pam at June 12, 2006 04:02 PM
#2

Right.

No effect on anyone, in fact, unless you decide to switch to it.



Posted by Pixy Misa at June 12, 2006 04:24 PM
#3

Sorry, I should have been clearer - Munuviana, as in this particular blog. Nothing else, at least for now.

Posted by Pixy Misa at June 12, 2006 04:29 PM
#4

For the time being I've set the main page for Munuviana to rebuild automatically every ten minutes.  That way any comments added in the Minx version will appear in the plain MT version.  (Minx doesn't build the MT pages at all, which is why it is so much faster to add comments that way.)

Posted by Pixy Misa at June 12, 2006 04:39 PM
#5

In the meantime, go here and play with it!  The more bugs we can shake out before I switch over, the better.

Come to think of it, if we switch over and it dies, that would be rather a problem.  I'll keep the MT version of Munuviana around; maybe just have a great big linky up the top saying "GO HERE FOR COOL NEW TOYS!!"



Posted by Pixy Misa at June 12, 2006 04:43 PM
#6

Thanks Pixy...You are fantastic!

Posted by Rachel Ann at June 12, 2006 07:14 PM
#7

Outstanding! 

Posted by GM Roper at June 12, 2006 09:38 PM
#8

Looks great. Safari still doesn't seem to like the pretty editor. (entering this text on the original site).

Posted by Stephen Macklin at June 12, 2006 10:22 PM
#9

Sorry for being a bit thick-headed, but what does this mean, Pixy? Will we switch to Minx and use it instead of MT?

I wouldn't mind being a Minx guinea pig if you're looking for them. Or would that be a guinea dog?

Thanks,
Howard

Posted by Howard at June 12, 2006 11:26 PM
#10

Fast is good - I'm waiting to see how the finished product turns out.  I'd be happy to move to it.  I'll likely screw up the template stuff - but I love new toys - even when they break things. *grin*

Posted by Teresa at June 13, 2006 03:36 AM
#11

Hmmm... interesting.  On my comment above, I hit preview and it posted instead.  I may have missed something and this is the way the unfinished version is working.  Just thought I'd mention it though, in case you didn't know it.

Posted by Teresa at June 13, 2006 03:38 AM
#12

Yes, it does that. I need to fix the comments page.

Posted by Pixy Misa at June 13, 2006 04:39 AM
#13

Howard - I've configured Minx to run in parallel with MT.  Minx doesn't yet have an interface for managing your posts, so until it does, you will use MT for that.  In fact, you can continue to use MT after that if you prefer.

Eventually, yes, we'll be moving over to Minx.  But because the two systems work nicely together, there's no need to switch over until you're ready.



Posted by Pixy Misa at June 13, 2006 05:34 AM
Live Comment Preview
Post a comment









Remember personal info?