Skip to content

Commit

Permalink
Added static:index rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Jul 16, 2012
1 parent 82b4526 commit e8ae4b1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bricks/static/zena/tasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

namespace :static do
desc 'rebuild static index'
task :index => :environment do
# Make sure all bricks are loaded before executing the index rebuild
Zena::Use.upgrade_class('Site')

include Zena::Acts::Secure
if ENV['HOST']
sites = [Site.find_by_host(ENV['HOST'])]
else
sites = Site.all
end

sites.each do |site|
Thread.current[:visitor] = site.any_admin
if ENV['WORKER'] == 'false' || RAILS_ENV == 'test'
# We avoid SiteWorker.
site.rebuild_static_index
else
# We try to use the site worker.
Zena::SiteWorker.perform(site, :rebuild_static_index, nil)
end
end
end
end

0 comments on commit e8ae4b1

Please sign in to comment.