Pluggable text filters for Typo

Posted by Scott Laird Fri, 12 Aug 2005 15:20:00 GMT

Now that tags are working, I’ve started work on adding text-filter plugins for Typo. The current release (Typo 2.5.3) has support for 5 different combinations of Textile, Markdown, and SmartyPants hard-coded into it. The different combinations are actually repeated in 3 different places–the filtering code itself, the drop-down list for the built-in editor, and the Movable Type API code to list filter options.

That’s all gone now, replaced with a plugin system, similar to the sidebar plugins that made it into Typo 2.5. Individual filters get dropped into components/plugins/textfilters/ and the system picks up on them automatically. Then there’s an interface in the admin UI that lets you combine the filters into named filter sets, so you can combine Markdown and SmartyPants into “My Filters” (or “Markdown with SmartyPants”, which Ecto recognizes and performs some magic to get Markdown previews to work right). The UI isn’t really complete yet, but the entire back end is there, and I’ve added two new filters as a demonstration of what we can do. Here’s the current list:

  • Markdown. This is my favorite lightweight markup language, and I use it for everything that I write here.
  • SmartyPants. A companion to Markdown, it does a typographical cleanup on HTML, turning ASCII single and double quotes into their typographically correct cousins and fixing em-dashes.
  • Textile. Another lightweight markup language, like Markdown.
  • Amazon. This turns URLs like <a href="amazon:097669400X" ...> into a link to Amazon’s page for ASIN 097669400X, optionally attaching your Amazon affiliate tag. This is mostly a demonstration of what you can do with filters, although I’ll be using it on my blog.
  • Flickr. This sticks a picture from Flickr on the page. This is a bit more complex then the Amazon filter, but similar in concept. It turns <flickr img="31366117" ...> into a formated inline image, linked to Flickr’s full-sized image page, optionally with a caption attached. The full HTML produced is something like <div style=""><a><img/></a><p>Caption</p></div>, which saves a lot of typing.

I’m currently working on a Sparklines plugin, using Glyph’s Ruby sparklines code. It’ll be similar to the <flickr> tag, except it’ll spit out an <img> tag that points to a built-in sparkline generator. Turning <sparkline ...> into an image tag is trivial; allowing a text filter to export an action to the world is a bit more work.

There are currently two things that bother me about this code that I’ll need to resolve before releasing it:

  1. The <flickr> and <sparkline> tags–should they look like plain XHTML, or is that a mistake? Should I turn them into pseudo-bbcode tags, like [flickr]? I’m currently leaning towards sticking a typo pseudo-namespace on the front of them, and turning them into <typo:flickr .../> and <typo:sparkline ...>. Any objections to that?
  2. The admin interface to this is killing me. I’d love to have a nice, simple way of editing each filter set, but it’s turning into a nightmare. I could just copy the sidebar config page (with a few changes–you can only include each filter once, unlike sidebars), but lots of people have had problems with the sidebar editor, and I’d like something a bit cleaner. Except I have no idea what to do.

If all goes well, I’ll post a public patch for comment early next week, and then kick off the Typo 4.0 process by committing this and the tag code later in the week.

Posted in  | Tags , , , , ,  | 5 comments

Halo 2, or why not to use Amazon

Posted by Scott Laird Tue, 09 Nov 2004 18:38:08 GMT

As widely covered in the news, Halo 2 was released today. I pre-ordered a copy through Amazon over a month ago, so I should be expecting my copy today, right?

So, I went to all of the trouble to order it a month in advance, and they can’t even be bothered to ship it until after the release date? I noticed that the shipping date was listed as the 15th yesterday, but Amazon’s site was so freakishly slow yesterday that I wasn’t able to log in and deal with it. Now, today, they’re gearing up to ship it, but it’s still not expected to arrive until the middle of next week.

This is really irritating–I need to have a copy in my hands before this weekend, because some friends have been planning a “Halo 2” party for almost 6 months.

Posted in  | Tags , , ,  | no comments

Cheap Treo 600 from AT&T and Amazon

Posted by Scott Laird Tue, 27 Jul 2004 21:15:03 GMT

According to Treo Central, Amazon is offering the Treo 600 for $149 after rebates. Treo Central didn’t notice, but PalmOne is selling the Treo 600 for $349 (after rebate) to new AT&T customers.

Treo Central thinks that this is an indication that the Treo Ace is getting closer. More likely, it’s a reflection on the Treo 600’s demand: PalmOne’s Treo 600 shipping page indicates that they’ve finally, after almost a year, caught up with the Treo 600 order backlog. Since they’re now building them faster then they’re selling them, it makes sense to start offering discounts.

Posted in  | Tags , , , ,  | 2 comments