G
George Moschovitis
Hello everyone,
new versions of Nitro and Og were just released:
Homepage + Downloads: http://www.nitrohq.com
Mailing List: http://rubyforge.org/mailman/listinfo/nitro-general
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
automatically 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 the 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:
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, er_page => 5, rder => '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, 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.
I hope this software will be useful to you, and I would love to
receive your suggestions, ideas and bug reports.
have fun,
George Moschovitis
new versions of Nitro and Og were just released:
Homepage + Downloads: http://www.nitrohq.com
Mailing List: http://rubyforge.org/mailman/listinfo/nitro-general
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
automatically 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 the 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:
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, er_page => 5, rder => '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, 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.
I hope this software will be useful to you, and I would love to
receive your suggestions, ideas and bug reports.
have fun,
George Moschovitis