Matthew Bull

web development

Lego NXT and Java

August 7, 2008 – 07:25 GMT - Matthew Bull

I bought a Lego NXT kit a couple of years ago, but beyond getting it to run around vaguely bumping into things and getting stuck, I’ve never really done much with it.photo

The main problem was the software. The NXT comes with a graphical programming environment called NXT-G. It’s a lovely idea and works really well for simple things. But if you want to do anything at all beyond that it starts to become a serious headache. You end up with wires and blocks and all sorts of things all over the place, mostly not actually viewable without doing some serious scrolling around.

Call me old-skool, but I like to code with words in a text editor. I can see that the NXT is aimed mainly at kids (including big kids), so the thinking seems to have been that kids can’t read or something. I’m not sure. When I was a kid I coped very happily with BASIC.

So my search led me to the leJOS website. leJOS is basically a cut-down version of java with some NXT classes thrown in. Finally I could code in words, in a way that I’m used to. Finally I could write more sophisticated programs than ‘move forwardu till you hit something, then stop’. Hoorah!

But that’s when the apathy hit me, as it probably has done with many a self-taught student before me. It’s all very well having the resources, but do I have the time to work out what it’s all about? Where do I start? Without any course, books, ideas, or structure it can be hard to do anything much.

Brian Bagnall’s excellent (if occasionally buggy) Maximum LEGO NXT: Building Robots with Java Brains came in.

photo

It tells you about the NXT brick and bluetooth, how to write code for the NXT, and even some ideas for building robots that do interesting things. The first one you get to build (see my photo above) moves around until something blocks its path. It then scans around for an open path, and heads off in that direction. A nice example, and only a few lines of code. How you’d code that graphically I daren’t even begin to think. A tangled mass of data wires and blocks, probably.

Time to build my first Turtle!




CushyCMS

August 5, 2008 – 22:43 GMT - Matthew Bull

CushyCMS is a very nice little ‘CMS’ tool/service that lets you edit content on your pages easily and simply. It’s by a small Australian startup (another Australian web company?!) called Stateless Systems.

To call it a CMS is perhaps a bit much. It’s basically a clever and lovely way for you to edit content on a static webpage via FTP, along the same lines as Contribute. Oh, so you think Contribute is a CMS, and therefore so must CushyCMS be? Well then I suggest you take a cold shower and come back after the next full moon. For the rest of us, this type of paradigm is nice for editing content, but it certainly does nothing for truly managing it.

Of course Cushy’s nothing like as complex a beast as Contribute, which is in fact a big selling point. With CushyCMS I had a basic page up and edited on my website in just a couple of minutes of logging in. Nice clean user interface, filled with healthy web2.0ness. Nothing scary for a webophobe.

You also don’t have the disadvantage of having to get a copy of all that expensive Adobe stuff, because CushyCMS is not only a web application, but it’s a free one too. There is an option to pay for a ‘pro’ version, which lets you change the design of the editing interface, and thereby fool your hapless web editor into thinking they’re really logged into your/their site when they edit content, and not the CushyCMS site. Is that worth $28 a month?

Before we get too filled with shock and awe, this system isn’t going to be the ultimate answer to CMS woes for everyone just yet. To set it up, you have to have a static page already on your site. This isn’t so much about content generation as it is about content editing.

And you have to manually edit those existing pages to contain bits of html that tell Cushy ‘this is an editable section’. Again, all very similar to Dreamweaver and Contribute. So you need a slightly web-savvy person to set up a site in the first place, and then a webophobe can edit the stuff that they need to.

Another drawback is that you’re very much reliant on their (not open source) software because all content editing is done through the web application. OK, no worse than being reliant on a desktop application that costs bundles of cash, but still… what if the site goes down, or they go out of business. You won’t lose your site, but you will lose your nice little system.

In conclusion, this is actually a very simple system which lets a web developer set up a simple static site and pass over editorial control to a non web-savvy editor. It is not a CMS in any meaningful sense of the word. But it is great at what it does.


acquia

August 5, 2008 – 11:25 GMT - Matthew Bull

Acquia is a company set up by Dries Buytaert, the guy who developed drupal, in an apparent attempt to get drupal taken more seriously by companies and institutions. The idea seems to be that Acquia (carrying on the water theme: druppel means ‘drop’ in Flemish) will provide commercial level support for drupal.

When a company or institution is considering an piece of open source software, having good support is always going to be a Big Thing. You don’t want to base your entire system support on the temperamental lone python hacker in your institution who knows how your open source code really works.

Without this level of support, drupal has until now tended to be taken seriously only by smaller companies and groups/departments within bigger institutions, who can generally manage their own installation.

There are of course tons of companies out there who already support drupal installations, but you have to take Acquia a little more seriously if only because the company is headed by the creator of drupal. There are also other supported open source CMS: Squiz’s impressive Mysource Matrix, and companies such as Netsight who support the normally very intimidating Plone.

It’s hard to tell whether Acquia will lead to a big shift in the way drupal is used, as Acquia seems to be a relatively new venture. Interesting nonetheless, and something worth keeping an eye on at least.


OpenSearch

July 23, 2008 – 10:38 GMT - Matthew Bull

One really useful thing I came across at IWMW 2008 was the ability to put your own site’s search into the browser’s list of search tools. You know, that little google box in Firefox where you can in fact bring down a list of other search engines. That can have your site’s search tool in there too.

This makes use of OpenSearch, a collection of simple XML formats for sharing search results.

Basically achieving your super-cool goal is a very easy three step process. Make a small web-accessible XML file on your web server with the right magic in it, then put a link to that file in your html header, much like you would if you wanted your RSS feed to appear as a button in a browser.

Step 1: work out your own search url

OpenSearch uses a special syntax for the search url, of the form:

http://example.com/search?q={searchTerms}

So for my blog, the search url is http://matthewbull.net/?s={searchTerms}

Step 2: make your xml file

<?xml version=”1.0″ encoding=”UTF-8″?>
<OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/”>
<ShortName>matthewbull</ShortName>
<Description>my blog search</Description>
<Url template=”http://www.matthewbull.net/?s={searchTerms}” type=”text/html” method=”GET” />
<Image height=”16″ width=”16″ type=”image/vnd.microsoft.icon”>http://www.matthewbull.net/favicon.ico</Image> <OutputEncoding>UTF-8</OutputEncoding>
<InputEncoding>UTF-8</InputEncoding>
</OpenSearchDescription>

where the ShortName and Description are up to you, and Url was the url you made in step 1.

Save this as an xml file to your server.

Step 3: tell the browser about your xml file

Now just put a link in your html to tell your browser where your xml file lives:

<link title="matthewbull.net" href="http://matthewbull.net/opensearch.xml"
 type="application/opensearchdescription+xml" rel="search">

And that’s it! Happy searching.


IWMW 2008 - day 2

July 23, 2008 – 09:08 GMT - Matthew Bull

So, we’re into day 2 of the IWMW 2008 conference at Aberdeen. Day 1 passed with much alcohol, dancing, Aberdonian ‘furry boots’, oh and some web stuff too.

I think the highlight was an excellent opening talk by Derrick McClure from the Centre for Linguistic Research at Aberdeen. It was a novel idea to have an opening talk by a linguist about the Aberdonian dialect (doric). But it worked, and to be honest this talk was more engaging than any of the other web-related talks that followed yesterday. I can’t even really remember any of the other talks, in fact.

Another highlight was a parallel session by Michael Nolan of Edge Hill University. They seem to be doing a lot of good healthy web 2.0 stuff there, and seem to have been given a lot of freedom in what they do. Edge Hill is a very new university, where student recruitment is king, and the website is viewed as a crucial tool in achieving that goal.

Edge Hill are using the symfony framework as a kind of php glue to bind together tools such as wordpress mu for blogging and bbpress for forums. They also developed their own google-style portal with php and jquery.

So now it’s day 2, I’m sitting in a boring talk feeling a little hungover. Oh well, it’s going to be a long day…


IWMW 2008

July 21, 2008 – 09:15 GMT - Matthew Bull

Off to Aberdeen today! Hopefully this year’s conference bag will be even better than last year’s…

IWMW spider


symfony 1.1 and 1.2

July 20, 2008 – 18:42 GMT - Matthew Bull

symfony 1.1 went live just a month or so ago, and in the relatively short history of symfony is somewhat of a revolution. In fact, the shift in a minor version number belies the effort and heartache that seems to have gone into the newer version, and one wonders at the implied major revamp that symfony 2.0 would someday involve. It saw the departure of a key member of the core team, as well as some major changes to the architecture of the framework as outlined in the diagram below.

symfony 1.1 architecture

 

The great thing about the platform is that being decoupled the classes can be used in isolation, so you can use some features of symfony and not have to use the whole system. In other words, you can build your own custom framework which uses just the bits of symfony that you want.

All this is great stuff, and should help symfony establish a place as the leading PHP MVC framework.

symfony 1.2 is released

But no sooner had 1.1 gone live than we heard that 1.2 is not just in development, but is actually imminent. The current release date is October, which is not very far off. According to the symfony blog, the main (and absolute must-have) feature of 1.2 is a completely revised admin generator system. Other features include bundling Doctrine with the framework and supporting it fully in the same way that Propel currently is. I’m sure a lot of people like using Doctrine, but for me Propel is just fine, and the differences in performance (at least where Propel 1.3 is concerned) are moot (see this blog for a good comparison

Worth upgrading to 1.1?

So should I wait for 1.2? I have a couple of live apps running under 1.0. They work just fine as they are, and I see no reason to update those to 1.1 just yet, only to go through the same process again in October. I think I’ll start using 1.1 in a dev environment for getting used to the new architecture, new command line system, etc. Upgrading to Propel 1.3 is also going to be a good idea for the performance gains.

I’m left wondering when symfony 1.3 will be out. Christmas?! Actually, my guess is that now that some of the major architectural changes have been made, things should start to settle down a little. Anyway, it’s great to see such activity in the symfony core development team: evidence that symfony is not just alive and well, but maturing very fast.


symfony’s sfGuard plugin and LDAP

June 29, 2008 – 13:54 GMT - Matthew Bull

A while ago I needed to hook up symfony’s excellent sfGuard plugin to some LDAP functionality. There are a couple of issues with the plugin and the readme which I think need fixing. In particular, there is no support for checking both LDAP and standard sfGuard passwords. This is absolutely essential (eg an admin user or guest users who aren’t in LDAP), and I’m somewhat amazed that there’s no provision for this. Moreover, the plugin structure generally makes it seemingly impossible (or if it is possible it’s just too horrible to contemplate) to write your own checkPassword() which does do both sorts of checking.

Anyway this post is partly an attempt for me to get my head round something which I’ve either totally misunderstood, or just isn’t well documented.

 

Confusing README

The README file that comes with the plugin is great, but it’s a little confusing for explaining how you might override its own way of checking passwords with something that’s LDAP-based. It’s really very simple to do when written out in plain English:

1. Make a file called myLDAP.class.php in your application’s lib folder. Put this in it:

class myLDAP extends sfGuardSecurityUser
{
}

2. Now put a method inside the class you just created:
public static function checkLDAPPassword($username, $password)
{
// put your preferred LDAP-checking code in here
// should return true or false
}

3. Add this to your application’s app.yml file:

all:
  sf_guard_plugin:
    check_password_callable: [myLDAP, checkLDAPPassword]

where myLDAP is the file called myLDAP.class.php that you created in step 1 above. checkLDAPPassword is the method you made inside myLDAP.class.php that you made in step 2.

And there you have it. Basic LDAP password checking.

 

How does checkPassword() actually work?

The above code is all very well, but what’s really going on?

Well, there are a couple of steps which I managed to work out:

1. sfGuardUserValidator contains a call to $user->checkPassword($password) where $user is a result of sfGuardUserPeer::retrieveByUsername($username)

2. PluginsfGuardUser (extends BasesfGuardUser) has a method called checkPassword() too. This calls the method you listed in your app.yml file (checkLDAPPassword in this case), or does a standard sfGuard password check (checkPasswordByGuard) if you didn’t specify anything:

public function checkPassword($password)
{
if ($callable = sfConfig::get('app_sf_guard_plugin_check_password_callable'))
{
return call_user_func_array($callable, array($this->getUsername(), $password));
}
else
{
return $this->checkPasswordByGuard($password);
}
}

Which it does depends on how you set up your app.yml file (see Step 3 above).

At this point, if you set up your app.yml correctly you’ll be in your custom checkLDAPPassword() method, which will do whatever you want it to do to check LDAP passwords. So long as it returns true or false depending on whether the check was successful or not, you’ll be ok.

Note that sfGuardSecurityUser class also contains a checkPassword() method. This basically does the same thing as the in sfGuardUserValidator, but in a slightly different way, and allows access to checkPassword() in templates and controllers through the $sf_user object. The important thing to realise is that both pieces of code end up calling the same checkPassword() method in PluginsfGuardUser.

 

So how about LDAP and sfGuard checking?

Now the fun begins. The problem is that it’s seemingly impossible to call checkPasswordByGuard() yourself from inside your custom-built checkLDAPPassword() method. Why would you want to do this? Because that way you can do some standard password checking first to see if your user is in fact a sfGuard user and not an LDAP user. Only if that failed would you do LDAP checking (I suppose you could do it the other way round if you wanted.) Even better, you wouldn’t need to alter checkPasswordByGuard().

So why is it impossible to call checkPasswordByGuard() ‘by hand’? As far as I can see, it assumes that you’re not in a static context, and that you have some kind of user object available. But of course, my checkLDAPPassword() is in a static context. It had to be that way because it was called by call_user_func_array() which uses the output of sfConfig::get() as an argument.

Sigh…

If you find a way of doing this, please let me know. Losing the will to live is merely one of the symptoms of battling with this sort of thing. I have a life to live.

All I can suggest to you in the meantime is to modify your copy of PluginsfGuardUser.php to allow both sorts of password checking. That’s what I did and it worked for me. It’s just a pity that you can’t override the checkPasswordByGuard() method in some way without changing the core of the plugin.


Matrix GUI, asset builders (and mums)

June 20, 2008 – 22:34 GMT - Matthew Bull

After fun and a few frustrations sorting out designs in MySource Matrix in my last post (probably mostly caused by me not knowing what I was doing, and with limited time to sort things out), I’ve been looking at the overall user interface for editors.

The interface is possibly a tad intimidating for some (could you imagine your mum using it?), but the great thing about the system is that it’s flexible enough that you can build your own very simple content edit interfaces.

Lots of buttons and flashing lights…

The thing to remember here is that MySource Matrix is a powerful system, with all kinds of features on all kinds of screens. Tickboxes, drop-downs, options, buttons all over the place. It’s great, but it’s complex. And as we all know, making something easy to use is a real trick. Just think back (if you can) to the days of video recorders that no one knew how to use because they made actually fairly simple things seem very hard to do. It’s the kind of thing companies like Apple have spent decades trying to perfect.

Actually the developers of Matrix have done a reasonable job, and in any case much of the interface is only for system administrators (like me) setting the thing up.

But if all you want to do is make a new page with some text, images, and links in it (this must be like 95% of all web pages) you don’t need or want to know about all the fancy stuff in the backend, all the different types of assets, etc, etc. You probably don’t even want to know what an asset is. You just want a nice box you can type stuff into, press a button, and away you go. You want something like wordpress with all its web 2.0 goodness.

Asset builders and simple edit

Thankfully Matrix has two features which you can get to work together to build a simple editing interface the way you want it.

The simple edit interface is basically a way of allowing users to edit a page without all that backend admin stuff. On its own it’s a nice feature, but not much use if you actually want to make a new page. Asset builders are really the other side of the coin, because they give you the flexibility to allow any user to add in whatever new assets you want them to add.

So, make a new page with asset builder. Edit it with simple edit.

I have to say that I haven’t tried getting them to work together yet. I don’t even know to what extent that’s possible. What would be nice is to be able to make a new page and edit it at the same time, then either publish it or save it for later if I don’t want it to go live. That’s what I’m doing now in wordpress. That’s what google docs does. It’s intuitive and quick. That said, I’m probably hoping for too much, because bolting something that simple onto what can often be a considerably more complex process (think workflows, nested content, etc) is a real problem.

Summary

Matrix offers a very comprehensive and rich backend interface. If you want something easier for your users you can build your own very simple frontend new page/edit interface, which is a really nice feature. Users still have to go into the admin interface to delete or move those pages, and do other fairly simple operations.

I’d love to see a friendlier backend interface to Matrix, and I have no idea if that’s planned for Matrix 4 (due out sometime next year apparently). Sprucing it up somewhat would certainly turn it into a pretty much unrivalled open source CMS.


MySource Matrix design

June 18, 2008 – 15:27 GMT - Matthew Bull

I’ve been playing around with mysource matrix on my laptop recently, as an early development stage to our pilot while we’re waiting for the server hardware to be set up.

One of the first things I’ve been looking at has been setting up designs, and I have to admit it’s been a somewhat mysterious process.

OK so I haven’t been on Squiz’s design training course, but I have taken a long hard look at the 94-page design manual (to their credit, Squiz have about 1300 pages of documentation, most of which is freely available.)

Part of the problem is our pretty complex set of css files. The other part of the problem seems to be the way mysource matrix deals with links to images in css files. Suffice to say that getting an existing design into mysource matrix isn’t much fun. Once you’ve got over that hurdle, performance seems to be an issue.

A far easier option is just to lift your static template, pointing to all those static css files and images sitting on your live webserver. In fact this works just great, and it’s what I’m now doing. But something makes me feel it’s not the ‘right’ way to do things. I should point out that I may have misunderstood something in how to set things up, so this review may not be entirely fair. Apologies in advance it that’s the case.

If you enjoy pain, and want to share some of mine, read on…

Getting Started

Let’s say you have an image that you want to call from a css file with something like

background-image:url(images/snap.gif)

How does matrix know where images/snap.gif lives? Unless it’s living somewhere on a publicly accessible web server, it has to be uploaded into matrix. You can then refer to it as mysource_files/snap.gif, and the system will know what you mean.

If this sounds simple enough, then wait. There’s much more. By the end of this you’ll think having teeth pulled is a fun experience. Read on…

CSS Files

You first have to tell matrix that each css file which has a url() is an asset, not just some static text file sitting there. OK, so I go through all 30 of my css files that are like this, creating them as children to my main design. Something is making me feel uneasy about this, but I carry on anyway.

Images

Right, now I have to make all the images that are referred to in each css file children of the corresponding css file. Ugh. Yep, well I don’t have anything better to do, so I reorganise all my images according to the css file they appear in. Some images in more than one place, but oh well I guess I could make them as copies if only I could remember which css file I already uploaded them to. Whatever. I battle on.

The process continues for some time…

Cool. It was painful, but now I have all my css files uploaded, with all their corresponding images. I’ve changed the css files to refer to mysource_files/imagename.gif rather than their original url.

Now I need to link these files into the main design. It turns out that I can’t actually do this directly. I have to create special design areas in the main design which point to the css files.

OK, not too bad? Erm, well it’s not that simple. I actually also need to put in what’s called a customization which acts as a bridge between design and css files, and it’s that thing which point to the css assets themselves. This feels very wrong, but I carry on.

Too slooowww…

Hoorah! Now after a few hours persistence I have a working design. I test it out. After about 8 seconds, my page loads with the correct design. Hoorah again!

Then I stop and think what’s just happened. 8 seconds? Hmmm, ok well I know this is just on my macbook, but that’s really a tad slow isn’t it?

At that point I realised that there’s a lot going on here. You can cache the css files, although that threw an error when I tried it. I eventually fixed that ‘feature’ temporarily, and it’s true things did start to speed up a lot.

But at that point I pretty much gave up. Life’s too short. The option to point all urls at the currently live designs was just too alluring. Anyway it was all a useful experience, if only to tell me that getting a design to work properly and load quickly in MySource Matrix isn’t a quick or simple procedure.