Sha256: 3ddcde8ee9b0a6ba428237b16058d24c256a1ca1193327659ca84589d80adce9

Contents?: true

Size: 1.55 KB

Versions: 9

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.

# Create an empty project in the current directory.
def create
	template_path = File.expand_path("../../template/*", __dir__)
	
	Dir.glob(template_path) do |path|
		FileUtils::Verbose.cp_r path, Dir.pwd
	end
end

# Serve the project using a web server.
# Binds to `https://localhost:9292` by default.
#
# @parameter port [Integer] The port to bind to.
# @parameter bind [String] The URL to bind to, e.g. `http://localhost:80`.
def serve(port: nil, bind: nil)
	config_path = File.expand_path("../../template/config.ru", __dir__)
	preload_path = File.expand_path("../../template/preload.rb", __dir__)
	
	options = []
	
	if bind
		options << "--bind" << bind
	end
	
	if port
		options << "--port" << port
	end
	
	system("falcon", "serve", "--config", config_path, "--preload", preload_path, *options)
end

# Generate a static copy of the site.
# @parameter output_path [String] The output path for the static site.
# @parameter force [Boolean] Remove the output directory before generating the static content.
def static(output_path: "docs", force: true)
	require 'rackula/command'
	
	config_path = File.expand_path("../../template/config.ru", __dir__)
	public_path = File.expand_path("../../public", __dir__)
	
	arguments = []
	
	if force
		arguments << "--force"
	end
	
	Rackula::Command::Top["generate", *arguments,
		"--config", config_path,
		"--public", public_path,
		"--output-path", output_path
	].call
	
	FileUtils.touch File.expand_path(".nojekyll", output_path)
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
utopia-project-0.26.1 bake/utopia/project.rb
utopia-project-0.26.0 bake/utopia/project.rb
utopia-project-0.25.0 bake/utopia/project.rb
utopia-project-0.24.1 bake/utopia/project.rb
utopia-project-0.24.0 bake/utopia/project.rb
utopia-project-0.23.0 bake/utopia/project.rb
utopia-project-0.22.0 bake/utopia/project.rb
utopia-project-0.21.0 bake/utopia/project.rb
utopia-project-0.20.3 bake/utopia/project.rb