Sha256: eae4c2d3f932bb8a99191453fac363934e1cc20ff526bf9d7f490ae8a33f564e

Contents?: true

Size: 1.15 KB

Versions: 36

Compression:

Stored size: 1.15 KB

Contents

namespace :static do
	task :static_environment do
		RACK_ENV ||= :static
		DATABASE_ENV ||= :production
		SERVER_PORT ||= 9291
	end

	desc "Generate a static copy of the site."
	task :generate => [:static_environment, :environment] do
		require 'falcon/server'
		require 'async/io'
		require 'async/container'
		
		config_path = SITE_ROOT + 'config.ru'
		container_class = Async::Container::Threaded
		
		app, options = Rack::Builder.parse_file(config_path.to_s)
		
		container = container_class.new(concurrency: 2) do
			server = Falcon::Server.new(app, [
				Async::IO::Endpoint.parse("tcp://localhost:#{SERVER_PORT}", reuse_port: true)
			])
			
			server.run
		end
		
		output_path = ENV.fetch('OUTPUT_PATH') {SITE_ROOT + 'static'}
		
		# Delete any existing stuff:
		FileUtils.rm_rf(output_path)
		
		# Copy all public assets:
		Dir.glob(SITE_ROOT + 'public/*').each do |path|
			FileUtils.cp_r(path, output_path)
		end
		
		# Generate HTML pages:
		system("wget", "--mirror", "--recursive", "--continue", "--convert-links", "--adjust-extension", "--no-host-directories", "--directory-prefix", output_path.to_s, "http://localhost:#{SERVER_PORT}")
		
		container.stop
	end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
async-websocket-0.14.0 examples/utopia/tasks/static.rake
utopia-2.11.1 setup/site/tasks/static.rake
utopia-2.11.0 setup/site/tasks/static.rake
utopia-2.10.0 setup/site/tasks/static.rake
utopia-2.9.5 setup/site/tasks/static.rake
async-websocket-0.13.1 examples/utopia/tasks/static.rake
utopia-2.9.3 setup/site/tasks/static.rake
async-websocket-0.13.0 examples/utopia/tasks/static.rake
async-websocket-0.12.2 examples/utopia/tasks/static.rake
utopia-2.9.2 setup/site/tasks/static.rake
utopia-2.9.1 setup/site/tasks/static.rake
utopia-2.9.0 setup/site/tasks/static.rake
async-websocket-0.12.1 examples/utopia/tasks/static.rake
async-websocket-0.12.0 examples/utopia/tasks/static.rake
async-websocket-0.11.1 examples/utopia/tasks/static.rake
async-websocket-0.11.0 examples/utopia/tasks/static.rake
async-websocket-0.10.0 examples/utopia/tasks/static.rake
async-websocket-0.9.0 examples/utopia/tasks/static.rake
utopia-2.8.2 setup/site/tasks/static.rake
utopia-2.8.1 setup/site/tasks/static.rake