Class: Syntropy::Markdown::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/syntropy/markdown.rb

Overview

Implements a Markdown file controller.

Instance Method Summary collapse

Constructor Details

#initialize(env, atts, md) ⇒ Controller

Returns a new instance of Controller.



17
18
19
20
21
22
# File 'lib/syntropy/markdown.rb', line 17

def initialize(env, atts, md)
  @env = env
  @atts = atts
  @md = md
  @module_loader = env[:module_loader]
end

Instance Method Details

#to_procProc

Returns the controller proc.

Returns:

  • (Proc)

    controller proc



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/syntropy/markdown.rb', line 27

def to_proc
  ->(req) {
    case req.method
    when 'head'
      req.respond_html(nil)
    when 'get'
      md = process_md_embeds
      html = render(md)
      req.respond_html(html)
    else
      req.respond(nil, ':status' => HTTP::METHOD_NOT_ALLOWED)
    end
  }
end