-
Notifications
You must be signed in to change notification settings - Fork 0
Home
##Introduction
Bernard-Board is a free web based dashboard application framework written in Ruby on Rails. The goal is to create a framework that you can use to create a visual reprisentation of your data by implementing simple plugins and Bernard will take care of rendering, refreshing and saving your dashboard for future use.
Please note that Bernard is in a state of extreme infancy. He will most likely misbehave.
If you're interested in trying out Bernard best thing to do is to grab the development branch and follow these very limited installation instructions.
##Required Gems
Before you do anything, make sure you have the following Ruby Gems installed. (Note - Mysql and sqlite are both listed because I intend to split the master into a mysql and sqlite branch since the mysql gem hurts my brain. If you're trying out Bernard make sure you have the mysql gem installed.
- mysql
- sqlite (But not really!)
- nokogiri
- gcal4ruby
##Installation instructions
- Grab the source from git.
- Edit you config/database.yaml file and configure your database.
- Run
script/server
- Hit up localhost:3000/ on your browser.
##Creating a custom plugin.
Bernard-Board allows you to create custom plugins with which to create new and exciting items to stick on your board. Each plugin requires a minimum of two files.
- A form partial
- A content partial
To create a skeleton for your plugin run
script/generate board_plugin foo
This will generate the following files
- vendor/plugin/bernard_foo
- vendor/plugins/bernard_foo/init.rb
- vendor/plugins/bernard_foo/REAMDE
- vendor/plugins/bernard_foo/lib/
- vendor/plugins/bernard_foo/lib/foo.rb
- vendor/plugins/bernard_foo/lib/javascripts
- vendor/plugins/bernard_foo/lib/javascripts/foo.js
- vendor/plugins/bernard_foo/lib/stylesheets
- vendor/plugins/bernard_foo/lib/stylesheets/foo.css
- vendor/plugins/bernard_foo/lib/views
- vendor/plugins/bernard_foo/lib/views/_formfor_foo.html.erb
- vendor/plugins/bernard_foo/lib/views/_foo.html.erb
- vendor/plugins/bernard_foo/test/
- vendor/plugins/bernard_foo/test/foo_test.rb
- vendor/plugins/bernard_foo/test/test_helper.rb
- vendor/plugins/bernard_foo/tasks/
- vendor/plugins/bernard_foo/tasks/foo_tasks.rake
In this example the form partial and content partial will be generated as
- vendor/plugins/bernard_foo/lib/views/_formfor_foo.html.erb
- vendor/plugins/bernard_foo/lib/views/_foo.html.erb
##Adding meat to your plugin sausage
The generated form partial contains four default form elements that are required for your plugin behave normally.
- Title
- Width
- Height
- Refresh Rate
These define the title displayed for the item, the width of the item in the board (in pixels), the height of the item (in pixels) and the frequency at which the item is refeshed(in seconds) respectively. From here on we can add whatever other form elements we'll need to create a item from our plugin. In this case we're going to create an item that displays a string as content, so lets add a text field element to the form.
Height: <%= text_field_tag "height", "", :size=>4%><br>
<!-- Your form content go here -->
My String: <%= text_field_tag "my_string"%><br>
<! -- Required submit buttons -->
In the generated content partial we can now access my_string from the parameter array, @parameters. Edit the content partial to...
<div class="ui-widget">
<div class="ui-widget-header">
<%= @parameters["title"] %>
</div>
<div class="ui-widget-content">
<%= @parameters["my_text"] %>
</div>
</div>
And that's it. You've created a plugin for your board. All that is left is to run a quick
rake foo:sync
If you edit vendor/plugin/bernard_foo/lib/foo.rb, remember to restart your server.
And you're good to go. Restart your server and go to edit mode. When you add a new item you will see that foo is listed with the other plugins, ready to be used.
###Deleting a plugin###
To get rid of a plugin, run
rake foo:remove
The plugin's source can still be found in vendor/plugins, just in case you change your mind, but if you're 100% sure you're done with it feel free to nuke with prejudice.
###Form partial validation When creating a new plugin, Bernard will validate the four required form fields. It is up to you to do the rest. Client side validation can be done in vendor/plugin/foo/lib/javascripts/foo.js in the validateFoo() method.
###Refreshing your plugin Typically Bernard will refresh your plugin by refreshing its contents every x seconds based on the value of refresh rate. This isn't always going to be the optimal case, especially if your plugin requires input from say an Ajax call. You can change Bernard's default behavior by changing the default field "Refresh rate" to a hidden field (or use some similar method to get that 0 to the controller) and set its value to 0. Refreshing can then be done via an Ajax call to a plugin controller or any other method that floats your boat.
###Side note on plugins
Passively displaying text or other information is not very useful in a dashboard system, and its not what Bernard-Board is about. We would ideally like to be able to throw in some crazy javascript, make the items look sexy and actually write some useful code to do things that we don't have to stick into our partials. If you take a look at the other files generated in vendor/plugins/foo/lib you will se a javascripts and stylesheets directory. The two files in these directories, foo.css and foo.js, are included when your board starts up and allows you to do all your fancy javascript and css specific to the plugin. Mixins and helpers and all that amazing Rails jazz can be done in foo.rb, which is located in the plugin's lib root.
##Screencasts
Creating custom plugins with Bernard Board - http://www.youtube.com/watch?v=1CTMYjmwfHY