From: George Moschovitis Date: 2005-07-25T16:16:03+09:00 Subject: [ANN] Nitro + Og 0.21.0 Compiler, Og custom joins, Og dynamic injection, new builder 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 Nitro goes from strength to strength as the community gets bigger. Great new features were introduced and a lot of effort was spend on cleaning up Nitro's implementation and polishing 'little things'. Many patches were contributed by the community to make this is a release you will love! Some notable changes: * New compiler pipeline replaces the obscure shader mechanism. A compiler object is responsible for transforming a controller action and or the associated xhtml templates to a special ruby method that will respond to given urls with the action output. Using the aspect oriented features of Nitro or the specialized pipeline setup method a developer can easily customize the compilation stage to meet his needs. Here are some examples: Compiler.setup_template_transformation do |template| template = Elements.transform(template) template = Localization.transform(template) template = Markup.transform(template) template = Template.transform(template) end or Compiler.before "puts 'Compiling'", :on => :compile Compiler.after "puts 'Template processed'", :on => :transform_template Compiler.wrap Benchmark, :on => compile Compiler.before :my_method, :on => compile Special rendering effects where never easier. If you need run time effects, just intercept the Render object. * Integrated the new configuration system that was previewed in the last release. All the configuration settings are now accessible either through the owner class or from the global Configuration variable using Ruby's metaprogramming features. Moreover, Nitro now dynamically decides the configuration mode (debug, stage, live/production) from environment variables or command line arguments so depolying your application is easier than ever: just run svn update on the live server, the application will grab the correct configuration parameters automatically. Of course you can use svn's advanced features to rollback to earlier versions if you experience problems. The mode specific configuration settings are defined either on ruby files or yaml files or both. Point your browser to http:://my.app.com/settings to browse the settings for your application. * Og dynamic queries. You can inject caclulated or join attributes to your objects. Here is an example: class Item property :quantity, Fixnum property :unit_price, Float def initialize(quantity, unit_price) @quantity = quantity @unit_price = unit_price end end Item.create 2, 3.0 item = Item.find_one :select => 'quantity*unit_price as total_price' item.total_price # => 6.0 Please note that total_price is a dynamically injected attribute. Now you can combine SQL's powerful query features with the simplicity and elegance of Og. * Og customized join tables allows you to use any Ruby object as the join relation between other objects. Here comes an example: class Category property :title, String end class Article property :title, String end class ArticleToCategory property :rate, Float has_one Article has_one Category end c1 = Category.create c2 = Category.create a = Article.create a.categories.add(c1, :rate => 2.3) a.categories.add(c2, :rate => 1.2) for c in a.categories p a.category_join_data(c).rate end * Og collections size() is now optimized. * Og join code support refactoring. The new code is easier to read, more customizable and generates more efficient code by default. * Nitro automatically assings reasonable template_roots on Controllers based on mount points. Moreover, the template_root overloading feature was improved. If you cant to reuse an existing controller but customize the view rendering by using different templates for some actions, just assign a different template root for this controller, and put the custom templates inside that dir. The custom templates 'override' the templates of the parent controller (templates for non customized actions come from the parent's controller template_root). Creating a library of reusable controllers (parts) was never easier. * Major cleanup of the nitro source code, removed many files. * Greatly improved Wee integration makes Nitro the premium container for Wee components. Have a look at the updated wee example. * Improved builder mechanism for programmatic rendering. The new builder resuses the controller helper mixins thanks to extensive refactoring of the implementation. Here is an example: class MyController def index build do labels = ['George', 'Stella', 'Renos'] html { head { title 'A simple test' } body { 10.times { strong 'Hello World' i 'Hello World222' } select(:id => 'names') { options :labels => labels, :selected => 1 } } } end end * Improved helper integration. Helpers are now accessed either as mixins or through the builder mechanism. #{form entity} #{options :labels => [..], :values => [..], :selected => 1} or #{emit :form entity} #{emit :options :labels => [..] ...} * Reimplemented the markup mixin to make this more flexible. You can easily customize the markup logic that is applied by the markup macros. * Updated the documentation. * Fixed all reported or discovered bugs, many smaller improvements. Nitro provides everything you need to develop professional Web applications using Ruby and Javascript. Nitro redefines Rapid Application Development by providing a clean, yet efficient API, a layer of domain specific languages implemented on top of Ruby and the most powerful and elegant object relational mapping solution available everywhere. Nitro is Web 2.0 ready, featuring excellent support for AJAX, XML, Syndication and Email interraction while staying standards compliant. Nitro gives choice to the developer: Multiple paradigms are implemented, incorporating ideas from Rails, CherryPy, Catalyst, Wee, PHP, JSP and Microsoft.NET and more. The developer is free to choose the pattern that better fits his application. This kind of freedom makes Nitro applicable to a wide range of applications, spanning from big, scalable web sites with thousands of concurrent users to simple solutions for deployment on intranet desktops. Enjoy this release! George Moschovitis -- http://www.nitrohq.com