2008/1/30

網站遷居啟事

我們的新網站上線了,部落格也一起搬家囉。這裡以後將不再更新。

新版網址是 http://handlino.com/

2007/11/15

jquery-form

This is our first jquery plugin, and we're very thrilled to release it. jquery-form provides on-the-fly form generation with:

  1. declarative syntax
  2. good default semantic
It's very questionable about why people even need to generate a whole form all in javascript, and my saying is that this is one kind of future. It looks like this when you use it:
$("#form1").form({
    legend: "Quiz #4",
    params: {
        "Title": "What's the answer ?",
        "your_answer": {
            label: "Your Answer",
            value: "42"
        }
    }
})
.find(":submit").val("Save").end()
.submit(function() {
    $("#message").html("You just submit that form");

    setTimeout(function() { $("#message").empty(); }, 5000);

    return false;
});
At this moment you can only see text fields generated, and it's not very customizable yet. More and more type of traditional fields, or smart fields, are being integrated into this branch. So stay tuned. Please visit it's official page for more details: http://code.handlino.com/wiki/jquery-form

2007/11/5

self.pm

OO Perl programmers often find them self typing this line many times:

    my $self = shift;

Why ? Because Perl do not have a special keyword to represent current object, the first argument in the argument list are taken to be the current object. Such convention has been there for years.

As Ingy döt Net tried to use source filter to sort that out, his Spiffy module is actually one of my favorite module. But there are too many know problem with source filter, and turned out nobody really enjoy it at all.

Although I've always think, with Perl, one shouldn't be bundled with the language to limit their thought, but should just enjoy the TIMTODI style to get things done in your favorite style. That's why the re-invented wheels like Template-Declare, Object-Declare, Scalar-Defer, Web-Scraper are so elegant.

Without using source filter, one can always say $_[0] to get the current object, but that's not very readable.

So self.pm provides a slightly different self, it's not a variable, but just a bare-word. Really it's function call that gets your current $_[0], but it's pretty handy.

Turned out somebody really likes it, that's great. :)

Note: This is a cross-post from: http://blog.gugod.org/2007/11/selfpm.html

2007/7/31

新 Template Toolkit Plugin 兩則

Template::Plugin::Num2Word

在 TT2 裡面,很容易將數值轉換成「字」的 plugin。如: [% menu.size.to_word %]-items 由於,有時候 element 的 class name 需要針對其內容做一些配合,所以可能會生出 "five-items" "six-items" 這樣的 class name,如果在模版系統裡面沒有方便產生這些數字「字」的方法,那還真是傷腦筋啊。

Template::Plugin::Text::Greeking

這是讓你在 Template 裡可以產生假文的。在模版仍在設計階段時,有時候需要一些填版面的假文,是故為之。這東西其實還有另一個用處,因其可以調整要產生的長度,所以可以拿來進行視覺上的測試。看看自已所設計的版本,在裝載各種長度的內文時,都能夠保持一定的水準。

2007/7/28

massage: A SPA plugin for Rails

SPA Stands for Single Page Application, it's a concept that totally depends on AJAX. We just made an Rails controller extension that makes it so easy to do spa, it's called: massage. (We are really enjoying it when the name feels just right, aren't we.)

The massage project is now on Rubyforge. To try it, first you would need to install it as a Rails plugin like this:

script/plugin install http://massage.rubyforge.org/svn/trunk/

Then, in the controller that you want to make it work like SPA, add:

spa :only => [:index, :settings]    # or :except => [...]

This would make index and settings actions work just right for both xhr and non-xhr. Non-XHR would show the page just like it was, and it'll work if you change those calls to link_to to link_to_remote too. By default, it uses RJS to update an element with id "content" (better to be a div for best look). If you need to change it to, say, "my-spa-arena", you can say:

spa :only => [:index, :settings], :update_element => "my-spa-arena"

And of course, make sure there's is such an element inside your layout, otherwise RJS would just pop-up an error message.

massage project is still at bleeding edge, if you find it broken please contact us, you can leave comments here.