#
2009 may 4 (mon) 12:30
::
Django broken after Ubuntu 9.04 upgrade
#
2008 nov 26 (wed) 12:31
::
Good-bye Dojo, jQuery is my new Javascript framework
Here's how it happened. I wanted to add some date pickers and a tabbed-layer area to one form, and plug in Eric Florenzano's Django threadedcomments to my templates. Eflo used jQuery in his threadedcomments example, and at first I thought I'd be able to whip up a Dojo version of that. I'm sure I could given enough time, but the clock was ticking. I took another look at jQuery and Eflo's examples, and jQuery started to feel less like a black box and more like something I could work with. I switched everything over and feel like I made a good choice.
I wish there was better writing in the Javascript space about the differences between jQuery and Dojo and the other toolkits. As a Javascript outsider it was hard to figure out the strengths and weakness of the frameworks, and the differences in the problems they're trying to solve. I also realized that some programmers seem to be using several of the frameworks together, so they seem to address different levels of the application stack. I haven't found any good writing that articulates this, and I'm not quite sure I understand it well enough to do it myself.
#
2008 nov 20 (thu) 11:55
::
Getting Dojo's dijit.Editor to work in a form
The Problem:
dijit.Editor can be inserted into a <textarea> like you insert other dijit widgets, using dojoType="dijit.Editor". The editor displays fine and works perfectly, except that it doesn't actually save to your form for some reason.
The Solution:
You have to make your actual textarea a hidden field, use <div> tags for Editor instead of <textarea>, and include some code in the dojo.addOnLoad() function that copies the text of the dijit.Editor field into the hidden field when the form is submitted. There's a good writeup of this over at Dojo Campus.org.
Thoughts
This problem is not mentioned anywhere that I could find in the official Dojo docs. I can see Dojo partisans making the case that dijit.Editor is a Dijit Application rather than one of the Dijit forms widgets, and that this justifies the special handling required. However, I think replacing the plain ol` <textarea> is probably the most common use case for dijit.Editor, so there really should be better documentation of this.
This experience makes me wonder if Dojo is really the right tool for the job I'm doing. I think I might have another look at jQuery...
P.S. JavaScript: The Good Parts is another really helpful book if you're getting into the language.
#
2008 jan 8 (tue) 13:39
::
ASCII, Dammit!
One of the banes of a web programmer's existence is dealing with user input, which can come in almost any form. You have to allow for malicious hackers who try to crash your site using strangely-formatted text, sure, but you also have to allow for users who write text in Microsoft apps like Word, which can also crash your site.
Microsoft, for their own insidious reasons, uses non-standard codes to represent things like "smart quotes", short and long dashes, etc. These codes cause errors in other programs unless they are converted, so every web programmer who hasn't sold out to The Man has to scrub user input before doing anything else with it.
Bless Leonard Richardson! He wrote a little Python class that handles this chore (and perfectly captures my feelings about this whole chore) called "AsciiDammit.py". I love it! The class also has a function called htmlDammit(), that works one HTML with "smart quotes" in it. Genius!
P.S. If you're interesting in alternatives to Word, there were a couple good articles about cool alternatives the other day.
UPDATE (2008-2-6): I just figured out that the Leonard Richardson behind ASCII, Dammit! is the same Leonard Richardson who wrote RESTful Web Services and the most excellent HTML parsing lib BeautifulSoup, His site is chock full 'o interesting stuff, like a script that turns a ReST-formatted text into presentation slides. I wanna be like Leonard when I grow up. :)







