From: Jason Woofenden Date: Thu, 27 Oct 2011 00:14:20 +0000 (-0400) Subject: load common.coffe into client X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-cgt.git;a=commitdiff_plain;h=bff997aff6d7220a8183421bdff64c9a1ef352c3 load common.coffe into client --- diff --git a/index.html b/index.html index fc6742c..7322952 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,7 @@ + diff --git a/server.coffee b/server.coffee index b3624ae..9beb901 100644 --- a/server.coffee +++ b/server.coffee @@ -16,9 +16,20 @@ css_handler = (args, out, request, url_parts) -> out.end css js_handler = (args, out, request, url_parts) -> - fs.readFile 'client.coffee', 'utf8', (err, data) -> + basename = url_parts.pathname.substr 1, (url_parts.pathname.length - 4) + if basename is 'client' + filename = 'client.coffee' + else if basename is 'common' + filename = 'common.coffee' + else + error = "Unknown js basename: #{basename}" + console.log error + out.end(error) + return + + fs.readFile filename, 'utf8', (err, data) -> if err - return out.end 'Server failed to read client.coffee' + return out.end "Server failed to read #{filename}" out.end coffee.compile data html_handler = (args, out, request, url_parts) ->