Index of /dev/null

AutoSmileys:-) Plugin for Movable Type

AutoSmileys is an easy to use and highly customizable macro environment for Movable Type. It will replace self-defined text abbreviations by image tags when your site is published or dynamically rendered, respectively. It may be applied either within entries, comments, pages, or any other part of your site.

AutoSmileys works with both static and dynamic publishing and has been tested with MT 4.2, MT 4.3, and MT 5.0 beta (Perl 5.8.8 / PHP 5.2.9). (Dynamic publishing with AutoSmileys requires PHP5 in either case.)



  1. Download, unzip it and copy the AutoSmileys directory from the zip file into the plugins directory of your Movable Type installation.
  2. Sign in to your Movable Type CMS.
  3. For each blog you wish to use AutoSmileys in, select Design > Templates from the menu and open the desired template for editing.
  4. Within each of these templates, enclose the desired parts with the <mt:AutoSmileys> ... </mt:AutoSmileys> block tag.
  5. Republish your site.

So for instance, if you wish to have AutoSmileys replacement on your entry main body, edit the Entry template as follows:


Anyway you may also put the whole HTML body inside the AutoSmileys tag. This would also apply AutoSmileys to comments, since the Comments module template is included into the Entry template.

For general installation instructions concerning Movable Type, see


Once you have installed AutoSmileys, sign in to your Movable Type CMS and open the Tools > Plugins page. Whithin the AutoSmileys 0.9 panel, expand the Settings tab. By default, it will look as follows:


On the top of the form you may define HTML tag names whose content will be ignored in order to avoid inappropriate image tag placement. The list beneath consists of text abbreviations (tokens) and associated image source URLs.

Default smileys are taken from *thx*

You may change these entries as you like and you may also expand or shorten the list by clicking on the [+] and [-] links on the right hand side (JavaScript required).

The list may be expanded with up to 40 rows by default. You may increase the related parameter maxRows by editing *hack*


Remember that MT tags are applied after any text filter you may have set up for entries or comments. Hence, text filters such as Textile and Markdown would replace stuff like *lol* before AutoSmileys has a chance to see it.

Also, note that tokens are recognized only in the way you have defined them after standard HTML entity replacement has been applied. That is, &#58;&#45;&#41; will be displayed as :-) but not replaced.

How it works

The heart of AutoSmileys is a regular expression, dynamically created from the mappings of tokens to URLs defined as above. Once having these mappings collected within a Perl hash called %mappings, it's built as follows:

my $re_pattern = join '|',
  q/<(!)--(?:.|\n)*?-->/,          # markup comments
  q/<([^\s>]+)[^>]*?(\/)?\s*>/,    # markup tags
  map(quotemeta, keys %mappings);  # smileys

On a reasonably valid markup code this will replace any tokens outside markup tags, especially ignoring the content of specified tags inapplicable for containing image tags. Then,


does the job, using the following callback function:

my $expect;
sub re_callback
  my ($match, $comment, $tagname, $selfclosed) = @_;
  return $match if $comment || $selfclosed;
  if ( defined $tagname ) # non-self-closing markup tag
    $tagname = lc $tagname; # ignore case
    if ( defined $expect )  # within ignorance state
      undef $expect if $tagname eq $expect; # end ignorance state
      return $match;
    $expect = qq</$tagname>
      if exists $ignoretags{$tagname}; # begin ignorance state
    return $match;
  return $match if defined $expect || !(exists $mappings{$match});
  &{$Defaults->{image_tag}}($mappings{$match}, $match);

Here, $Defaults->{image_tag} is the actual image tag function. That's it 8-).



cool 8-)

Guess which one is my favourite.

It is of course this one: *hack*


post a comment

Leave a comment
You may use HTML tags for style