Archive for December, 2005

Arrows in HTML

I hadn’t realised that there were so many HTML character codes. Very useful, as I was looking for some arrows… ↑ ↓ ⇑ ⇓

Headlines in any font…

Do with without CSS for those headlines with funny fonts - use sIFR to replace your text with a Flash image of the text. Neat, although you’d need to be a bit of a typography nerd to panic over it that much…

Impressed with Rails - again

So, I had need of a little ‘Ajax’. I wanted to provide a brief preview of some content, but without all the nastiness of page refreshes - an ideal candidate for XMLHTTPRequest. So I wrote my own. That was a mistake.

I’m comfortable with Javascript - I think I’m fairly accomplished with it - so I got it done, and it worked. It was only then that I thought ‘I think Rails does Ajax too’. Does it ever! Ten minutes, and I had a Rails Ajax version working (a lot less than my own time, even with my boiler-plate code) and, and this is the best bit, much more readable code! That’s what I call a win. link_to_remote was the useful function in question, and my call is:
link_to_remote( "Show",
:url => { :action => "show_small", :id => game.id },
:update => "js_board",
:before => "document.getElementById('js_board').style.left = get_x(this);
document.getElementById('js_board').style.top = get_y(this)",
:complete => "document.getElementById('js_board').style.visibility = 'visible'" )

Progress on Chinese Chess

Progress - I can make moves. Okay, so the timebank isn’t working correctly, my board seems to have some problem that means when black moves it creates errors on the WebBrick server, and you can’t take a piece that is causing check, for some reason, but I can sort that. It’s good progress though!

Progess on Ruby Chinese Chess site

So, I’ve been a bit busy with things, so I don’t have any of my usual interesting links to post. I’ve been getting stuff done with the Rails Xiangqi site that I’m building (Chinese chess to the rest of us). Nothing radical, just plugging away.

My biggest complaint with Rails so far is a lack of books and documentation. I mean, the API docs are pretty good, but I’d like to see more example, more tutorials, and a structured thing like a book would be wonderful.

So, what have I learnt? Well, I’ve used routes.rb to set up the default page for the site. You can also ditch that index.html file from public in your application too. I think I’ve figured out how change passwords in the security thing, which is a bit involved, so sometime I’ll post the code.

Partials - annoyingly - don’t have a ‘general’ folder. You can create one, but you have to specify it each time you call a partial. That sucks a bit.

I built a lot of the user admin stuff - login, signup, etc.. It was made very easy by the Login Generator. Updating users and stuff - well, that was only a slight change to the normal scaffold. The big change was updating the password - but even that wasn’t too bad.

All in all, still impressed by how much you can get done in a short time with Rails.

One thing I’d like to figure out is how to do a persistent Login cookie for Rails. I don’t mind having my session deleted, but having authenticated that user, I’d like to not have to do it again the next time they visit the site.