Creating a widget
To generate a widget, you can use the Rails generator that Chameleon provides:
rails g chameleon:widget NAME TYPE
to generate a widget within "app/widgets". For example, if you want to generate a widget that exposes the amount of users you have in your app currently:
rails g chameleon:widget users number_and_secondary
This will generate something similar to the following in "app/widgets/users_widget.rb":
widget :users do
key "3638c90ec12d5a59061ad7b78afcbd050e50b621"
type "number_and_secondary"
data do
end
end
To implement your widget, you simply need to alter it to return the required data - for a "number_and_secondary" type of widget, it requires a hash containing a :value, and optionally, a :previous value to compare it to (such as user count as of yesterday, for example):
widget :users do
key "3618c90ec02d5a57061ad7b78afcbb050e50b608"
type "number_and_secondary"
data do
{
:value => User.count,
:previous => User.count(:conditions => "created_at < '#{1.day.ago.to_s(:db)}'")
}
end
end
You can then point Geckoboard at your widget, http://myapp/widgets/users?key=3618c90ec02d5a57061ad7b78afcbb050e50b608, and Geckoboard will then show the current user count, as well as the percentage difference compared to a day ago.
To read more about configuring widgets, click here.
To read more about the different widget types, click here.