Posted By: George Moschovitis
Date: 2005-07-16 04:41
Summary: Nitro + Og 0.20.0
Project: Nitro

Another superb release! State of the art AJAX/Javascript support, Wee components / programmatic renderer integration, a beginners
tutorial, self documenting configuration and many important bug fixes. Don't forget to check out our new community site at http://www.nitrohq.com

Some notable changes:

* Ajax is THE buzzword at the moment, and Nitro provides the best support you can find. Nitro fully separates the behaviour from the template using the behaviour.js library and allowing for dynamic injection of ajax functionality. The generated code contains clean html and all the javascript organized in a single <script> block. Here is an example:

in the Controller:

def index
# Inject functionality to the DOM elements of the template.

behaviour '#alert', %{
el.onclick = function() {
alert('Hello world');
}
}
auto_complete :country # convert to autocomplete field
live :live # convert to async link!
draggable :dragger, :revert => false
end

def a_simple_action
puts 'LIVE!'
end

def country_auto_complete # data for auto complete.
%{
<ul>
<li>Greece</li>
<li>England</li>
...
</ul>
}
end

in the Template:

<label>Enter a country:</label>
<input type="text" id="country" />
<div id="country_auto_complete" class="auto_complete"> </div>

Behaviour example:<br />
<button id="alert">Click to alert</button>

Drag and Drop example:<br />
<div id="dragger">DRAG ME</div>

Live/Asynchonous request (AJAX) example:<br />
Here comes a <a id="live" href="a_simple_action">live link</a>.<br />
(Check out the log to see the action called in the background!)

All you have to do is define id's for your DOM elements. Here
comes the generated code:

<label>Enter a country:</label>
...
(Check out the log to see the action called in the background!)

<script type="text/javascript">
var _behaviours = {
'#alert': function(el) {
el.onclick = function() {
alert('Hello world');
}
},'#country': function(el) {
el.autocomplete = 'off';

},'#live': function(el) {
el.onclick = function() {
new Ajax.Request(el.href, {});
return false;
}
}
}
Behaviour.register(_behaviours);

new Ajax.Autocompleter('country', 'country_auto_complete', 'country_auto_complete');
new Draggable('dragger', {revert:false});
</script>

See how a normal <a> tag is converted transparently to an Ajax request. The prototype, scriptacoulous and behaviour js libraries are used.

The ajax support in this release is a PREVIEW. Stay tuned for major improvements (and some surprises) in the next version.

* Wee Components integration. Nitro now transparently integrates Wee components. This is truly a win-win situation. Wee applications can use Nitro's infrastructure. Nitro applications can use extremely reusable, stateful Components. For a demonstration check out the new Wee example in the examples distribution! Wee 0.9.0 is needed!

Even better interoperability with Wee is coming soon. Nitro plays well with others, and always provides more options.

* Mixins are modules of functionality that can be mixed into Controllers. The developer can explicitly include Mixins or use Nitro conventions to have helper Mixins automatically included:

class MyController
..
end

module MyControlllerMixin
# gets automatically mixed in
end

This works just like Og Mixins.

* Brand new, self-documenting configuration system. There is a new keyword for defining configuration settings:

Here is an example:

class Render
setting :template_extension, :default => 'xhtml', :doc => 'The default template extension'
end

class Session
setting :store, :default => 'memory', :doc => 'The session store'
end

You can configure the Application using ruby code or yaml files:

Render.template_extension = 'xhtml'
Session.store = 'drb'

or

Render:
template_extension: xhtml
Session:
store: drb

You can access all defined settings:

Configuration.settings.each { |s| ... }

You can view the settings of the application along with documentation on the following url:

http://www.myapp.com/settings

This feature is also a PREVIEW. Will be used a lot more in the next release.

* CherryPy style published objects. Nitro allows you to publish any Ruby object. Here is the new hello world example:

class HelloWorld
def index
print 'Hello World'
end

def add(val)
print "added: #{val + 2}"
end
end

App.start(HelloWorld)

Now, point your browser to localhost:/ or localhost/add?val=2

If you need the advanced controller functionality just extend your published object from the Controller base class. The normal heuristics to decide which method is safe to publish are aplied.

* CherryPy-style dispatcher configuration, provides another way to define mounting points for Controllers and published objects. Here is an example:

server = Server.new
server.root = MainController # /
server.root.fora = ForaController # /fora
server.root.wiki = WikiController # /wiki
server.root.really.deep = DeepController # /really/deap

* Improved pager interface. Thanks to the new PagerMixin, presenting paged lists is easier (and as efficient) than ever:

items, pager = paginate(Article, :per_page => 5, :order => 'date DESC')

* Added better sql injection protection in Og sql stores.

* Fixed Mysql store reconnect bug.

* Og falls back to pure ruby adapters for Mysql and Postgres, to make it easier to run out of the box. Please, don't forget to switch to the natively compiled adapters for production sites.

* This is surely the most request feature: Nitro Step by Step by James Britt, a beginers guide to Nitro. Available in the brand-new, Nitro-powered, http://www.nitrohq.com Community wiki.

* New examples: The totaly recoded and ultra cool ajax example, a Wee/Nitro example and the new Hello world example.

* Cleaned up a lot of source files.

* Many, many, many bug fixes and small improvements. This release fixes all reported bugs in the spirit of out zero-bug tolerance philosophy.

Latest News
BinData 1.5.0 - source moved to github
    Dion Mendel - 2013-05-21 11:10
v13.5.0 Released !!
    id 774 - 2013-05-18 12:28
Runt v0.9.0 Released
    Matthew Lipper - 2013-05-17 00:11
kramdown 1.0.2 released
    Thomas Leitner - 2013-05-09 06:58
mime-types 1.23 Released
    Austin Ziegler - 2013-04-21 01:41

 

Forums | Admin

Discussion Forums: nitro---og-0.20.0

Start New Thread Start New Thread

 

Topic Topic Starter Replies Last Post