NZETC: Trackbacks now added

October 17, 2007

Just been adding Haloscan trackbacks to the NZETC blog.

So, as a test, I think I’ll link to the post about using iPod Touch devices to view eBooks.

Which reminds me, that I need to add a post to the NZETC blog about FreeBase (great technology, bad name). I must say, it feels a little funny to be creating circular blog references.

wxJavascript: a great find

October 5, 2007

I’ve just been installing and trying out wxJavascript, which is a very useful server-side javascript library that, for me, seems to solve the problem of running javascript server-side for the online word processor project (current code-name: “Remote Writer”).

Amongst other things, it has an Apache module (mod_wxjs)and support for sqlite, both quite important for this project.

The configuration wasn’t too bad, and consisted of following the quick start instructions on the website, as well as:

  1.  Experiencing a problem with adding the wxWidget modules in the Apache httpd.conf file, so what I ended up with was:
    # mod_wxjs server-side javascript stuff (see:
    LoadFile d:/wxjs/bin/libapreq2.dll
    LoadModule apreq_module "d:/wxjs/bin/"
    #LoadFile "d:/wxjs/bin/wxmsw28ud_core_vc_custom.dll"
    #LoadFile "d:/wxjs/bin/wxbase28ud_net_vc_custom.dll"
    #LoadFile "d:/wxjs/bin/wxmsw28ud_adv_vc_custom.dll"
    LoadModule wxjs_module "d:/wxjs/bin/mod_wxjs.dll"
    AddHandler wxjs .wxjs
    wxJS_Modules "d:/wxjs/bin/modules.xml"
    wxJS_RtSize 1M
    wxJS_CtxSize 8K

    Which is not too bad I think, as for the work I want to do, hopefully I won’t need the wxWidgets.

  2.  I had to play around with the modules.xml file, reordering the entry for wxJS_gui.dll to the bottom of the list, as otherwise, when Apache tried to load these modules, it produced an error message
    Error: Failed to load shared library 'd:\\wxjs\\modules\\wxJS_gui.dll'
    (error 126: the specified module could not be found.)
    Error: wxJS: Module gui(d:\\wxjs\\modules\\wxJS_gui.dll )not loaded

    It then apparently refused to load the following modules, which I would detect in the log after trying to run a script using the sqlite module:

    Error: wxJS: D:\\Program Files\\...\\maori-bibliography\\dbtest.wxjs(3) :
    ReferenceError: sqlite is not defined

I then wanted to run the following test script to check the Sqlite connection:

var exists = false;
var created = false;
var handle = new sqlite.Database("htdocs\\gears\\editor\\tinymce\\maori-bibliography\\store.db");
if ( handle.opened )
    var pragmaStmt = handle.prepare("PRAGMA user_version");
    var pragma = pragmaStmt.fetchArray();
    if ( pragma[0] == 0 )
        // Create the tables and insert some example data
        handle.exec("CREATE TABLE authors(id INTEGER PRIMARY KEY, firstname TEXT, lastname INTEGER)");
        handle.exec("CREATE TABLE books(id INTEGER PRIMARY KEY, title TEXT, fk_author_id INTEGER)");
        handle.exec("PRAGMA user_version = 1");
        handle.exec("INSERT INTO authors(id, firstname, lastname) VALUES(1, 'JRR', 'Tolkien')");
        handle.exec("INSERT INTO authors(id, firstname, lastname) VALUES(2, 'John', 'Grisham')");
        handle.exec("INSERT INTO books(id, title, author) VALUES(1, 'Lords of the ring', 1)");
        handle.exec("INSERT INTO books(id, title, author) VALUES(2, 'The firm', 2)");
        created = true;
    } else {
        exists = true;
        handle = null;
response.print("<html><head><title>wxJS database test program</title></head><body>");
response.print("<b>Was the database already present?:" + exists + "</b><br/>");
response.print("<b>Were the tables created?:" + created + "</b><br/>");

However, running this test script wasn’t without some apparent wrinkles:

  1. Once I got this one worked out, I ran the script to create a database, which seemed to work fine, but the created Sqlite database didn’t appear in the home directory of the script, where I would have thought it would appear.
    It turns out that mod_wxjs seems to default to creating Sqlite databases in the Apache2.2 directory.
    So, in my script I had to specify the subpath to the location where I wanted the database created.

    var handle = new sqlite.Database("htdocs\\gears\\editor\\tinymce\\maori-bibliography\\store.db");
  2. The created database was not accessible via the command-line Sqlite3.exe tool, at least not until I’d shut down Apache (fair enough I suppose, as it created journalled entries in an associated file which were not applied until Apache shutdown).
  3. It seemed to ignore the Pragma identifying whether the database had been created, being quite happy to recreate the database. This errant behaviour stopped after I restarted Apache (i.e. after it had written out the journalled entries)

However, to date it seems to be usabl, and a great solution at that!

I’ve been working away at the online word processor that I’m developing, based on TinyMCE, and struck the problem that, by default, TINYMCE cleans up the HTML code of the entered content.

In my case this is a problem, as I’m trying to make use of standard HTML attributes in order to persist information, and still let the user easily edit that information. For example, I want them to be able to style certain text as being a name of some sort: personal, geographic, organisation, title etc. I then want to be able to key that name with an authorative identifier, but let them continue to work on the content.

For example, I want text to be displayed to the user something like this:
Screenshot of formatted text

But I want the HTML code for this to appear something like this:

<span class="nameWork" title="name-010203">
	Reflections of a Black Woman in a White Man's World

After a bit of hunting around, I found the answer, which is to use the option to specify extended valid elements when initialising the instance of the editor:

extended_valid_elements : "span[class|title]",