I make tools to help people create wonderful things.


How embarrassing

Three months since I last posted on this site, and all of those early posts were just about setting the site up. Seems lie the site's a bit pointless, really. Not that I've been sitting idle; I've been snowed under with academic work. I'll get something interesting up here eventually, I promise.

For now, let it be known that I am procrastinating my exam revision by upgrading the site to Drupal 4.6.

Spam, spam, spam, spam....

The site's only been up for five days and I'm already getting referrer spam. No comment spam yet, but I'll probably disable comments and trackbacks until I have some interesting stuff up, and sort it out then.

Thanks to some helpful advice on Caveat Lector I used a bunch of Apache .htaccess rules to filter out domains containing spam-like words. It's likely that there will be some false positives but until I find another way, it'll have to do.

In other news, Drupal's project module is giving me trouble; it refuses to track my projects' releases. I think it's PostgreSQL compatibility-related, but the exact reason is proving to be difficult to track down.

GeSHi Code Filter module

I couldn't find a Drupal module to syntax highlight C# code, so I made one. I'm using the Generic Syntax Highlighter, GeSHi, to drive a filter loosely based on the codefilter module. While doing this, I discovered Nonstop Bits' Nonstop HiLighter module, which highlight many more languages, but I think GeSHi produces prettier output colours :). The next version will be supporting mixed-language files, such as PHP, CSS and JavaScript in XHTML, which looks amazing. It's also very configurable and can output line numbers and XHTML Strict/CSS code, and it wouldn't be hard to add options to the filter to turn these options on.

Using the filter's fairly simple. Once it's installed and registered to an input format, just surround your code with <code language>...</code> tags. Supported languages are actionscript, ada, apache, asm, asp, bash, caddcl, cadlisp, c, c_mac, cpp, csharp, css, delphi, html4strict, java, javascript, lisp, lua, nsis, objc, oobas, pascal, perl, php-brief, php, python, qbasic, smarty, sql, vb, vbnet, visualfoxpro, xml.

Here's some PHP:

function GeSHicodefilter_process_code($matches) {
  // Include the GeSHi library
  // Make a new GeSHi object, with the source, language and path set
  $path = module_get_path('geshicodefilter').'/geshicodefilter/geshi/';
  $geshi = new GeSHi($matches[2], $matches[1], $path);
  //GeSHi settings
  //dump the code!
  return $geshi->parse_code();

and some C#:

///<summary>Resizes the world</summary>
public void ResizeWorld(int w, int h)
	gridWidth = w;
	gridHeight = h;
	//Setup new grid
	CellGrid = new int[gridWidth, gridHeight];
	oldCellGrid = new int[gridWidth, gridHeight];
	//configure drawing bitmaps
	//seed the world with cells

Pretty, isn't it? You can get the module from its project page.

I also found a modified wiki module that uses GeShi to highlight a couple of languages, but it's not completely general. I think I'll just modify the Wiki module to ignore anything inside a <code> block (it insists on escaping it all at the moment!) and the GeSHi filter can sort out whatever comes out.

Progress is a good thing

I wasn't quite as far as I thought I was.

There were still a few PostgreSQL bugs in Drupal that I had to fix before getting on with theming the site. This turned out to be too big a task for an evening so I modified the Drupal port of Michael Heilemann's Kubrick theme, changing the title picture (anyone recogise the mountain?) and the footer, hacking the template so that the sidebar vanishes if it has no content, and making a few other tweaks. Personally I still have my reservations about a fixed-width layout like this - even though it's very pretty - so when I have time I'll fix it up to use relative units.

Additional modules I've installed now are the PHPTemplate theming engine, the Article, Trackback, Wiki Markup and Project Management. There's not really much else I need, though I'd like to be able to add screenshots and documentation to the projects.

I turned on comments for completeness, though I don't expect to recieve any yet. It does mean I'll have to be on the watch for comment spam but I don't think the spammers know about my site yet. Anyway, Drupal offers a Bayesian spam filter when I need it.

And so it begins...

I've been wondering for literally months how to set up this site. I almost went with a custom coded solution but Drupal's logging and modular 'plug-in features' were ultimately too alluring. The critical question, as always - what would be the best layout? Which modules to use to categorise and display my projects? How do I make all these features work together?

I finally got around to setting up the site properly. My year-old half-baked installation of Drupal should now be fixed (I've reinstalled it several times playing with various configurations) and set up to do everything I want it to. I had to use a few modules, several of which had to be ported to PostgreSQL, but overall the installation process was quite easy. The categories, blocks and links are all set up and all that remains is to create a theme. Then the content can be rolled in...


Subscribe to Journal