- Blog -

(A cheesy homepage for Justin Collins)
Sqwee and Unicode

As someone quite correctly pointed out, Sqwee wasn’t supporting Unicode very well. In fact, not really at all. You could put it in, but then things got weird. You might not think this would affect me much (I am generally a pretty ASCII kind of guy), but what happens when I want to do a little mathematical notation? Perhaps I need to write down {x, y} ∪ {z, y} for some reason. That would make Sqwee mildly blow up.

So I tentatively started poking into the Unicode world, expecting at any moment to have a dragon fry me to a crisp or to fall into some large crevasse. Interestingly, neither happened, but it was a little bit of a journey.

First, I found out all I needed to do was add a nice little meta-tag:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >

Simple enough, right? I tried it. Didn’t help a bit. Manually switching the encoding (in Firefox) did work, though. After examining the headers using Live Headers, it was clear the content type was still being sent as iso-8895-1.

I figured this was due to the Lighttpd webserver not setting the content type correctly, so I went about trying to change that. I thought it would be possible to change it in the mimetypes:

mimetype.assign             = (
  ".html" => "text/html; content-type: utf-8" 
)

I saw this suggested somewhere, but it didn’t help.

Then I read that in Prototype Unicode doesn’t work with “get” and only with “post”, so I tried that:

 new Ajax.Updater("main", "index.rhtml", {
           method: "post",
           //...
        });

But it didn’t help either!

At this point I was getting somewhat frustrated, but then I remembered that eruby generates its own headers. Perhaps that was the problem?

Indeed it was! Fortunately, it is possible to set the content type via a commandline switch:
usage: ./eruby [switches] [inputfile]

  -d, --debug           set debugging flags (set $DEBUG to true)
  -K[kcode]             specifies KANJI (Japanese) code-set
  -M[mode]              specifies runtime mode
                          f: filter mode
                          c: CGI mode
                          n: NPH-CGI mode
  -C [charset]          specifies charset parameter for Content-Type
  -n, --noheader        disables CGI header output
  -v, --verbose         enables verbose mode
  --version             print version information and exit
Now I was in business! I went ahead and changed the Lighttpd config file to add in the appropriate switches:

cgi.assign = (".rhtml" => "/home/justin/sqwee/bin/eruby -Ku -C utf-8")
Unfortunately, this doesn’t work at all, because Lighttpd uses stat to check if the specified program exists and the options mess it up. To work around this, I needed to create a little script to launch eruby with the appropriate options:

#!/bin/env ruby
require 'pathname'
exec("#{Pathname.new(__FILE__).dirname}/eruby -KU -C utf-8 #{ARGV.join(' ')}")

That worked perfectly, and suddenly Sqwee had Unicode! That means time for a new release.


More Sqwee

Yes, I’m going talk more about Sqwee. I think it’s mostly because I’m excited about writing software with real version numbers… just kidding.

I’m still working on a good description of it. It’s incredibly simple stuff, but kind of hard to explain. It’s like a wiki, without lots of revisions and multiple users. So it’s like a personal wiki. But it is oriented towards being quick to install and quick to use, while retaining the flexibility for people to use it as they like. That’s why I sort of have the ‘prepackaged’ and ‘no frills’ versions, for running on a desktop and a shared server, respectively.

Anyways, enough blabbing about that stuff. I have been using Sqwee to take notes for a couple weeks now, and it actually works pretty well. But I noticed a couple of things that bugged me quite a bit:

First, if you are editing a page (taking notes) and you want to save it, but keep editing, you have to click ‘save’ and then ‘edit’ again. So I added the ‘quick save’ feature which will save the page but keep you in editing mode.

But then…how do you know it has really saved it and there wasn’t some problem? Or maybe it takes a long time to save or load a page…it would be nice to know when that kind of thing is “working on it” and when it has failed. So what I do now is have the button you press “gray out” while it is work in, then come back when it is complete. It works well when things are slow, but isn’t annoying when they are fast.

Anyhow, the point is that version 0.2.1 is out and I’m excited about the changes. Which, I forgot to mention, include the ability to search.


My first official software release – Sqwee

Yes, so. That project I previously called “MyWiki” has been rebranded as Sqwee – Simple Quick Web Editing Engine. Which is silly, but I like the acronym.

This project came about because I was using Pimki for keeping track of various thoughts and things, but accessing my home server remotely started to become a pain (stupid ISP, I imagine). It became such a pain that I got a real hosting plan with Site5 (link over there somewhere) and this nifty domain name.

But! I didn’t think Site5 would appreciate me running Pimki because it is tied up with WEBrick and therefore had to be running as a background thing and use a non-standard port. I looked around for something Ruby-based (like Pimki) but easy to set up on a shared host.

Sadly, I didn’t find anything that I liked. So, as these stories usually go, I made my own. I had some specific goals in mind:

  • Easy to install
  • Fast
  • Simple design
  • Quick creation and editing of pages

Out of that came the very minimalist Sqwee. It’s like a wiki, but only in that you can dynamically create and edit (and delete) pages. There are no accounts, revision tracking, or other bells and whistles (on account of wanting to keep it fast). It doesn’t even have password protection built in…but that’s because it would be a pain and any web server will have that already.

There are some planned features, but the idea is to not let anything slow down page rendering or creation. In fact, pages are basically stored as static HTML. The only “rendering” is putting the header, navigation section, and the content together, like many websites do.

This was my first time doing AJAX stuff, so I went ahead and used the Prototype library to get going. It’s pretty nice. So that means nice, quick creation and editing of pages. I like it.

Well, that’s probably enough rambling about Sqwee. If you are curious, see the website or check out the demo.