[Nitro] Scaffolding / Admin

zimba-tm zimba.tm at gmail.com
Thu Dec 1 13:44:14 EST 2005


Hi George,

I effectively have some observations about the datatype conversions.

Actually, if I understand well, a datatype is described by the
ClassName passed in the property method.

For example,

class Item
  property :name, String
  property :price, Float
  property :data, File
end

There is one part in Og to map Ruby <-> SQL types. There are generic
transformers in sql.rb for date, integer, etc... Then, those
transformers can be overridden for the specific storages (sqlite,
mysql, ...)

On the other hand, the form helper will do the Ruby <-> Html
conversion. I haven't looked into this really yet so I don't know how
it works exactly.

Finally, scaffolding makes use of the FormHelper in combination to the
Og Entity you want to scaffold (with some magic inside). It take the
files in public/scaffolding for the external design.

This is what I understood by looking a little bit in the code.

I did this, because I wanted to add new data types like File and URI.

What i would like, is to be able to define a new class and it's
different transformers easily.

I'm also currently developping a javascript library that could take
advantage of input's class names to automatically bind validation
methods on client-side.

Example html :

<form>
  <input type="text" name="email" class="email" />
  <input type="submit" />
</form>

Example javascript :

Element.add({
  'FORM' => Library.Form.Validating,
  'FORM .email' => Library.Form.Email
})


My Element library does a kind of mixin with an object and an
html-node. It uses css-like queries to determine what node should be
mixed with what. For example, 'FORM .email' looks for every element in
that page with the class 'email' and which has a parentNode's type
FORM. Defining an element's behavior is a simple as

Library.Form.Validating = function() {}
Library.Form.Validating.prototype = {
  onsubmit: function() {
    var elements = this.find('INPUT')

    var message = ''
    for(element is elements) {
      if (!element.is_valid()) {
        message += element.name + " is not valid \n"
      }
    }
    if (message.length > 0) {
      alert(message)
      return false
    }
  }
}

The javascript part is more or less working already. It's much lighter
than the "prototype" js-lib. I already have dragging elements and
various fancy stuff. I'm actually working on the "Ajax" part. It would
be great if Nitro could take advantage of that library by mapping Ruby
<-> Javascript data types in scaffolding.

Finally, I wonder if we could also map Ruby <-> Request parameters.

On 01/12/05, George Moschovitis <george.moschovitis at gmail.com> wrote:
> If anyone has any nice suggestions about scaffolding and the admin part,
> now is the time to let me know ;-) I am redesigning both to make them
> more useful
> for my company's projects but a lot of people will like the new code too :)
>
> -g.
>
>
> --
> http://www.gmosx.com
> http://www.navel.gr
> http://www.nitrohq.com
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>


--
Cheers,
  zimba

http://zimba.oree.ch




More information about the Nitro-general mailing list