README.mdown in netzke-basepack-0.1.4.1 vs README.mdown in netzke-basepack-0.2.0

- old
+ new

@@ -1,52 +1,52 @@ # netzke-basepack -A pack of basic Rails/ExtJS widgets, as a part of Netzke framework. +A pack of basic Rails/Ext JS widgets, as a part of Netzke framework. # Prerequisites 1. Rails >= 2.2 -2. ExtJS >= 2.0: its root *must* be accessible as RAILS_ROOT/public/extjs. You may symlink your ExtJS library to here, like this (from your app folder): `cd public && ln -s ~/Developer/extjs/ext-2.2 extjs` +2. Ext JS >= 2.0: its root *must* be accessible as `RAILS_ROOT/public/extjs`. You may symlink your Ext JS library here like this (from your app folder): `cd public && ln -s ~/Developer/extjs/ext-2.2 extjs` 3. `acts_as_list` plugin must be installed: `./script/plugin install git://github.com/rails/acts_as_list.git` # Installation Install the gem: `gem install netzke-basepack` Include it into environment.rb: `config.gem "netzke-basepack"` # Usage -First, run the generators to have the necessary migrations (if not done so already): +First, run the generators to have the necessary migrations: `./script/generate netzke_core` `./script/generate netzke_grid` Do the migrations: `rake db:migrate` -This example will provide you with a grid-based scaffold for ActiveRecord-model called `Book`. If you don't have it already, you may generate it like this: +The following example will provide you with a grid-based scaffold for ActiveRecord-model called `Book`. You may generate it like this: `./script/generate model Book title:string amount:integer` -(don't forget to do the migrations after this) +(don't forget to run the migrations after it) In the controller declare the widget: `class WelcomeController < ApplicationController - netzke_widget :books, :widget_class_name => 'Grid', :data_class_name => 'Book' + netzke :books, :widget_class_name => 'GridPanel', :data_class_name => 'Book' end` After a widget is declared in the controller, it can be accessed in 3 different ways: 1) loaded by means of an automatically created controller action which will produce a basic HTML-page with the widget (handy for testing), 2) embedded directly into a view (by means of helpers), 3) dynamically loaded by other widgets (usually by the widget of class 'Application', if you want a desktop-like, AJAX-driven web-app). ## Using automatically created controller action -Without writing any more code, you can access the widget by `http://yourhost/welcome/books_test`. That is to say, you simply append `_test` to your widget's name (as declared in the controller) and use it as the action of the controller. +Without writing any more code, you can access the widget by `http://yourhost/welcome/books_test`. That is to say, you simply append `_test` to your widget's name (as declared in the controller) to get the action name. ## Embedding a widget into a view -netzke-core plugin provides the following 2 helpers to put inside your head-tag (use it in your layout) +netzke-core plugin provides the following 2 helpers to put inside your head-tag (use it in your layout): 1. `netzke_js_include` - to include extjs and netzke javascript files -2. `netzke_css_include` - to include the css. This one can take a parameter to specify a color schema you wish for ExtJS, e.g.: `netzke_css_include(:gray)` +2. `netzke_css_include` - to include the css. This one can take a parameter to specify a color schema you wish for Ext JS, e.g.: `netzke_css_include(:gray)` Declaring a widget in the controller provides you with a couple of helpers that can be used in the view: 1. `books_class_definition` will contain the javascript code defining the code for the JS class. 2. `books_widget_instance` will declare a local javascript variable called `book`. @@ -69,10 +69,10 @@ Ext.onReady(function(){ <%= books_widget_instance %> books.render("books"); }) <% end %> -<!-- some HTML... --> +<p>... your page content here ...</p> <div id="books">the widget will be rendered in this div</div>` ## Dynamic loading of widgets TODO: this part will be covered later