Cowlix Wearing my mind on my sleeve

Saturday, February 09, 2002
Movable Type tweaks

I've been meaning to document the tweaks I've done to Movable Type and what I've done to put together some things it doesn't directly support. Two reasons I want to do this: one, it will help me keep track of things and help me remember what I did when it comes time to merge things into version 2. Secondly, someone out there just might be interested. So, if you're one of those people, read on...

As I tweak things going forward, I'll try to keep up notes here. Here's a cumulative list of my tweaks so far.

Weblogs.com ping

Based on a post in the Movable Type forum, I've patched XMLRPC.pm to fix the weblog.com ping bug.

Paragraphs and line breaks

MT has an option that tells it whether to insert paragraph and line break tags in entries and comments. If you select it, a blank line will trigger a new paragraph tag and a newline will trigger a line break tag. I ran into two problems with this. I'm converting a bunch of old archives from BlogMax that have newlines through out. So I didn't want <br> inserted throughout. But I didn't want to bother with putting in paragraph tags. So I modified html_text_transform in Util.pm to skip the <br> insertion. But then, I realized that I really wanted both behaviors in comments. So, I put the original function back as html_text_transform_comment and changed Context.pm to call html_text_transform_comment from _hdlr_comment_body.

Emails in comments

This is one I mentioned when I first moved to MT. I'd like people to enter email addresses on comments, so I turned off anonymous comments in the MT config. But I didn't want to expose the addresses on my site. So, remembering a suggestion I read in Aaron's notes, I commented out the two lines of _hdlr_comment_author_link that would insert the mailto: link if a URL wasn't given.

Suppressing index.shtml

Most of my archive pages, except for the individual entries, index.shtml files in subdirectories. I really didn't want to pollute all the links with "index.shtml" when it's not necessary, but by default that's what MT does. So, I changed _hdlr_archive_link to strip off the index.shtml if it's in the generated link.

I've also done some things with combinations of MT templates and external scripts:

Sorted category archives

Providing support for sorted category archive lists is on the list for 2.0, but it having a long list of unsorted topics bugged me. So, using a very short template

<MTArchiveList archive_type="Category">
<a href="<$MTArchiveLink$>"><$MTArchiveTitle$>&nbsp;
  (<$MTArchiveCount$>)</a><br />
</MTArchiveList>

and a croned shell script that occasionally sorts the generated list into two versions, one with the post counts and one without the counts, I have a temporary workaround.

Related categories

I'm winding up with a lot of categories. But, as always, everything is intertwingled. So, I want to be able to show relationships between the categories I've created. My category archives are each in their own subdirectory. So, now I can put a file in each that contains a list of category names. A CGI script called through SSI from the category archive template checks for the file, and if it's there, formats the list for inclusion on the sidebar of the category's archive file.

I'm not entirely happy with the solution, because it would be easier to maintain if the relationships were all defined in one file. One of these days I may change that, but it works for now.

Recent comments

This is another one that looks like it's going to be doable with MT version 2, though I didn't realize it when I started fiddling with a workaround. Currently, there's nothing allows building a recent comments list directly. But, we can fake it with an index template and some Perl. The template lists out all the comments for all entries within an arbitrary number of days. I lead each comment line off with a timestamp in a format I can sort on and the entry ID.

<MTEntries days="300">
<MTComments>
<MTCommentDate format="%Y %j %H%M%S"> <MTEntryID>
  <a href="<MTEntryLink>"><MTEntryTitle> (<MTEntryCommentCount>)</a><br />
  <MTCommentAuthorLink> at <MTCommentDate format="%H:%M, %b. %d">
</MTComments>
</MTEntries>

This generates a lot of blank lines, one for each entry, but that's OK. The CGI script simply reads the file in, strips the blank lines, and sorts it in descending date order. Anything older than 10 days is dropped and the entry ID is used to filter out duplicates. If there's anything left, the list is printed out to be pulled into the sidebar.

Comments
Post a comment
Name:


Email Address:
 

URL:


Notes:
  • Name and email are required
  • Email will not be disclosed
  • HTML will be stripped
  • URLs will be linked
Comments:


Remember info?



February 2002
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28    
Line

Copyright © 2001-2002 by Wes Cowley
wcowley@cowlix.com