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
utopia-2.8.0 setup/site/tasks/static.rake
utopia-2.7.0 setup/site/tasks/static.rake
utopia-2.6.0 setup/site/tasks/static.rake
async-websocket-0.8.0 examples/utopia/tasks/static.rake
async-websocket-0.7.0 examples/utopia/tasks/static.rake
utopia-2.5.5 setup/site/tasks/static.rake
utopia-2.5.4 setup/site/tasks/static.rake
utopia-2.5.3 setup/site/tasks/static.rake
utopia-2.5.1 setup/site/tasks/static.rake
async-websocket-0.6.1 examples/utopia/tasks/static.rake
async-websocket-0.6.0 examples/utopia/tasks/static.rake
utopia-2.5.0 setup/site/tasks/static.rake
async-websocket-0.5.0 examples/utopia/tasks/static.rake
utopia-2.4.1 setup/site/tasks/static.rake
utopia-2.4.0 setup/site/tasks/static.rake
utopia-2.3.0 setup/site/tasks/static.rake