public
Description: a Ruby on Rails plugin for easier integration of the YUI library into a Ruby on Rails application. It will include helpers for generating widgets and including the YUI file dependencies.
Homepage: http://rubyforge.org/projects/yui4rails/
Clone URL: git://github.com/mghaught/yui4rails.git
yui4rails / README
100644 78 lines (39 sloc) 2.729 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
YUI 4 Rails
===========
 
YUI 4 Rails is a plugin for easier integration of YUI components/widgets into a Rails application. Initially, we will only be offering two components, datatable and charts, however more will follow. We also encourage others to help convert their favorite components for the plugin and contribute it back to the community.
 
 
Installation
===========
 
As with plugins, you can install YUI 4 Rails either from archive or subversion.
 
Via Subversion:
 
 
script/plugin install svn://rubyforge.org/var/svn/yui4rails/tags/yui4rails-0.1.1
 
Via archive:
 
Download either the tar.gz or zip file and extract it into your RAILS_APP/vendor/plugins directory.
 
For those of you wishing to be more on the cutting edge of the plugin, please use my github repo at:
 
http://github.com/mghaught/yui4rails/tree/master
 
You can install it via the git clone command (if you have Git installed):
 
git clone git://github.com/mghaught/yui4rails vendor/plugins/yui4rails
 
Or hit the download button and extract the tarball as the archive command above illustrates.
 
Next, you will want to run the rake command to install the YUI resources into your application.
 
From the plugin root, run this command:
rake yui4rails:update
 
If you're running off trunk or a version newer than 0.1.1 then you can do this instead:
 
rake yui4rails:update
 
You should then find a lot of resources copied to the <RAILS_ROOT>/public/yui directory. At this time, the plugin assumes that you are referencing the YUI resources from your server, as opposed to theirs. We will make this optional in the future.
 
At this point you can start to use the plugin in your application.
 
 
Using
===========
 
1) Including YUI resources
 
We have a convenience include helper for you to use in your templates
 
<%= yui_includes %>
 
You will want to feed this an array of component names (as symbols) such as:
 
<%= yui_includes :datatable, :charts %>
 
It will pull in the necessary javascript and stylesheet resources for those components.
 
 
For the two components, you'll first want to read up on how to use them from YUI's developer site as they're not trivial widgets. Our wrappers on these objects are as follows:
 
data_table = Yui4Rails::Widgets::DataTable.new("your_table_id", column_definitions, data_rows, footer_row = "")
 
After constructing the component, you then need to render it via the render method:
 
data_table.render
 
Charts works essentially the same way:
 
chart = Yui4Rails::Widgets::Chart.new("yui_chart_id", yui_column_definitions, yui_data_rows)
chart.render
 
 
You can usually find more tidbits on this plugin at Marty Haught's blog: http://martyhaught.com
 
Copyright (c) 2008 Marty Haught, Andy Kappen, released under the MIT license