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