10 April 2009

blocking the DiggBar in Habari

Challenged by RandyWalker and inspired by John Gruber's post about blocking the DiggBar, I whipped up a quick plugin to do just that for Habari.

After all, why should all the other blog engines have all the fun?

But I'm getting ahead of myself. The DiggBar is a new feature that adds lots of great features to pages and sites linked on Digg. And to do so, it shortens the URL (to one starting with http://digg.com/) and loads the target in a frame.

In a frame?! I thought we were done with frames half a decade ago.

There are myriad reasons why this is a bad thing, and not all of them involve Digg stealing revenue, and other sites have covered it better, but in short, it's a bad thing.

So, how can you avoid it framing your Habari site?

DiggBar Blocker

You can download* it here: Current Version.

Unzip that in your /user/plugins/ directory, and activate it in your admin plugins page.

By default, it will provide a brief message ("This site does not support use of the DiggBar.") and a link to the correct page with your URL on it. I also added an option to bypass the nice message, and just reload the target outside of the bar.

If you have questions, comments, suggestions, please leave them below or submit a ticket on the Habari-extras Trac.

* Or view the source here.

14 May 2008

word count plugins for habari

November's still five three months away, but I'm thinking ahead. I've written two simple plugins for Habari that will let me easily see how many words I've written* toward the 50,000 word goal of National Novel Writing Month. These plugins provide a quick and easy tally of words used in individual posts and all posts with a given tag.


version 0.5 of Habari or later


These will always link to the most recent versions:

Word Count by Tag

Post Word Count

Installation and use

Word Count by Tag

Unzip wordcountbytag.zip in /user/plugins. Then activate and configure it in the Plugins Admin page. If you leave the 'tags to include' box empty it will count all words from published posts with all tags. The words in the posts' titles can optionally be added to the total.

Here how to add it to your theme (no need to echo):


Post Word Count

Unzip postwordcount.zip in /user/plugins. Then activate it in the Plugins Admin page. It will count all of the words from the post, and the words in the post's title can optionally be added to the total.

Here is the template tag for adding to your theme, inside the posts loop:

echo $post->word_count;

Comments and questions should be left below. Subsequent updates and releases will likely appear on the plugin page, not here.

* Or rather, how far behind I am, if my typical progress from the last several years progress is any indication.

13 May 2008

geotags plugin for habari

I've written a simple plugin for Habari to add geographical information to a blog. I've used geotags for years* with websites like GeoURL by manually-editing my page headers, but this geotags plugin automatically inserts the correct tags in every generated header.


Using version 0.5 of Habari or later, all you need is this line somewhere in the <head> block of your theme.


If you are using one of Habari's default themes, then you are already set.


This will always link to the most recent version: geotags.zip

Installation and use

Unzip geotags.zip in /user/plugins. Then activate and configure it in the Plugins Admin page - you will need to know your latitude and longitude in decimal. To find them you can use My Geo Position.

Once the plugin is installed and configured, you're done. Your headers will now display your position like this (the location of my site):

<meta name="DC.title" content="mikelietz:fine whine">
<meta name="ICBM" content="40.076665, -82.95996">
<meta name="geo.position" content="40.076665, -82.95996">

Comments and questions should be left below. Subsequent updates and releases will likely appear on the plugin page, not here.

* Whether or not they've ever been useful is, I suppose, a question I've never really asked. They've certainly got potential to become something interesting, or at least useful.

21 January 2008

a creativecommons-licensed interesting photo findr for flickr

The more I play with making fake CD covers from flickr photos, the more I get frustrated by the sheer number of interesting photos that are unusable because of their creators' chosen license. I realize that if I emailed them, many wouldn't mind me using their photos for something like this, but that seemed like it would be so much trouble.

So instead I programmed a little script to find only the usable shots, and made a page for it. Took me a couple hours, give or take, to get it working.

To be more specific, here's what you might want to know about what I did.

Flickr photos can be licensed in a number of ways, either through the default "© All rights reserved" that regular copyright protection grants, or through the more flexible and friendly creative commons licensing with its many permutations, including requirements for attribution, non-commercial and commercial use, and even the licensing of derivative works. So what I needed to do was take the five hundred photos flickr picks each day for their "interestingness", and filter out anything that was marked "all rights reserved" or "no derivative works". Fortunately those happened to map to the integers 0,3, and 6, which meant filtering them out was a simple modulus test*. Calculations aside, the rest was a matter of a few hours' work and the phpFlickr documentation to get a working script that wouldn't hammer my server, nor get me banned from flickr's.

So all it does is check 3,500 of the last seven days of interesting photos, and from those, screens out the usable ones. From my quick observations, the percentage of correctly-licensed photos chosen for their interestingness is under ten percent. Which means that hopefully I can save people some time. The one that it picks, at random, is ready to use.

Click here to try it for yourself.

Go ahead and put your comments and questions below. I'm releasing this as a 0.1 version - I know there is much more I'd like to do with it, but since it works, I figured I'd get it out there for people to play with. My source code is messy, but eventually I'll get the relevant bits of it posted too.

* At the risk of sounding too nerdy, modulus is, and has been, one of my favorite mathematical operations. It's just a fancy name for "the remainder", but since that sounds like something out of elementary school, I think everybody calls it the much more impressive "modulus". It's wildly useful (or at least, I've used it a lot), and, well, I've used it a lot, probably more than multiplication and division combined, in my programs over the years.