Subscribe to RSS Subscribe to Comments

commafruit.co.uk. welcome.

Site upgrade, Wordpress 2.3.1, Tags

So, I’ve finally upgraded this site to use a version 2.x series Wordpress. This version (2.3.1) includes tagging support built in, which was a big plus for me as I’d be looking at installing something like UTW, but putting it off because I knew I planned to upgrade. Installation/upgrade of Wordpress is impressively straightforward by the way.

Anyway, after going through and tagging most of my entries, it was clear that I had a small number of tags with like 20 posts, and then lots of others with 1-5, which meant I had a list of words with a couple of them highlighted, but unable to see the difference between a tag with 1 post and one with 4. Luckily, I know PHP. :)

The code below replaces the wp_generate_tag_cloud function in the wp-includes/category-template.php file. Essentially, rather than taking the default distribution of number of posts for a tag then calculating the size, it takes the natural log (aka ln or loge), which results in a more even distribution, and so more similarly sized tags!

This code was marked up using the wonderful GeSHi.

  1. function wp_generate_tag_cloud( $tags, $args = ) {
  2.         global $wp_rewrite;
  3.         $defaults = array(
  4.                 ’smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt’, ‘number’ => 45,
  5.                 ‘format’ => ‘flat’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’
  6.         );
  7.         $args = wp_parse_args( $args, $defaults );
  8.         extract($args);
  9.         if ( !$tags )
  10.                 return;
  11.         $counts = $tag_links = $counts_display = array();
  12.         foreach ( (array) $tags as $tag ) {
  13.                 $counts[$tag->name] = log($tag->count) + 1;
  14.                 $counts_display[$tag->name] = $tag->count;
  15.                 $tag_links[$tag->name] = get_tag_link( $tag->term_id );
  16.                 if ( is_wp_error( $tag_links[$tag->name] ) )
  17.                         return $tag_links[$tag->name];
  18.                 $tag_ids[$tag->name] = $tag->term_id;
  19.         }
  20.         $min_count = min($counts);
  21.         $spread = max($counts) - $min_count;
  22.         if ( $spread <= 0 )
  23.                 $spread = 1;
  24.         $font_spread = $largest - $smallest;
  25.         if ( $font_spread <= 0 )
  26.                 $font_spread = 1;
  27.         $font_step = $font_spread / $spread;
  28.         // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
  29.         if ( ‘name’ == $orderby )
  30.                 uksort($counts, ’strnatcasecmp’);
  31.         else
  32.                 asort($counts);
  33.         if ( ‘DESC’ == $order )
  34.                 $counts = array_reverse( $counts, true );
  35.         $a = array();
  36.         $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ‘ rel="tag"’ : ;
  37.         foreach ( $counts as $tag => $count ) {
  38.                 $tag_id = $tag_ids[$tag];
  39.                 $tag_link = clean_url($tag_links[$tag]);
  40.                 $tag = str_replace(‘ ‘, ‘&nbsp;’, wp_specialchars( $tag ));
  41.                 $a[] = "<a href=’$tag_link’ class=’tag-link-$tag_id’ title=’" . attribute_escape( sprintf( __(‘%d topics’), $counts_display[str_replace(‘&nbsp;’,‘ ‘,$tag)] ) ) . "’$rel style=’font-size: " .
  42.                         ( $smallest + ( ( $count - $min_count ) * $font_step ) )
  43.                         . "$unit;’>$tag</a>";
  44.         }
  45.         switch ( $format ) :
  46.         case ‘array’ :
  47.                 $return =& $a;
  48.                 break;
  49.         case ‘list’ :
  50.                 $return = "<ul class=’wp-tag-cloud’>\n\t<li>";
  51.                 $return .= join("</li>\n\t<li>", $a);
  52.                 $return .= "</li>\n</ul>\n";
  53.                 break;
  54.         default :
  55.                 $return = join("\n", $a);
  56.                 break;
  57.         endswitch;
  58.         return apply_filters( ‘wp_generate_tag_cloud’, $return, $tags, $args );
  59. }
Tags: , , , ,
AddThis Social Bookmark Button

A Picture of Manchester

Now that there is finally some content up there, it seems like a good time to introduce my most recent photo project, A Picture of Manchester. This is intended to be extremely light-weight, that is, I’m not desperately worried about the technical merit, more the content and feeling a shot provides. I’m not going so far as to call it gonzo, but that style is definitely part of the inspiration behind the project.

Tags: ,
AddThis Social Bookmark Button

Portfolio Updated

Updated the portfolio section. Looks a lot better than it did a year ago! :)

Tags:
AddThis Social Bookmark Button

addthis.com

I’ve just added addthis.com boxes to all my main sites - very easy, recommended if for anyone running a website.

Essentially, addthis.com provide a widget which allows users to easily add the referring page to the most popular social networking sites. Since the widget is hosted by the provider, they maintain and update it, so if del.icio.us (for example) suddenly change their submission format, or some new service appears, addthis.com will update their end, and I won’t have to worry about it.

Tags: , ,
AddThis Social Bookmark Button

webrecip.es

This idea has been kicking around for months, essentially, webrecipes is will be a recipes database, but since I’ve done nothing for it so far, and I’m not going to have any time to dedicate to the project in the next few months at least, maybe it’s best to announce it now. It’s been sitting online with a little static content for weeks, but with no incoming links.

I really didn’t intend for this thing to stagnate (I’ve got some good ideas - and look at that URL!)

Tags: ,
AddThis Social Bookmark Button

New Wordpress Plugin

I just released my first Wordpress plugin: End of Queue. This is a simple little plugin to warn Wordpress users when the last post in their queue has been posted.

Tags: ,
AddThis Social Bookmark Button

Just Barely There

Recently I unveiled a new website: Just Barely There. This is a blog consisting of free (libre), Creative-Commons-licensed stock abstract images. The plan is to release them at the rate of two per week. Please check it out!

Tags: ,
AddThis Social Bookmark Button

Learn to Backup

I just got shown this the hard way - made a mess of my tables, and just had to rebuild my Wordpress categories table by hand. It could have been so much worse though!! I will definitely be making regular backups in future.

The other thing is name change to the site. It’s temporary, I promise - just an experiment to see how high I can climb on Google. I’ll take it off next week.

Tags:
AddThis Social Bookmark Button

Ads.

And so it is, that I’ve added Google AdSense ads to both this page and Peterborough in Winter. How much difference it will make I don’t know, but here’s hoping as little as possible to the user experience, and maybe a little to my wallet. We shall see.

Tags: ,
AddThis Social Bookmark Button

Peterborough in Winter

I’ve just finished setting up Peterborough in Winter, a new photoblog, check it out now…

Tags: ,
AddThis Social Bookmark Button

I Love last.fm

Last.fm are cool enough as it is, let alone mentioning that they provide data feed access, including XML and RSS. I’ve just got around to installing WP Audioscrobbler (check it out on the right), and am so pleased with the results! :)

Tags: , , , , , ,
AddThis Social Bookmark Button

Deviantart.com

I submitted a new piece to DeviantArt yesterday - haven’t done that in ages. It used to be that I would submit all manner of stuff (especially to my old account), but I think now I’ll just use it for more “arty” type things.

New “Peterborough” page coming soon for more traditional photography. This is partly an extension of the plans I had for Manchester (now somewhat defunct - at least until September 2007), but also inspired by a project by Kathleen Connally.

Tags: ,
AddThis Social Bookmark Button

Hiatus Over

Typical “new blog” trick: I haven’t updated in a month. This little break was planned, it’s just the break went on for longer than I’d planned. It’s been a busy month, many exams at uni, moving out of my old house, finding a new place (in a different town), end of year parties etc… Anyway, there are a few things I still have to write about, so this is a quick way of getting myself back into posting. Soon to come: new photographs, books (might lump these all together in one entry), couple of new recipes, Last.fm, kottke.org, maybe some talk about web development/design – what this site was supposed to be for – finally?

AddThis Social Bookmark Button

Making Money On-Line

Found this article on stromcode about making money from running a website (naturally, the bulk of the text focuses on advertising). While that’s not something I had in mind when I set up this site (or in any web-based venture I’ve started), it made me think about the possibilities. As the article says however, making money on the web is hard, so maybe it’s good that this isn’t my primary aim.

Tags: , ,
AddThis Social Bookmark Button

New photography section

Just set up photography.commafruit.co.uk, for posting photographs; this is for more polished photos that I’ve taken, rather than the snaps that appear on this page.

I had been going to build a browser in the style of soupisgoodfood, but after playing with F-Spot’s web gallery export feature, I decided to just use that. Check it out…

AddThis Social Bookmark Button

Site Update

Finally set up some proper hosting for the site. Penguin Internet Ltd. are hosting. I’ve installed Wordpress 1.5 (with the intention to upgrade to the 2.x series soon), and the (I think, awesome) Fluidity theme from Kaushal Sheth, based on Dave Reeder’s original design.

Tags: ,
AddThis Social Bookmark Button

Based on FluidityTheme Redesigned by Kaushal Sheth | All content by Ben Parsons unless otherwise stated | Askimet has filtered: 179 spam messages.