« Los Angeles Beach Day | Main | Icehouse Canyon »

Photo Plugin

This past weekend, I took a number of photos, and I want to make them into an entry for my blog. I did it manually in a past entry, by setting up HTML tables and such. But, it would be nice to have an easy and automatic way of generating that kind of code. So, I'll take this opportunity to write a new plug-in for Moveable Type.

I wanted to be able to embed tags into an entry, perhaps in a hierarchical sequence. The tags would contain the photo path, and some text description. These tags would be parsed into a proper HTML table, that would be pleasing to view. I imagined an XML format, perhaps with a container entity so that one's photo entry could have a pure text prelude and a conclusion.

My first attempt at this is located here. This may be useable, if only barely. There were some good lessons learned, though:

  • Normal MT tags cannot be used within entries. I probably should have know this. It is somewhat unfortunate, as MT has a great tag scheme for its templates. The only way to be able to do processing of entries is via a text-formatting plugin.
  • It is difficult to include XML tags in a text-formatting plugin, for at least two reasons. First, the MT editor automatically changes strange < and > signs into the appropriate thing for HTML. That means that they are not passed into the text filter. Second, even if they were passed in, I probably would not be able to use an XML parser, as there may be text before and after the XML tree. (Maybe that can be handled with some parsers, but I don't know how.)
  • Plugin installation is surprisingly easy. But, I was originally frustrated when I could not get normal MT tags to work in my entry. I was then frustrated when I misspelled "Plugins" as "Plugin". I guess that I am easily frustrated. Still, most of my computing career has been on the Windows platform, so installing a module by dropping it into the right directory makes me almost giddy with joy.
  • Because I could not include XML-like tags into the entry, I had to parse for bare text. I tried to make the syntax obvious by capitalization and end-tags (like XML without the brackets). It seemed easiest to write the parsing code in a "stateless" way, but I recognize that is not a very maintainable way of doing it. Wow, do I want to use a real XML parser.
  • There seems to be some good documentation out there. Timothy Appnel's writeup was an excellent introduction. The original discussion of the text-formatting plug-in feature is described here. The MT manual contains some information about plugins. The best place, of course, is the Plug-Ins Directory. It is almost a necessity to look at some working examples.

Well, I will continue to think about the issues in doing what I am trying to do. Perhaps there is a reasonable solution. I am far from a Perl guru, and maybe some wise master has already uploaded what I need to CPAN.

I continue to be impressed with Moveable Type and the community that has grown up around it. Perhaps if I can work out my issues, this little plug-in will be useful to others, too.

Example of what I am trying to do:

Here is some text.
Here is some text.

Ads

TrackBack

TrackBack URL for this entry:
http://www.borlik.net/cgi-bin/blog/mt-tb.cgi/25

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)