To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / vendor / plugins / engines / lib / engines / assets.rb @ 442:753f1380d6bc
History | View | Annotate | Download (1.61 KB)
| 1 |
module Engines |
|---|---|
| 2 |
module Assets |
| 3 |
class << self |
| 4 |
@@readme = %{Files in this directory are automatically generated from your plugins. |
| 5 |
They are copied from the 'assets' directories of each plugin into this directory
|
| 6 |
each time Rails starts (script/server, script/console... and so on).
|
| 7 |
Any edits you make will NOT persist across the next server restart; instead you
|
| 8 |
should edit the files within the <plugin_name>/assets/ directory itself.}
|
| 9 |
|
| 10 |
# Ensure that the plugin asset subdirectory of RAILS_ROOT/public exists, and
|
| 11 |
# that we've added a little warning message to instruct developers not to mess with
|
| 12 |
# the files inside, since they're automatically generated.
|
| 13 |
def initialize_base_public_directory |
| 14 |
dir = Engines.public_directory
|
| 15 |
unless File.exist?(dir) |
| 16 |
FileUtils.mkdir_p(dir)
|
| 17 |
end
|
| 18 |
readme = File.join(dir, "README") |
| 19 |
File.open(readme, 'w') { |f| f.puts @@readme } unless File.exist?(readme) |
| 20 |
end
|
| 21 |
|
| 22 |
# Replicates the subdirectories under the plugins's +assets+ (or +public+)
|
| 23 |
# directory into the corresponding public directory. See also
|
| 24 |
# Plugin#public_directory for more.
|
| 25 |
def mirror_files_for(plugin) |
| 26 |
return if plugin.public_directory.nil? |
| 27 |
begin
|
| 28 |
Engines.mirror_files_from(plugin.public_directory, File.join(Engines.public_directory, plugin.name)) |
| 29 |
rescue Exception => e |
| 30 |
Engines.logger.warn "WARNING: Couldn't create the public file structure for plugin '#{plugin.name}'; Error follows:" |
| 31 |
Engines.logger.warn e
|
| 32 |
end
|
| 33 |
end
|
| 34 |
end
|
| 35 |
end
|
| 36 |
end
|