You are here: Browse Railsplugins Plugin Assets
= plugin_assets
plugin_assets adds the ability to automate the copying of plugin assets into your application’s public/ folder, in addition to providing tasks for semi-automatically performing updates.
ResourcesWiki
Announcement
Source
Development
Many plugins, especially those targeted for ActionPack, come bundled with additional assets that are either required or could be used by the main application. For example, a plugin that adds a helper for a js calendar could come with the required js files. These files would then be stored in your plugin_xyz/assets/javascripts/ folder.
This idea of this plugin is to provide a little more automation for copying assets from plugins to your application’s public/ folder. See the Usage below for how automation works.
Assets can be copied either automatically or semi-automatically.
Automated asset copying
Automated asset copying occurs when your Rails application starts up. Immediately after initialization, all assets from your plugins are copied to your application. You can control whether this is enabled with:
PluginAWeek::PluginAssets.mirror_on_initialization = true
The above will enable automated mirroring of plugin assets. By default, it is disabled. You can control which plugins are mirrored and whether files are always overwritten with the following options:
PluginAWeek::PluginAssets.plugins_to_mirror << 'plugin_xyz'
If you do not specify any values in plugins_to_mirror, then all plugins will be mirrored.
PluginAWeek::PluginAssets.write_once_plugins << 'plugin_xyz'
Write-once plugins specify which plugins should only write once to your application’s directory and never overwrite. By default, assets will always be overwritten.
Semi-automated asset copyingSemi-automated asset copying refers to the use of the rake tasks that come bundled with this plugin. The tasks assist in copying, updating, or listing all of the assets currently in the plugins that are being loaded. The examples in the following descriptions assuming a directory structure like the following:
public/
vendor/
vendor/plugins/
vendor/plugins/calendar_helper/
vendor/plugins/calendar_helper/asssets/
vendor/plugins/calendar_helper/assets/javascripts
vendor/plugins/calendar_helper/assets/javascripts/calendar.js
= assets:copy
This task will mirror assets from your plugins, overwriting any and all existing files. For example,
rake assets:copy
Mirroring assets for calendar_helper:
create C:/Projects/workspace/sandbox/config/../public/javascripts/calendar.js ...done
If the calendar.js already existed, the file would be overwritten:
rake assets:copy
Mirroring assets for calendar_helper:
update C:/Projects/workspace/sandbox/config/../public/javascripts/calendar.js ...done
= assets:update
This task will mirror assets from your plugins, skipping any files that already exist, regardless of whether they are different. For example, if no files have already been copied,
rake assets:update
Mirroring assets for calendar_helper:
create C:/Projects/workspace/sandbox/config/../public/javascripts/calendar.js ...done
However, if the calendar.js already existed, the file would be skiped:
rake assets:update
Mirroring assets for calendar_helper:
No new assets found
=== assets:list
This task will list all of the available assets for your plugins. For example,
rake assets:list
calendar_helper:
vendor/plugins/calendar_helper/assets/javascripts
vendor/plugins/calendar_helper/assets/javascripts/calendar.js
=== Additional information
For all tasks, you can specify which plugins to update by using the PLUGIN option, e.g.
rake assets:copy PLUGIN=calendar_helper
rake assets:update PLUGIN=calendar_helper,xyz_helper
rake assets:list PLUGIN=calendar_helper,xyz_helper
Dependencies
This plugin depends on the presence of the following plugins:
Thanks to James Adam and his Engines plugin for providing an implementation upon which this plugin is based (http://www.rails-engines.org/).
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly