Ben Godfrey

Archive for July, 2002

upd

Chinese music archive, has MP3’s and AU’s. I want to use some of these sounds in Live to make crossover sino-electro madness.

Since last posting I went to a wicked party and DJ’d with three turntables and my laptop using Live. It was cool, if a bit too experimental.

I’ve also upgraded Fortyfive (our firewall/NAT machine) to use a much better interface to the ADSL modem. No more kernel panics! Phew. Currently I’m upgrading to Debian 3, which is twatting my internet radio MP3 listening rather badly.

Fixed ADSL!

Kind of, more later, very tired…

Mo Uploads

Had a bit of a crazy night tonight. Ben Tullis is attending a week long course on C++ in London for work and had to catch a train at 6:30. He’d left his bag at Thickthorn so I offered to drive him to the station via there. At dawn I’m usually slipping away, but after 3/4 hour driving I’m nearly dead. Oh well, he got his train OK and lent me his camera to boot.

I’ve also added two things to my content section. One is the game I made for Louise’s birthday last year. It’s javascript and very very very simple, but it was hanging around on Hype still and I thought it would be more at home where it is now.

The other item today is Blocks. I’ve been doing some design for a client, using the old 45 angles and primary colours. I find trying to do real design quite inspiring. If I mess up and rotate 60 or apply some kind of explosive filter in Illustrator the results are unusable but look really good. Blocks is a prime example, I’ve taken the elements from my commercial work and created an interactive Flash toy that has no usefulness whatsoever. Move your mouse to make the colours change.

CV

I have put up my CV. The reason I started building this site in the first place was to act as a central point for me to promote myself and share what I’m up to, a CV was always going to be part of that.

Please feel free to comment (nudge nudge, Charlie, wink wink).

Ain’t no stoppin’

Hackfest 2002 continues. This week I have been writing a C++ program that is a replacement for the ancient Unix command-line app calendar. It uses an XML config file which I’m parsing with Expat, although I may replace this with Apache’s Xerces. I’ve kind of got a bit lost on this one. It’s basically functional, but very basic. I need to think more carefully about the algorithm used to process nodes. At the moment it’s getting messy, but as long as I work to standardise the way I discover node context (SAX parsing here) I should be OK. Then it’s just a case of calculating the right Unix timestamps and comparing them. It, like calendar will extrapolate information about repeating events based on what data you specify, so if you specify only a weekday, it will assume that your event runs all day and repeats weekly.

Also I have beautified my mail page. It is now bright pink. The background image invites the prospective emailer to consider both them and I as monotone pink buxom underwear models from the Sixties. I like it. Also the error messages have a certain pinned-on afterwards punkness about them. I’d like to thank Mat Denney for the tracing inspiration on that one, ‘cos it’s TME creds-tastic, I only hope I haven’t ripped you off too badly (I kept some texture!). BTW, spot the hidden Mac OS logo…

Once again I’ve made use of my PHP form validation class. I have enhanced it’s ability to generate natural English reports of errors by adding a whole bunch of class members which control the output sentences. This makes it a lot more useful. With the latest version you would probably want to use to_english even if you wanted a ungrammatical list. It is powerful enough and has the advantage that it will parse the error arrays itself rather than you having to write code. When I’ve used it on a few more pages I’ll release it. I keep meaning to make a /software/ area. In fact I need to put my CV up as well.

Hypothetical Objects

Hype 2 will be object oriented. Here are some of the objects:

  • Core
  • Validator
  • Database (PEAR::DB)
  • Autolinker
  • Backlinker
  • Renderer? A wrapper layer around Smarty, similar to WAPHype and the h_drawframe functions from v0.2.

It might be worth using objects to manage the various areas of the site, e.g. one to manage the filestore, one which is the core message handler and another that builds pages with portlets. One thing that would be good about splitting off the renderer would be that this can be used to keep track of all the natural language used, making it much easier to change these strings.

Validator, Autolinker and Backlinker should be totally separate to Hype. Backlinker will basically be an implementation of some of the things suggested for Red Herring by Bluefire on Hypothetical (thanks Bluef!), by keeping it separate it should be possible to grow it until it implements all of Red Herring’s ideas.

Tonight’s Major Hacking Feat

The WAP bit of Hype didn’t work. I fixed it. I’d been meaning to rewrite it ever since the day I wrote the first version. Today I got around to it. It uses Smarty, PEAR, mod_rewrite, WML and a big PHP class (400 lines).

It’s the most recent thing in the Afternoon-becomes-a-master-PHP-coder Hall of Fame. Every time I think about re-implementing Hype (which is often), I think about what would be the best way to do it. With each app that goes into the Hall of Fame, my ideas about the structure of Hype 2 become more specific. For example, mod_rewrite, Smarty and classes are all going to be in there. I’m going to use get_browser() to make sure every part of the site has access to browsercap info.

So what did I learn from rebuilding WAP? Well, the class is nice. I have one script which implements the URI interface with a small switch statement (I used the same exploding to path_tokens approach used here at aftnn). This means that there is a degree of separation between the URIs used and the actual code. However, I still found myself writing a function for each section of the site. I broke some things, like DB access, off into functions, which is good. But before I really crack it I need to break the site-section functions down into blocks and treat those in a generalised manner, ensuring that I’m not having to edit code for 5 sections when I decide to change one minor feature. E.g. the post message and send mail sections of the WAP site are virtually identical, but they use separate functions, same with a list of messages and a list of search results! This is probably a good starting point to continue my quest for PHP-perfection.

One thing that I have been thinking about that would really help this is to push more HTML processing off to Smarty. I often have large, complex blocks to construct pretty HTML or grammatically correct phrases. Whilst the latter is essential, passing arrays and using $smarty->fetch() for anything that is formatted HTML would clean a lot of functions up, especially ones where forms are involved.

At the end of the day a lot of Hype 2 is in the background support. The sections aren’t going to number in the hundreds or anything, it’s the functionality that’s available generally around the site, the personalisation, that really matters. This will be easier to extract out to different functions.

Oh, and I successfully used my XML-based BrochureWare generator to generate a website. I’ve learnt XSLT and XPath in order to put it together. They form an interesting system. I found them really great for creating a dirt simple accounts system. For collecting info about groups of nodes of unknown size and making management-style reports out of the numbers. In order to build my BrochureWare generator I implemented some extensions for Xalan that allow me to create dirs and copy files from the XSLT stylesheet. People on the Xalan mailing list thought this probably wasn’t a good idea, they’re right but it’s a quick and usable hack. If I put much more effort into the system I’ll probably go a different route. If I get it to that romantic state called finished I’ll put it up for download.

All in all it’s been a successful couple of weeks of hacking. I’ve completed at least four major tasks. I’ve been acutely aware recently of how rarely I actually finish things. It’s spurred me to go that extra little bit further with things like this journal and the WAP service.

Blanket

I felt so sorry for my friends getting banned from Hype because we use the word fuck so often that I wrote a nasty words filter that they can use to view pages.

This was relatively simple to write in PHP (view the source), just a file() instruction and a bunch of regular expressions really. The RE processing makes it quite slow on big pages (Hype for example). It has no support for cookies or HTTP post either, which handicaps it a bit. However, I’m hoping the semi-experienced web user should be able to work around this. It has an issue with links to binary files as well, it tries to read and sanitise them like normal HTML. Getting around this would mean using CURL to grab the Content-type header. This would provide a framework to solve the cookies/post issue as well though.

At some point I will knock out a version 2 using CURL, but for now I have other (more lucrative) fish to fry.