Back when I used Typo, I enjoyed having the Tags sidebar module available to show that I only really write about three subjects on any regular basis. However, while Mephisto did come with tag support, I couldn’t make them different sizes, forcing users to actually read tiny numbers if they wanted to know which categories were bigger. So, (since you know how I roll), I had to figure out how to do it.

Grapher showing logarithm function

Basically, a tag cloud is a collection of tags sized by their relative popularity. My favorite function for sizing them is the logarithm, because it doesn’t let big tags get ridiculously far ahead of smaller ones. In particular, I’m using y=(8* ln(x)) + 8 to calculate font size in points (y) from number of articles (x). The smallest a tag can be (with a single article) is 8pt, and at 100 articles it only gets up to 44pt, which is perfectly reasonable for my number of articles. Fortunately, the multiplier is tweakable.

Usage

Here’s my tag.liquid:

{% include 'shared' %}
<h2>All Tagsh2>
<ul class="monthblock">
{% for tag in site.tags %}<li style="font-size: {{tag | tagged_articles | calc_tag_weight}}pt">{{ tag | link_to_tag  }}li>
{% endfor %}
ul>

(the weirdly long line is so that my HTML comes out looking nice)

Getting the plugin

Mephisto supports installing (and keeping updated) plugins right from svn, which is pretty sweet.

I highly recommend the trunk release - there’s not much there to break. (famous last words)

#in your mephisto root
script/plugin install -x http://brycekerley.net/svn/mephisto_tag_cloud/trunk/

Whining about Reporting bugs

Send bug reports to bkerley@brycekerley.net after checking Trac to see if they’re fixed. Ticket submission’s not on Trac because it’s a spam magnet and I don’t feel like putting up with it.