Is attempt to automate many task and practices in building RIA using Dojo and Rails.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PROJECT IS GONA BE ACTIVELY DEVELOPED IF U HAVE SAME IDEAS LETS JOIN US
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
script/plugin git://github.com/niquola/dojo_on_rails.git #or better go to plugins dir and git clone git://github.com/niquola/dojo_on_rails.git
-
rake dojo:install:config #dojo.yml to RAILS_ROOT/config
-
#Here you can customize in dojo.yml from where to take dojo modules #checkout - is shell command to load sources u can substitute it with ln -s surse target for example #svn and git must be installed
Here is example of configuration
modules: dojo: checkout: svn checkout http://svn.dojotoolkit.org/src/branches/1.3/dojo dijit: checkout: svn checkout http://svn.dojotoolkit.org/src/branches/1.3/dijit dojox: checkout: svn checkout http://svn.dojotoolkit.org/src/branches/1.3/dojox kley: checkout: git clone git@github.com:niquola/kley.git util: checkout: svn checkout http://svn.dojotoolkit.org/src/branches/1.3/util
-
rake dojo:install:modules #this checkout dojo source code
-
then you configure application settings
From dojo.yml:
#name of dojo module, where your OnePageApplications will live application_module: app #controller file name, which actions mapped to one page applications controller: <your-controller>
-
script/generate controller <your-controller> #Generate controller for OnePageApplications
-
script/generate dpage OnePageApplicationName1 OnePageApplicationName2 #generate OnePageApplications skeletons
-
#run this controller
-
Some conventions and practices about Dojo-Rails project structure and management
-
Automate dojo installation and update from svn to project
-
Automate builds
-
Generators for custom widgets (DijitGenerator) and one page applications (KleyGenerator - not yet implemented)
-
configured through dojo.yml
-
-
Lightweight mvc framework KleyMvc (in develoupment)
-
Smart DojoHelper
-
configured through dojo.yml
-
use builds or sources
-
Autorequire option automatically dojo.require(WidgetsOnYourPage)
-
Here the directory structure:
RAILS_ROOT |-app | |-controllers | |-models | |-helpers | \-views |-config | \-dojo.yml <------------------- all configurations centralized \-public \-client_root <------------configured in dojo.yml, by default ria |-profiles | \-profile.js <-- Profile to build project / TODO: will be automatically updated by generators | |-src <--------------------- The sources. Modules checkouted as described in dojo.yaml | |-app | |-kley <----------------- Lightweight mvc framework | |-dojo | |-dijit | |-dojox | \-util | \-builds <--------------Builds folder, the place where dojo:build rake put builds |-build_2009_01_02_12_33 <--- Concrete build, to which u can switch application by dojo.yml config or directly in dojo helper | |-app | |-kley | |-dojo | |-dijit | |-dojox | \-util | |-build_2009_01_02_12_43 \-build_2009_01_03_12_33
Here our vision of custom application package
app |-views <-------- Here u or dijit generator put your custom widgets | |-SomeWidget | \-layout | \-ApplicationContainer |-models <---- Here some stores/models |-themes | |-nihilo | \-tundra | |-AppLayoutApplicationContainer.css <--- custom widgets css | |-override_theme.css <--- place to put css overriding theme | |-reset.css | |-custom.css <--------- common.css imported by all pageX.css by default | |-widgets-all.css <--- Import all stylesheets for custom Widgets | |-page1.css <---- entry point to your stylesheets dependencies for this OnePageApplication | | @import all required stylesheets | | example: @import url(../../../dojox/grid/tundraGrid.css) | \-page2.css <---- Another one |-tests | \-AppLayoutViewsContainer.html <--- test generated by DijitGenerator or manually created | \-pages |-page1.js <--- entry point script to your simple OnePageApplication |-page2.js <--- entry point script to your another OnePageApplication featured with KleyMvc \-page2 <--- parts of page2 module |-controllers.js |-mediators.js |-autorequire.js <---- this file require Widgets from autorequire | we need it to resolve all dependencies when run dojo:building | now your need manually copy autorequirs from your page | TODO: will be updated by dojo:build rake soon \-models.js
run dojo:build first time it will create client_root/profiles/profile.js edit profile (read more on dojo help)
-
For example if we gonna build OnePageApplication to one file we need open this application in browser and copy autorequired dojo.require to:
client_root
| app \-pages |-OnePageApplicationName1.js \-OnePageApplicationName1 <--- parts of page2 module | |-autorequire.js <---- HERE ...
-
then edit profile.js and add to layers array
{ name: "../app/pages/OnePageApplicationName1.js", dependencies: ["app.pages.OnePageApplicationName1"] }
-
app/pages/OnePageApplicationName1.js now require all graph of Classes
-
rake dojo:build
-
change in dojo.yml version of js to use build path
development: <<: *defaults #configure helper dojo: version: builds/buildXXXX-XX-XX <--------- your build djConfig: parseOnLoad: true isDebug: true autorequire: false <------------ turn off autorequire theme: tundra
-
restart server
Do many things:
* read dojo.yml config * generate <script src="...dojo.js" djConfig="..."> * turn on AutoRequire * generate <script> dojo.require(OnePageApplication)</script> * generate <style> @import required css with theme support
DojoHelper accept hash of options, which overrides options in dojo.yml:
:app - the name of OnePageApplication file :root (:src, :last_build or build_2009_12_02) set dojo root to src or last or concrete build :autorequire - if true search page for dojoType and generate dojo.require for them' :theme - theme name for this page, generate css imports
Example: {{{
!!! XML !!! Strict %html %head %title DOJO on RAILS =dojo :app=>'welcome' %body{:class=>theme} #mainContainer{ :dojoType => "dijit.layout.BorderContainer", :design => "screenDesign"} #topContainer{ :region => "top", :dojoType => "dijit.layout.ContentPane"} %h1#logo Dojo On Rails #leftContainer{ :region => "left", :dojoType => "dijit.layout.ContentPane", :jsId=>'views.navigation'} %ul %li{:content=>'dojo_installation'} Easy dojo installation to rails project. Many documented conventions - so u don't need to invent them. %li{:content=>'dojo_builds'} Automated and configurable dojo builds for your application %li{:content=>'dojo_helper'} Smart dojo helper will done all work for you #centerContainer{ :region => "center", :dojoType => "dijit.layout.ContentPane", :jsId=>'views.contentViewer'} #rightContainer{ :region => "right", :dojoType => "app.views.AdwertView"}
}}}
Usage: script/generate dijit CLASSNAME [OPTS] [BASENAME] [MIXIN1,MIXIN2…]
generate custom dijit widget
Options:
CLASSNAME - name of dijit. There are could be diferent types of package name resolution: * just name (MyWidget) - the package will be taken from dojo.yml config (default_package) * dot started name (.subModule.MyWidget) - default package will be added to begining * full name (some.new.module.MyWidget) - declared package will be used OPTS - is abbriviation string example - tBM downcase means turn on flag, upper - off x - just placeholder do not change defaults t/T - generate template w/W - widgets in template b/B - append base class m/M - append mixins p/P - do generate test page c/C - do generate css for widget f/F - open in firefox defaults can be changed in dojo.yml BASENAME and MIXINs - names of base class and mixins (the same package resolution used as with CLASSNAME)
Example: script/generate dijit .layout.AppContainer MP dijit.layout._ContainerWidget .layout._ContainerMixin kley.mvc.MediatorMixin
Lightweight publish/subscribe/mvc framework (on top of dojo) inspired by pureMVC - git://github.com/niquola/kley.git
Copyright © 2009 [niquola], released under the MIT license