1 Using configuration
Ubiquo::Config offers a place where store configuration variables
A value can have 2 states, added as default value and added as normal value. If both setted, normal value is used.
It allow to store values in contexts using context method.
It’s not recommended to change the value of the configuration during the life of the application, only in the setup
1.1 Getting a value
To get a stored value of the configuration.
value = Ubiquo::Config.get(:key)
contexted_value = Ubiquo::Config.context(:context).get(:key)
1.2 Creating a new value
You can create new values for the configuration.
Ubiquo::Config.add(:key, 'default_value')
Ubiquo::Config.context(:context).add(:key, default_value)
1.3 Setting a normal value
when a key is added you can override their default value with set method:
Ubiquo::Config.set(:key, 'normal_value')
Ubiquo::Config.context(:context).set(:key, normal_value)
1.4 Inherited values
It is usefull for adding keys that their value is the same of another key until it’s not setted manually.
Currently is used to the plugins lists max row number, default to 10 but can be re-setted for a single list.
Ubiquo::Config.add_inheritance(:key, :existent_key)
Ubiquo::Config.context(:context).add_inheritance(:key, :existent_key)
1.5 Use of config caller
Config caller let you to define keys with a lambda as value and evaluate it in any context.
It’s very powerfull to add hooks in the application.
Currently is used to all access_control calls of the plugins, letting you to change it in your application without changing plugin code.
ubiquo_config_call(:key)
ubiquo_config_call(:key, {:context => :context})
2 Core helpers
Ubiquo provides a series of helpers that can be useful in most ubiquo projects. On the rdoc you will find an exhaustive list, and here examples for some of the most usual plugins will be shown.
2.1 Show helpers
The helpers in this group will assist you when creating ‘show’ pages in Ubiquo.
2.1.1 Lists
ubiquo_show_list('Title', ['array', 'of', 'elements'])
This will create a normal, styled ul list.
2.1.2 media_attachment helpers
Visit the ubiquo_media guide if you are interested in helpers to easily print lists of images or documents
2.1.3 HTML text
Just add the class ‘text’ to the dd tag and you are ready
3 Navigation
3.1 Tabs navigations
All ubiquo applications have two tab navitations, one for normal mode and one for superadmin mode. This tab navigator is what is showed under the ubiquo header.
3.1.1 Create new tab to the normal mode
Open RAILS_ROOT/app/views/navigators/_main_navtabs.html.erb.
Here you can edit navigator_left or navigator_right. Inside the ‘create_tab_navigator’ method block you can add new tabs with a piece of code like that:
navigator.add_tab do |tab|
tab.text = 'Your tab text'
tab.title = 'Go to ...'
tab.link = ubiquo_your_controllers_path
tab.highlights_on({:controller => "ubiquo/your_controller"})
tab.highlighted_class = "active"
end
3.2 Link navigations
Link navigations work like tab navigations but showing links instead tabs.
Currently there are only one default link navigation, but scaffold generates one for the new controller.
The default navigation is showed on top of the Ubiquo, where is showed user name, logout link, etc.
To add a link to any link navigation just add this code to the ‘create_link_navigation’ method block:
navigator.add_link do |link|
link.text = 'Your link text'
link.url = ubiquo_your_controllers_path
link.highlights_on({:controller => "ubiquo/your_controller"})
end