bake/utopia/static.rb
# Generate a static copy of the site.
# @param output_path [String] the path where the files for the static site will be created.
Generate a static copy of the site.
Generate a static copy of the site .
def generate(output_path: 'static')
	require 'falcon/server'
	require 'async/io'
	require 'async/http/endpoint'
	require 'async/container'
	config_path = File.join(Dir.pwd, 'config.ru')
	container_class = Async::Container::Threaded
	server_port = 9090
	app, options = Rack::Builder.parse_file(config_path)
	container = container_class.run(count: 2) do
		Async do
			server = Falcon::Server.new(
				Falcon::Server.middleware(app),
				Async::HTTP::Endpoint.parse("http://localhost:#{server_port}")
			)
			server.run
		end
	end
	output_path = File.expand_path(output_path, Dir.pwd)
	FileUtils.rm_rf(output_path)
	FileUtils::Verbose.mkpath(output_path)
	Dir.glob(File.join(Dir.pwd, 'public/*')) do |path|
		FileUtils::Verbose.cp_r(path, output_path)
	end
	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
def generate ( output_path : 'static' ) require 'falcon/server' require 'async/io' require 'async/http/endpoint' require 'async/container' config_path = File . join ( Dir . pwd , 'config.ru' ) container_class = Async :: Container :: Threaded server_port = 9090 app , options = Rack :: Builder . parse_file ( config_path ) container = container_class . run ( count : 2 ) do Async do server = Falcon :: Server . new ( Falcon :: Server . middleware ( app ) , Async :: HTTP :: Endpoint . parse ( "http://localhost:#{server_port}" ) ) server . run end end output_path = File . expand_path ( output_path , Dir . pwd ) FileUtils . rm_rf ( output_path ) FileUtils :: Verbose . mkpath ( output_path ) Dir . glob ( File . join ( Dir . pwd , 'public/*' ) ) do | path | FileUtils :: Verbose . cp_r ( path , output_path ) end 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
Generate a static copy of the site.
Generate a static copy of the site .
# Delete any existing stuff: # Copy all public assets: # Generate HTML pages:
output_path
the path where the files for the static site will be created.
the path where the files for the static site will be created .