php

Status.net Word Filter Plugin (Wordfilter)

The TWiT Network has pretty strict rules about profanity across all channels including the netcasts, chatrooms and the TWiT Army Canteen. There are usually moderators lurking the IRC and microblog but once in a while some profanity gets through the cracks. Therefore I wrote a little word filter to preempt the profanity.

CodeIgniter CSRF (XSRF) library

They say a lot of developers work on things to scratch their own itch. This is me scratching.

I'm a fan of the CodeIgniter project but I find it odd that such a well developed framework lacks CSRF protection in the core. There are a few CI CSRF libs but most of them are outdated so I wrote my own. A few ideas came from Michael Wales' toolkit but this library is written from scratch. One of the major differences is that this toolkit uses form IDs instead of a timer to handle forms in different tabs which I find more robust since it doesn't rely on time.

Download csrf-v4.tgz

Status.net Plugin Developer Helper Plugin (PDhelper)

As with most open source projects, the Laconica (now Status.net) team focuses much more on development than documentation. That's not necessarily a bad thing for the project but makes it harder for third party developers. I had to use a lot of trial and error when working on the TWiT Army Laconica Plugin.

Here's where I had some trouble:

  • Finding the right hook to insert elements in specific places
  • Determining the 'action' name for the loaded page
  • Figuring out how to remove elements

For the last one, it turns out that returning bool FALSE for some hooks will prevent the default output. That was a good idea by the dev team. As for the first two, I decided to create another plugin that just spits some markers and useful PHP object data. You can see a demo of this plugin on my Status.net test site: status.kylehasegawa.com. Some of the markers are not in the body element so these markers are added as HTML comments. View the source of the test site to see these markers.

Comments, feedback, and suggestions are more than welcome. Full source code below the break.

Update v0.3 2010/01/05

  • Status.net v9.0 support (tested on 0.9.0rc2)
  • XHTML now mostly valid (<!DOCTYPE is not on line 1)
  • Other minor enhancements

TWiT Army Laconica Plugin

I was recently asked by my friends over at the TWiT Army to checkout the new Laconica plugin system in version 0.7.2.1. They wanted to know if it could be used to modify the default Laconica output on the TWiT Army Canteen, a feature currently handled by Javascript after the page is loaded. Javascript was used because it saves them from having to modify core code since core changes complicate upgrades. The downside of Javascript is that users see a brief flash of the original output before the JS runs. Another problem with JS modifications is that users who disable JS won't see the page as intended. I doubt anyone besides the TWiT Army will actually use this plugin but it's a decent example of how to use the plugin system so I hope it will be helpful for someone.

What the plugin does

  • Inserts 'apple-touch-icon' link in <head>
  • Adds 'helmetlink' and 'logolink' divs
  • Adds 'toplinks' and 'toplinks2' divs and lists (Live, Leoville, ODTV etc.)
  • Adds 'watermark' and 'bugle' div
  • Replaces nav links (tabs) on some pages

Edict SQL generator sourcecode

This is the source code for the script used to generate the Edict SQL file located here.

All code on this site is free for use at your own risk and provided as-is under the WTFPL license unless otherwise stated. Attribution is appreciated but not required.
Blog content, with the exception of externally quoted material, is licensed under the Creative Commons Attribution 3.0 license