About a mont ago at one of my contract jobs we had a discussion about the Prototype design pattern and mixins. The discussion took place around javascript, which is by language construct a prototyped language. For those who don't know about the Prototype design pattern let me quote from the Gang-of-Four, "Specify the kinds of objects to create using a prototypical instance, and create new objects by coping this prototype." Or, Wikipedia, "Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse (known as inheritance in class-based languages) is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as class-less, prototype-oriented or instance-based programming."
What's been happening?
March 22nd, 2008
Posted at 2:24pm
Those who know me by the work I did on sanctus.org are probably wondering where the progress on the re-write I mentioned back in February. Well, today I committed a little more source code for the project and updated my own projects page to include a link to the Google Code project page. This is where I am keeping the source code for the library I have been developing. Currently, the base loader and a set of calculators are there, the calculators determine how a particular lectionary behaves, ie. Historic, Michelmas, Three Year, etc. These calculators are supposed to determine the current Sunday of the Church year based upon a PHP DateTime object.
The library is far from complete, the calculators return a number correlating to the Sunday of the year - but right now you have no way of knowing what that Sunday of the year is. My next step is to develop a Sunday object with mapping, and setup a way so that the particular Sunday object in use can be changed and thus alternative mappings become available for different calculators.
As for sanctus.org, it's revival is based upon this library's completion. So, this is progress. It's taking me so long because, as I've said before, I'm no longer a full-time student with lots of free time, and between my commitments to work and my family I have very little spare time these days. It really stinks to grow up! If you're really anxious to get sanctus.org back up you either need to be patient, or you can always consider a PayPal donation - which does help development.
Stay tuned...
March 22nd, 2008
Posted at 12:03am
I just setup jQuery Templates and jGrowl in the jQuery plugin repository, and then I added them on my own projects page. I'll try and keep the plugin page's release piece up to date as I make modifications, and I also promise to do my best in following up on any bugs reported.
March 21st, 2008
Posted at 10:59pm
I just uploaded a new copy of jQuery templates with a fix for $.fn.text() and $.fn.html(), I was not passing the options object in correctly (silly mistake) and thanks to Chris Jaure, if you were using either of these methods to simply return a value they now work correctly as well.
jQuery Templates available at: http://stanlemon.net/files/jquery.template.js
March 20th, 2008
Posted at 11:36pm
Back in November I wanted a mechanism to communicate messages after an ajax request to my PageSite users. I experimented with a number of things and initially had a terribly ugly manipulation of the green and red message boxes you'll see on this type from time to time. There were a couple of big problems though, first the code was originally written for Prototype so it sucked, and second it was not very portable. Ultimately I wanted something that looked good, was well written and could be reused in a number of different ways.
When PageSite was converted to using jQuery for all of its javascript I rehashed a lot of stuff. There was some old javascript code that had been floating around since 2004 when I first prototyped out PageSite 4.0's admin panel. To cut to the chase... I stumbled across Humanized Messages, which was close to what I wanted to do, but not yet there. This plugin got me to thinking, though, what I'd really like is something that looked like Growl. For those not on OS X, take a look at the website and you'll see that Growl is a system-wide notification system.
As a result, while Erich was out here visiting I fleshed out an initial concept. I called it jGrowl, spinning off of the OS X solution. It's pretty simple to use out of the box:
// Normal notification $.jGrowl("Here is my message!"); // Sticky notification $.jGrowl("This message is stuck!", { sticky: true });
Today I sat down and cleaned up some of the plugin, namely I removed a dependency on the metadata plugin in favor of $.fn.data() and I also namespaced all of the events, which should allow you to attach other events to the jGrowl nodes and deal with them without jGrowl unbinding them on you.
The plugin still needs some work, I'm not sure how much I like styling it with javascript - at the same rate, I like the idea of styling different notifications differently as well. I'd also like to see some callback options, the animations customizable and I'd like to potentially add some internal sorting using the "header" option. These things, though, will come in time - for now I just want to get the plugin out so I can get some feedback.
Update 8/21/08: You can download jGrowl from it's jQuery plugin page at: http://plugins.jquery.com/project/jgrowl
March 20th, 2008
Posted at 12:27pm
As I continue to get feedback on the jQuery Templates plugin I've ported from Ext I'm trying to implement the suggestions I've received. Subsequently, I've uploaded another round (or two) of changes. The changes I've made are:
- Moved the $template object to $.template.instance, so that the object can be access from the jQuery object and extended easily - what was I thinking before??
- Renamed the "re" property to "regx", and this is now an object containing several different regular expression options (jsp, jtemplates and ext for starters).
- You can now change the standard regular expression by setting $.template.regx.standard = $.template.regx.myregexp;
- Templates can utilize custom regular expressions on a per-template basis, ie. var t = $.template("<div>...</div>", { regx: 'ext' });
- In addition to the methods that use domManip() I've updated html() and text() to handle receiving jQuery Templates as well.
I hope to add some kind of callback to the plugin as well, so that you can specify a method to be called after a template has been created or applied. I'm still thinking this through and will post more once I implement it.
March 18th, 2008
Posted at 8:01pm
Finally, Safari 3.1! For a long time now I've been using a variety of hacks on my install of Safari to make it more usable. Most notably, plugins like Twicetab which offered the ability to double click in the tab bar and open a new tab, or Safari Stand which opened up a series of debug menu options. The new release of Safari now makes all those things unnecessary. Double clicking the tab bar works - just like you would expect it to, and a "Develop" menu bar is revealed by a simple checkbox in the Safari Preferences. This menu bar reveals access to the Web Inspector, Console and best of all new "Disable Caches" option - something every web develop has been patiently waiting (and hoping) for!
I believe all these cool new perks, plus an amazing score of 75 on the Acid3 tests are available for Windows users. Safari has definitely out-done Firefox, it pains me to say that, but it's true. It's fast, usable and now developer-friendly. I remember when Safari 2 came out and it was rumored to be a "legitimate" browser and I just laughed. I used Camino for 95% of my browsing experience in those days, and defaulted to Firefox 1.5 for the rest of it. Firefox 2 was a little faster on the Mac, but not enough to replace my default of Camino. When the Safari 3 betas came out things were promising and I comfortably converted. I've used nightly webkits for development purpose routinely, but I never quite felt comfortable using it as my main browser since I'm really bad about downloading new nightlies. The advent of Firefox 3 pre5 had me reconsidering, since it was finally truly macified, and was fast enough for general usage. Safari 3.1 has made all that bunk now, and I'm happy to say I've even uninstalled most of my hacks.
If you haven't downloaded it yet, run over to http://www.apple.com/safari/ and get it right away.
March 12th, 2008
Posted at 11:43pm
I've done some more work on my jQuery Templates proposal. First, by request from some on the jQuery lists I've removed the usage of the $.ui namespace, although it really functioned completely independent of jQuery.UI. Second, I've added a modification to override the jQuery domManip() method, which is a method called by other methods like insertBefore() and append() and handle DOM manipulation within the jQuery core. Now, you can pass any of the manipulation methods your jQuery Template object and as a second parameter the object of properties for replacement. This changes the syntax to:
var t = $.template('Hello ${name}, how are you ${question}? I am ${me:substr(0,10)}');
$(selector).append( t , {
name: 'Stan',
question: 'feeling',
me: 'doing quite well myself, thank you very much!'
});
I'm going to resubmit my proposal to jquery-en and jquery-ui for consideration and review. If you're interested in looking at the code, it's available at:
http://stanlemon.net/files/jquery.template.js
February 22nd, 2008
Posted at 10:48am
Some conversation at work arose about templating in jQuery. The honest answer to anyone inquiring about this is that jQuery lacks any real good solution for simple macro-based templating. I was directed to Ext, which has a Template library in it that does exactly this. Subsequently, I've proposed to the UI folk a port of Ext.Template. For the most part the port is direct, the apply() and compile() methods are virtually identical to Ext.Template, though they use some jQuery functions instead of Ext.Core functions. The constructor is very different, and the designation of compiling is via a jQuery-style options object passed to the template constructor. I've tried to follow the jQuery.UI API as best as I know. I've changed the formatter usage in Ext.Template, as it depends on Ext.util.Format which isn't available in jQuery. All in all, this functionality does not seem like it's necessary so I changed it to use what I'm calling "helpers". These helpers provide the variable:method() syntax like in Ext.Template but allows the designer to customize what functions are available in a jQuery-style way.
Updated 03/12/2008: Anyhow, the code for my port and proposal is available here:
http://stanlemon.net/files/jquery.template.js
February 16th, 2008
Posted at 12:32pm
I love AOL Radio on Mac OS X, even more than iTunes radio. Since AOL Radio partnered up with XM there are more stations and more variety and less commercials. You can literally find anything regardless of your taste. The down side to this wonderful music selection is an ugly side panel that jets out from the side of the application. If it wasn't for this side panel, I think I would be content to use AOL Radio. However, like a good mac user, everything has to be aesthetically pleasing and the side panel just isn't. To say nothing of the fact that most of the time the adds are less then stellar themselves.