Module: Presently::Environment::Application

Includes:
Lively::Environment::Application
Defined in:
lib/presently/environment/application.rb

Overview

The environment configuration for a Presently application server.

Extends the Lively environment with Presently-specific middleware and configuration. Override #slides_root and #templates_root to customize paths.

Instance Method Summary collapse

Instance Method Details

#applicationObject

The application class to use.



33
34
35
# File 'lib/presently/environment/application.rb', line 33

def application
	Presently::Application
end

#middlewareObject

Build the middleware stack with Presently’s public assets.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/presently/environment/application.rb', line 39

def middleware
	application = self.application
	slides_root = self.slides_root
	templates_root = self.templates_root
	root = self.root
	
	::Protocol::HTTP::Middleware.build do |builder|
		# Serve assets from the user's public directory:
		builder.use Lively::Assets, root: File.expand_path("public", root)
		
		# Serve Presently's bundled assets (syntax-js, CSS, etc.):
		builder.use Lively::Assets, root: File.expand_path("../../../public", __dir__)
		
		# Serve Lively's built-in assets (Live.js, morphdom, etc.):
		builder.use Lively::Assets, root: File.expand_path("public", Gem.loaded_specs["lively"].full_gem_path)
		
		builder.use application,
			slides_root: slides_root,
			templates_root: templates_root
	end
end

#slides_rootObject

The root directory containing slide Markdown files.



20
21
22
# File 'lib/presently/environment/application.rb', line 20

def slides_root
	File.expand_path("slides", self.root)
end

#templates_rootObject

The root directory containing slide templates. Defaults to the gem’s bundled templates.



27
28
29
# File 'lib/presently/environment/application.rb', line 27

def templates_root
	File.expand_path("../../../templates", __dir__)
end