Shorter Link: A rev=canonical WordPress plugin

11th April 2009

Hot on the heels of my No DiggBar, I've created another extension for WordPress!

Shorter Links provides a <link> tag in the <head> section of your page with a shorter url and appropriate tags for use with the new revCanonical system. Further details can be found at laughingmeme.org, shiflett.org or benramsey.com.

The link created looks like this:

By default, the shorter url is simply {your domain}/{post id}, but the plugin also creates a custom field called "Shorter link" once a post is saved, so that you can change the shorter link to a more memorable set of characters.

Rather handily, Simon Willison, has produced a bookmarklet called Shorten so you can find out if the page you are looking at has a shorter link or not.

As an example, my Zend Framework Tutorial page has a canonical URL of http://akrabat.com/zend-framework-tutorial. I have set up a Shorter Link of http://akrabat.com/zft which will redirect to the correct page. The <link> tag for this is:
<link rev="canonical" rel="alternate shorter" href="http://akrabat.com/zft" />

Why not download Shorter Links and have a play?

Digg bar blocker for WordPress

10th April 2009

The DiggBar is a URL shortening service that puts your website within a frame on digg.com. As a result, the user sees Digg's URL, rather than your URL in their address bar, no matter which page they navigate to on your site.

I don't particularly like this, so I've written a small plugin for WordPress that removes it. Go to the No DiggBar page to download it.

Tip of the hat to John Gruber for the idea.

Update: The No DiggBar plugin is now available from the WordPress Plugin Directory: http://wordpress.org/extend/plugins/no-diggbar

Fixing -- in WordPress

21st March 2009

One thing that I've noticed is that whenever I used -- in a post, such as this one, WordPress converted the -- to &emdash; which whilst very pretty doesn't work so well for people trying to understand command line switches to ./configure!

Today, I finally got around to poking into the WP source code to work out what was happening and I tracked it down to the wptexturize function in the wp-includes/functions-formatting.php file. Once I knew the name, it was trivial to google for a solution and I found Jason Litka's Disable wptexturize plugin. I couldn't find it through WordPress' new built-in plugin installer, so I installed it the old-fashioned way and now the code in my posts will make more sense!

Busy

4th August 2008

I'm kind of neglecting this blog at the moment. Sorry.

I was away last week and I'm head down into editing Zend Framework in Action. It's amazing how many details the technical proof reader and our copy editor have found. The book is going to be so much better as a result. I need to go through each suggestion though and ensure that the meaning hasn't changed and to implement the suggested technical changes.

When I get a little time, I'll try and write up what I've learnt recently about testing with Zend_Test_PHPUnit_ControllerTestCase which has reduced the testing scaffolding that I had by around 50% or so.

License for code published on this site

25th June 2008

A few people have asked me, so I thought I'd better make it explicit.

All non-trivial code on this site is released under the New BSD license as noted here.

For code examples that are a line or two long, I consider them added to the public domain.

Downtime

17th September 2007

Just a heads-up. Tomorrow, this site is being moved to a new server and so is going to be down for most of tomorrow from around 10:00 (GMT) to late evening.

Upgrade time

26th February 2007

Just a quick note to warn you that the server that akrabat.com runs on is going to be upgraded tomorrow, so expect serious downtime as we see what happens when you go from FC-old to FC6 !

All should be back up and running by the evening though!

New Theme

14th January 2007

Thought, I'd have a go at understanding WordPress themes! The image at the top is an actual road sign on my way to work, which has unfortunately been removed by the council.

If you see anything broken, let me know please as I've only actually tested this in Firefox! (I know it's broken in IE...)

Wordpress 2.0 Rewrite Rules

18th January 2006

We recently upgraded my wife's blog from WordPress 1.5 to 2.0 and it broke the mod_rewrite rules used to support the legacy Movable Type urls. When she migrated from Movable Type to WordPress, we moved to /{year}/{month}/{day}/{slug} type urls from the default Movable Type rule of /archives/{id}.html. We read the manual at the time and put the following into the .htaccess file:

RewriteRule archives/0*(d+).html /index.php?p=$1
RewriteRule index.rdf /index.php?feed=rdf
RewriteRule index.rss /index.php?feed=rss
RewriteRule index.xml /index.php?feed=rss2

and all was well...

Then we upgraded to WordPress 2.0.

They stopped working because WordPress 2.0 does it's own mod_rewrite. I worked my way through the source code and modifed the core stuff and got it working. Then I started trying to find out how to do it properly without modifying the WordPress source code. I finally found a post on the support forums from someone trying to do something similar and modifed the solution to work for me:

Add the following to a file called functions.php in your theme directory:

function mt_filter($rules)
{
    $rules['archives/0*(\d+).html']
                = 'index.php?p=$matches[1]';
    $rules['index.rdf'] = 'index.php?feed=rdf';
    $rules['index.rss'] = 'index.php?feed=rss';
    $rules['index.xml'] = 'index.php?feed=rss2';
    return $rules;
}
add_filter('rewrite_rules_array', 'mt_filter');

and that's all there is to it.

Fairly obvious I would think if you know how WordPress works. There's probably a very handy article somewhere on wordpress.org detailling this, but I couldn't find it... probably didn't look hard enough!

Is this thing on?

23rd January 2005

Akra's DevNotes is where I intend to write about my development life. In general this means that I'll be talking about PHP coding as that's what I do most of my development in at the moment.

I currently work for Campbell Shaw and also do a little bit of freelance work for my old company to help them out maintaining code that I wrote for them. In my spare time, I am (slowly!) writing some plugins for CMS Made Simple, a remarkably easy to use Content Management system.