Ben Godfrey

Archive for May, 2002

Window size arses

Browsers insist on rendering content at different sizes, popup windows are either inadequate or too large. The simple answer is to make window.open wrapper functions that adjust window sizes based on browser detection. They only need a few pixels:

function nicewindow(url, x, y) {
    var scroll = "auto";
    var n = navigator.appName.toLowerCase();
    if (n.indexOf("internet explorer") != -1 || n.indexOf("msie") != -1) scroll = "yes";
    if (document.layers) { x += 161; }
    else if (n.indexOf("netscape") != -1 && parseInt(navigator.appVersion) > 4)
        { x -= 100; y -= 70; }
    else if (n.indexOf("mac") != -1) { x -= 100; y -= 40; }
    return window.open(url, "sometitle",
        "width="+x+",height="+y+",scrollbars="+scroll+",menubar=no,toolbar=no");
}

Werk at lurst

Finally got some actual work done as a contractor! Apart from a near-constant stream of changes to Certa I haven’t actually done anything for a while. However, last week I got my first job as a usability consultant.

Basically I evaluated (clicked-on) a web site and wrote down how I felt (angry, less angry, exstatic). At the end I wrote a report. The report was quite interesting. I separated it into problems and suggested solutions so hopefully it was quite useful from an implementation point of view. I like being a consultant, but report writing is a brain-taxing thing to do.

Now today I’m depressed

  • It’s grey and shit. The weather is extremely nasty.
  • Nobody is talking to me about work. Several people have rung me saying that they want me to do work but nobody can be fucked to ring and say yes, we want you to get paid for working for us. It’s been three months since I’ve done any work and I’m getting very poor now. I’m not going to be able to go to Russia unless I do lots of work between now and then, so I haven’t turned anything down. I was supposed to start work on one job this week and they haven’t even decided if they want it done or not.
  • The people I live with are useless. Those who said they would come out to Royksopp tonight aren’t. I’m going on my own now. It won’t be too bad as Louise is working there, but still. Also Louise and I spend at least £30 a week on food and there is still never anything to fucking eat.
  • Thom’s attitude is annoying me. He doesn’t have any money and can’t pay his bills. When I ask him for the money he owes me he says he needs to get more shifts at work. Today he blew work off because he wanted to go to the pub. Grrr. In addition, Thom is not the only one pulling this tactic. Everybody owes money, few people are actually working to pay their debts. I’m not working either, but I pay my debts (and everybody else’s it seems). I don’t know if I’m alone in feeling this, but borrowing money from your friends and then not paying it back is just shit.

So yeah, bunch of shit really.

Smart moves

Got a bit further with Smarty. I now have an excellently tangled web of templates creating a themeable page. One goal that’s on my mind is template juggling of arrays. For example, I pass in an array describing the left hand portlet block of Hype (login, threads, etc). What if my template author wants to drop one of the portlets, include another or otherwise change the array? Smarty doesn’t seem to cover these problems.

However, as with everything Smarty doesn’t do, it should be possible to add support throught plug-ins. I could build plug-ins that manipulate the assigned variables in the style of PHP’s own array functions, push, pop, sort etc. A wide library would be useful.

More on download times

One saving grace about download times is that a lot of images can be shared between pages. If the home page HTML is 2k, then it and 32k of graphics can be download in under ten seconds, subsequent pages can then be up to 34k if they only use the same graphics as the home page. This is an ass as the most important page, the home page, is the one burdened with the job of bringing in the heavy graphics. Also, if the user enters the site via another page, and does not have the images cached, it will take 20 seconds to download. So, not that great an idea really.

Browser recognition etc

Nielsen advocates the use of different layouts and configurations for different devices and users, so does Tullis! The guest user can be bounced between several versions of the default theme for different hardware configs, i.e. WebTV, PDA, even WML can be thought of as an especially cut down version of the default theme. Then, when the user is logged in, certain themes can be recommended for certain browsers and a simple sanity check can be performed before sending the page. I.e. if they default to a basic HTML page they would still get a WML page if they used a phone. Setting the decision barriers will be tricky.

Need to test the PHP browscap.ini functions, if they can be used they’d be great. Browser detection and what to do when we’ve identified the capabilities is a grey area that is going to need testing to get the best results.

Additionally, I think people should probably be logged in for longer. Maybe a few days or something. Perhaps a tick box in the config: “When I log in, I wanna stay logged in, god damn it.”

Jakob says…

In order to be a good website, you need:

High-quality content.
Often updated
Minimal download time
Ease of use

And, to be superb:

Relevant to users’ needs
Unique to the online medium
Net-centric corporate culture

Also, a user gets bored of waiting in ten seconds. For a page to download in this time it must weight less that 34kb (150-200kb for DSL). In order for a user to completely feel in charge the page needs to download in less than a second (!). For a modem that means 2k, 8k for ADSL/ISDN or 100k for T1. I guess that for an ethernet intranet that means a page can be about a meg before it takes longer than a second to get moved across the network. However, on the intranet it is the response time of the server that makes the critical difference. Fortyfive (our PPro 180 server) is never going to acheive this with dynamic content, but for HTML is no problem.

Testing 1 2 3

Having spent a week on the Smarty mailing list I’ve learnt quite a lot about and and thought about how to use it. I knocked up a demo that uses a bunch of templates to build a Hype 0.2 style page. Nicely it takes about 30 lines of code (and a splash of HTML, obviously). It uses a frame template and a portal template as 0.2 does, they’re are pretty simple but they could be slightly cleaner. The left and right blocks of portlets are arrays so the theme designer has to know how to use a Smarty foreach.

I also wrote a lot of Perl. I wrote a one liner that converts text files to uber-simple, a one-liner that does sentence capitalisation and a many-liner that deduces the average hits to each page from a set of Apache logfiles. This showed me that Hype gets about 6,100 hits a month, which makes me happy.

Also for new-hype, I’ve been thinking about threads more. It occured to me that a public thread with only one author is a weblog, so I might integrate this with Hype, we’ll see. Also I like the aggregating up to the front page bit. I originally built Hype’s stupid thread support like it is because I thought that proper forum style threads would stop users posting to the front page and just reduce the amount of content. However, Hype’s post counts have stabilised, so I’m wondering if the opposite may be true: that other threads would just increase the amount of posting and the number of people doing it. A more general message server, rather than the flow-of-existence style of the front page.

Clearly threads are going to have to more central to a new version of the code, so I think I will tackle that task next, given that themes is more than 50% done (i.e. design and initial implementation).

Paging

Got the 1, 2, 3 style paging sorted out which is very nice and certainly simple to implement. However, it would be much more logical to allow access to posts by data ranges, months etc. The posts don’t really fit into neat “Messages 20-25” categories.

Stencil Graffiti

Did my first bit of stencil graffiti today:

Worked OK. The stencil was a bit small, and I sprayed too close so it ended up dripping. However, next time I won’t make that mistake. Bigger bit of card, with lots of space for holding. Then spray from a distance of at least six inches with a sweeping motion. You have to get good coverage without getting too much paint in one place.

There you go, I’m a fucking expert right now.

Another web site finished!

I just finished my first site of my second bout of freelancism. Certa Solutions went live about half an hour ago. I didn’t do the design, BTW, just the build.

Building the site I fell into the same patterns that I often do when building straight HTML. The effort of maintaining consistency between 40+ pages outweighs everything else. To this end I’ve thought about converting all the content to XML and then building a set of XSL transformations to generate the site. Then the computer can do the repetive bit! Ha! The trick would then be to balance the content out between nodes — much easier than distributing it around one document.

I may try to rebuild Certa using this technique, but more likely I think I’ll leave it until next time I have to do something similar. Hypothetical is a priority, and Fog needs a page which means rebuilding this site.

Also today I joined the Smarty mailing list and found out that my problems with it are not due to it, but my PHP build. Installing it on a more predictable BSD machine (this one) worked fine. Smarty is a template engine, the PHP teams measures to seperate logic from design. It’s pretty fast, although I don’t have the numbers for other systems like Zope or JSP. I’m going to use it to provide theme support for Hype2.

PEAR r0x0rz

Having just mentioned PEAR, I decided to use their DB_Pager class to split this weblog up into chunks and make the page a bit more useable. It’s really sweet. It means using the DB abstraction class as well, but that’s no problem. I get to use cool DSN URLs like mysql://monkey@hype/etc. All of the navigation at the bottom of the page (and more, which I tried but didn’t keep) is provided by DB_Pager. The whole thing was fantastically easy. So easy in fact that I could be bothered to wade through some of the hellish tables I’ve used here. Why the hell didn’t I write it with CSS?

Anyway, it’s all going to change soon, I need an URL to give to potential clients and that URL needs to be slightly more than a dodgy weblog.

Today Hypothetical was one year old

My baby! My baby! I’m kind of proud that Hypothetical is still going after a year. I will have been going out with Louise for a year in a couple of days as well, so that’s acheivements all round for me. But realistically, the fact that it’s been going for a year just serves to highlight how badly it needs rewriting! I’m exploring using PEAR classes to do as much work as possible. I think I will use Smarty to code templates for themes. I recently had good experience writing fog in Perl and using the Template Toolkit module. There are many wheels on the internet, too many to permit reinvention.