Class: JMV::Servlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/jmv.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(_request, response) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jmv.rb', line 14

def do_GET(_request, response)
   = @server.config[:ResourcePath]
   = read 

  context = {
    'app'  => {
      'name'    => 'Jekyll Metadata file Viewer',
      'version' => JMV::VERSION,
    },
    'data' => {
      'path' => ,
      'data' => ,
      'json' => JSON.pretty_generate(),
    }
  }

  # Repeat on every browser window refresh
  template_contents = File.binread(TEMPLATE_PATH)
  rendered_contents = Liquid::Template.parse(template_contents).render(context)

  response.status = 200
  response['Content-Type'] = 'text/html'
  response.body = rendered_contents
end