class Slideshift::Tool::Server::Server
Public Class Methods
new(presentation)
click to toggle source
# File lib/slideshift/tool/server/server.rb, line 9 def initialize(presentation) @presentation = presentation end
Public Instance Methods
start()
click to toggle source
# File lib/slideshift/tool/server/server.rb, line 13 def start @server = WEBrick::HTTPServer.new(:Port => Slideshift::Tool.config['server']['port']) @server.mount_proc('/') do |req, res| file = nil local_file = File.join(Dir.getwd, req.path) file = local_file if File.exists?(local_file) && File.file?(local_file) static_file = File.join(Slideshift::Static.path, '..', req.path) puts static_file file = static_file if File.exists?(static_file) && File.file?(static_file) if file res.body = File.read(file) else @presentation.load res.body = @presentation.render end end trap('INT') { @server.shutdown } @server.start end