lib/tasks/zena.rake in zena-1.2.7 vs lib/tasks/zena.rake in zena-1.2.8
- old
+ new
@@ -40,15 +40,19 @@
FileUtils.symlink_or_copy("#{from}/public/#{dir}", "#{to}/public/#{dir}")
end
end
end
-def copy_assets(from, to)
+def copy_assets(from, to, copy_all = false)
from = File.expand_path(from)
to = File.expand_path(to)
return if from == to
- ['config/mongrel_upload_progress.conf', 'lib/upload_progress_server.rb', 'config/deploy.rb', 'config/bricks.yml', 'public/**/*'].each do |base_path|
+ folders = ['public/**/*']
+ if copy_all
+ folders += ['config/mongrel_upload_progress.conf', 'lib/upload_progress_server.rb', 'config/deploy.rb', 'config/bricks.yml']
+ end
+ folders.each do |base_path|
if base_path =~ /\*/
Dir["#{from}/#{base_path}"].each do |path|
path = path[(from.length + 1)..-1]
next if File.directory?(path)
copy_files("#{from}/#{path}", "#{to}/#{path}")
@@ -101,10 +105,19 @@
FileUtils.cp(from, base)
end
end
namespace :zena do
+ desc "Copy all assets including gem and deploy config from zena gem to application."
+ task :all_assets => :zena_config do
+ if Zena::ROOT == RAILS_ROOT
+ puts "Copy all assets should only be used when zena is loaded externally (via gem for example)."
+ else
+ copy_assets(Zena::ROOT, RAILS_ROOT, true)
+ end
+ end
+
desc "Copy latest assets from zena gem to application (images, stylesheets, javascripts)."
task :assets => :zena_config do
if Zena::ROOT == RAILS_ROOT
puts "Copy assets should only be used when zena is loaded externally (via gem for example)."
else
@@ -233,32 +246,20 @@
task :zena_config do
require File.join(File.dirname(__FILE__),'..','..','lib','zena')
end
desc "Remove all zafu compiled templates"
- task :clear_zafu => :zena_config do
- if File.exist?(SITES_ROOT)
- Dir.foreach(SITES_ROOT) do |site|
- next if site =~ /^\./
- FileUtils.rmtree(File.join(SITES_ROOT, site, 'zafu'))
- end
+ task :clear_zafu => :environment do
+ Site.all.each do |site|
+ site.clear_zafu
end
end
desc "Remove all cached data" # FIXME: cachedPages db should be cleared to
task :clear_cache => :environment do
- if File.exist?(SITES_ROOT)
- Dir.foreach(SITES_ROOT) do |site|
- next if site =~ /^\./ || !File.exist?(File.join(SITES_ROOT,site,'public'))
- Dir.foreach(File.join(SITES_ROOT,site,'public')) do |elem|
- next unless elem =~ /^(\w\w\.html|\w\w)$/
- FileUtils.rmtree(File.join(SITES_ROOT, site, 'public', elem))
- end
- end
- ['caches', 'cached_pages', 'cached_pages_nodes'].each do |tbl|
- Site.connection.execute "DELETE FROM #{tbl}"
- end
+ Site.all.each do |site|
+ site.clear_cache
end
end
desc "Create a backup of all data for a site"
task :backup_site do
@@ -276,11 +277,11 @@
end
end
end
task :full_backup => :environment do
- data_folders = Site.find(:all).map { |s| File.join(SITES_ROOT, s.data_path) }.reject { |p| !File.exist?(p) }
+ data_folders = Site.all.map { |s| File.join(SITES_ROOT, s.data_path) }.reject { |p| !File.exist?(p) }
cmd = "tar czf #{RAILS_ROOT}/sites_data.tgz #{data_folders.join(' ')}"
puts cmd
puts `#{cmd}`
end
@@ -374,11 +375,11 @@
else
Zena::FoxyParser.new(table).run
end
end
- %w{db:fixtures:load zena:rebuild_index}.each do |task|
+ %w{db:fixtures:load fs_skin:index zena:rebuild_index}.each do |task|
puts "******************************* #{task}"
Rake::Task[task].invoke
end
index_tables = Node.connection.tables.select {|t| t =~ /^idx_/ }
@@ -423,11 +424,13 @@
sites = [Site.find_by_host(ENV['HOST'])]
else
sites = Site.master_sites
end
sites.each do |site|
+ puts "************** Rebuild paths for '#{site.host}' *************"
# Does not use SiteWorker.
- site.rebuild_fullpath
+ setup_visitor(site.any_admin, site)
+ site.rebuild_fullpath(nil, 1)
end
end
desc 'Rebuild vhash for all sites or site defined by HOST param.'
task :rebuild_vhash => :environment do