Taking your blog’s temperature
Lloyd Nebres had a great idea, to take your weblog’s temperature by rating each day’s posts by whether you were hot or not, and then displaying a calendar view with colored dots that show at a glance how you were, or at least how you blogged, over the course of a month.
Phil Ulrich took the idea and ran with it, creating a PHP/Movable Type scheme for automatically generating average daily ratings that you display by the date header or in the calendar. Unfortunately, using it requires that you not be using MT categories already, since that’s the only convenient thing MT has to assign a temperature to your posts.
It should be possible to adapt it to an MT blog that already uses categories for categories, but I’m not quite sure exactly how to do it yet. We need a plugin clone of the MTCategories tag that will allow you to exclude categories one way or another (either along the lines of <MTCategoriesX exclude=”1, 2, 3, 4″> or maybe just a config file that lists the categories that aren’t really categories), which would be useful for lots of abuse of the category concept things. Then, if it’s possible to assign secondary categories with a set of radio buttons hacked into the entry template without breaking the regular secondary category assignment system (I’m not at all sure, since I’ve never looked at how it’s done), you could use categories for all sorts of things without messing up the regular category functions. Put it on the to do list.
<update>Take that off my to do list: Ulrich’s got your plugins for MTCategoriesX, MTEntryCategoriesX (I forgot about that one), along with MTCategoriesThermal and MTEntryCategoriesThermal. I’m not going to get to play with it until after the weekend, since I’m blowing town straight from work Friday, but I’ve got plans. Oh, I’ve got plans.</update>
Phil, about the plugins thing. I hate to say it, but unless you’re doing something totally new, running system commands such as uptime, or are able to decipher the mystic example at the end of the plugins documentation that, interestingly, the output does NOT show up for–then plugins are basically useless. You already have to be a Perl genius, in my opinion, to use it. Unfortunately, PHP is my forte. Something as similar as cloning a tag doesn’t really seem to be possible at all. Shoot me if I’m wrong.
On second thought, it’s 3:22 a.m. here; maybe I’m just grumpy because I fried my brain trying to decipher a language I’m not so hot at.
Perl’s a bitch, no doubt about it. It’s not so much that you have to be a Perl genius as that there’s only two classes: Perl geniuses and people who don’t get Perl at all. PHP you can pick up a little at a time, but Perl you have to grasp the whole damn language all at once. PHP, if you don’t get something you look it up in the incredibly clear manual; Perl’s manual is designed to obfuscate, just like the language. Hell, they’re proud of the fact that There’s More Than One Way To Do It. In fact, there’s usually eight or ten, each less clear than the last, and you have to know all of them in order to figure out what someone else’s code is doing.
However, it can be done. Context.pm is your friend: up at the top, in the section of $ctx->register_handers, it tells you what sub gets called for various tags, so then you know that MTCategories is handled by sub _hdlr_categories. Copy the contents of _hdlr_categories, and paste it into the shell from the container tag example, give it a new name, and you’ve got a working clone of MTCategories.
Then it gets ugly. I think that if you pass an argument (MTCategoriesX exclude=”1, 2, 3, 4”), then you’ll find it in $args->{’exclude’}. So, if you get one, split on ”, ” to get a list of category labels to exclude, and after the ”my $iter = MT::Category->load_iter…” line that loads the category objects, *waves vaguely* delete the things in $iter that are in your exclude list. What the hell is $iter? Um, a scalar reference to a list, I would think, but then to go through it you would say:
for my $cat (@$iter)
but when he goes after the entries, he uses
while (my $cat = $iter->())
and I don’t have a clue what $iter->() is, does, or means about what $iter is. Figure that out, so that we know how to remove something from $iter, and we’re set.
Which would work, once we figure out the $iter deal. However, two small problems. I tried cloning the MTCategories tag handler this morning – and nothing happened. No output at all from the clone tag. Also no output (other than the glue) when I try using an MTEntryCategories tag handler, instead. I almost wonder if it’d be possible just to call one of the handlers directly from MT::Template::Context to save on copying/pasting.
I tried to learn Perl once. Failed. Utterly. Have no plans to try again.
Somebody develop an MT plugin that lets me call a Python program… *evil grin* (Yeah, yeah, I know; do it via <script>.)
Well, um… I happen to like perl… Of course It’s been said that I have a demented mind, maybe that’s why…
Or even easier. `python scriptname`. ;)
Yeah, I actually tried that for a PHP plugin, but then you end up getting back a couple of lines of header that you have to strip out of your output, and you have to pass all the data you’re going to manipulate (unless you then do a exec(perl mt.cgi …) from PHP, or the Python equivalent, which would just be way too silly), so for most things you end up still having to do the bulk of it in Perl, but with the added overhead of having to fire up Python/PHP every time you rebuild. Just have to grasp the Perl nettle.
Well, I couldn’t’ve done it without you, Phil, but I did manage to do it, or something like it. Check it out here.
$iter’s an object, so $iter->() would presumably be it calling its constructor method (I think it’s still a constructor in this case) which is, in turn, probably creating a new iterable list each time and setting it to $cat, for as long as it can create new lists. As for how it applies to the categories, I _guess_ it’s returning a list of all the posts in a category, one category at a time (each time round the WHILE loop).
Or something.
The load_iter subroutine which is called is held inside DBM.pm, but I’m not sure what exactly you can feed into it. Perhaps there _is_ an easier way to exclude things here. I dunno. It fries my noodle when I look at it.
So you will be next to succumb to the Thermal Rating craze, eehhhhh, Ringnalda, you wily rogue? ;)
Not today, though – I’m leaving town straight from work tonight. Next week. I’ll have to pick some really nice color for ice cold, though, to keep my long and frequent pauses from looking too bad.
So, $entry = MT::Entry->load ({ Author => ’Phil’ }) returns the first entry object that I wrote (or some random one, the first retrieved), @entry = MT::Entry->load ({ Author => ’Phil’ }) returns an array of all the entry objects I wrote, and $iter = MT::Entry->load_iter ({ Author => ’Phil’}) returns a reference to an object method that will return the next singe entry each time I call it with $iter->()? Ow, my head!
I went shopping for Perl books yesterday. They all run from $35 to $50, and judging by what people recommend, around $200 worth will give you a fairly reasonable overview. Might be time for me to turn whore and put up an Amazon wishlist link.
Turning whore has never bothered me any. Oh, wait, the list to my Amazon wishlist has vanished! I’ll have to fix that after lunch.
I have nothing to add to this thread…just thought it could use another Phil.
cheers!
Taking other people’s weblogs’ temperature ;)
Well, Phil wrote about the thermal weblog system, which isn’t too surprising–I figured he’d get around to it eventually. ;)
MT plugin!
It’s not that complicated, really, but I’ll save you the work–download the ThermalCategoryTags plugin here. Basically, this implements four new
More MT Plugins
Four new tags are now available, via two plugins: CategoryExclude, which adds <MTCategoriesExcluding> and <MTEntryCategoriesExcluding>, both of which take one