mike chambers | about

Custom Quickcode Tags for MoveableType

Tuesday, May 17, 2005

One of the new plugins we installed on the new weblog server is the Quickcode plugin for Moveabletype This is a simple plugin that uses bracketed tags to make it easy to mark up posts.

Instead of typing:

<a href="mailto:mesh@macromedia.com">mesh@macromedia.com</a>

I can type:

[email]mesh@macromedia.com[/email]

The syntax is easy to use, which is the main reason I installed it.

Once I began using it, I realized it would be useful to create a number of other tags, so I opened up the plugin file (written in Perl) and hacked around until I got some new tags working. I wanted to post them here in case anyone else found them useful.

Here are the new tags:

[mxna]TERM[/mxna] - Links the term for a search at the Macromedia XML News Aggregator (MXNA)

[google]TERM[/google] - Links the term for a search at Google

[wikipedia]TERM[/wikipedia] - Links the term for a search / link at wikipedia

[url2]TERM[/url2] - Links the included URL, with the URL as the link.

Here are some examples:

This searches for [mxna]mesh[/mxna] at MXNA.  
This searches for [google]Mike Chambers[/google] at Google.  
This search for [wikipedia]Macromedia Flash[/wikipedia] at wikipedia.org.  
This creates a link to my new weblog at [url2]http://weblogs.macromedia.com/mesh/[/url2]

To install these, download and install the quickcode.pl file. Open the file in a text editor, and search for the following lines inside of the maincode sub:

$s =~ s![email](.*?)[/email]!<a href="mailto:$1">$1</a>!gis;

Insert the following lines after the line above:

$s =~ s![mxna](.*?)[/mxna]!<a href="http://weblogs.macromedia.com/mxna/index.cfm?searchterms=$1">$1</a>!gis;

$s =~ s![google](.*?)[/google]!<a href="http://www.google.com/search?q=$1">$1</a>!gis;

$s =~ s![wikipedia](.*?)[/wikipedia]!<a href="http://en.wikipedia.org/wiki/Special:Search?search=$1">$1</a>!gis;

$s =~ s![url2](.*?)[/url2]!<a href="$1">$1</a>!gis;</pre>

Save the file. Now when you make a post using Quickcode formatting, you can use the new tags.

If you can think of any useful tags to create, post them in the comments.

twitter github flickr behance