Plugins - Restful Citations
Add to favoritesEngine, which adds citations mechanism to your Rails application. Citations may be edited using Ajax-based citations editor. Transparently integrates with Restful Comments plugin.
Features
- Simple citation mechanism
Requirements
This plugin requires followng plugins installed:
- Engines (http://agilewebdevelopment.com/plugins/engines)
- Globalite (http://agilewebdevelopment.com/plugins/globalite)
If your Rails version prior to 1.2:
- Restful Rails (http://agilewebdevelopment.com/plugins/restful_rails)
Installation
- script/install svn://rubyforge.org/var/svn/rf-comments/trunk/restful_citations
- script/generate plugin_migration
Using
Common configuring:
- Add map.from_plugin :restful_citations to your routes.rb
- Copy localization files from {RAILS_ROOT}/vendor/plugins/restful_citations/lang/ui directory to your {RAILS_ROOT}/lang/ui directory, or add their content to your existing localization files
- In environment.rb set your localization language (for example, Globalite.language = :en)
- If you want to specify per-user access rules and your helpers haven’t method current_user, implement this method in ApplicationHelper.
For citable:
- Add acts_as_restful_citable into your model class to declare it as citable
- Add <%=restful_citations_include%> into your erb template to include styles and javascripts
- Don’t forget to add <%= javascript_include_tag :defaults %> to your layout
- Add <%= restful_citations_for {model_instance} %> into view to render citation editor for {model_instance}
- Add <%= restful_citations_toggle_link {text}, {model_instance} %> to create link to toggle citation editor.
Configuring access
You can specify access rules for different citable models. To do it, you need to specify block in acts_as_restful_citable call.
This block can contain some of methods:
def can_view?( citable, citation, user )
def can_add?( citable, citation, user )
def can_remove?( citable, citation, user )
Each method returns if user can make coresponding action on citation.
If you want to specify user-dependent access, when user must be accessible through current_user method in helper
Configuring styles
To configure display of editor you may pass hash of options to restful_citations_include. Available options:
- :style - name of built-in style. Available value: ‘gray’, ‘lj’
- :stylesheet - name of application stylesheet to use
http://rubyforge.org/projects/rf-comments/
http://rf-comments.rubyforge.org/svn/trunk/restful_citations/
Rails' (MIT)
Rails Engines
