From 0a7c88a70e569931d43859c72d983da267523f62 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 19 Nov 2009 07:24:22 +0800 Subject: [PATCH] Fixed to work with latest node version --- debug.js | 2 +- example.js | 2 +- fu.js | 17 +++++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/debug.js b/debug.js index 1166fce..4af0786 100644 --- a/debug.js +++ b/debug.js @@ -1,4 +1,4 @@ -var fu = require("fu.js"); +var fu = require("./fu"); var debug = exports; diff --git a/example.js b/example.js index 036446c..a44951d 100644 --- a/example.js +++ b/example.js @@ -1,3 +1,3 @@ -var debug = require("debug.js"); +var debug = require("./debug"); debug.listen(8080); diff --git a/fu.js b/fu.js index 6dfc4e9..cae5c2b 100644 --- a/fu.js +++ b/fu.js @@ -1,3 +1,8 @@ +var http = require('http'), + sys = require('sys'), + posix = require('posix') +; + DEBUG = true; var fu = exports; @@ -18,7 +23,7 @@ fu.get = function (path, handler) { getMap[path] = handler; }; -var server = node.http.createServer(function (req, res) { +var server = http.createServer(function (req, res) { if (req.method === "GET" || req.method === "HEAD") { var handler = getMap[req.uri.path] || notFound; @@ -45,7 +50,7 @@ var server = node.http.createServer(function (req, res) { fu.listen = function (port, host) { server.listen(port, host); - puts("Server at http://" + (host || "127.0.0.1") + ":" + port.toString() + "/"); + sys.puts("Server at http://" + (host || "127.0.0.1") + ":" + port.toString() + "/"); }; fu.close = function () { server.close(); }; @@ -66,8 +71,8 @@ fu.staticHandler = function (filename) { return; } - puts("loading " + filename + "..."); - var promise = node.fs.cat(filename, encoding); + sys.puts("loading " + filename + "..."); + var promise = posix.cat(filename, encoding); promise.addCallback(function (data) { body = data; @@ -77,12 +82,12 @@ fu.staticHandler = function (filename) { if (!DEBUG) headers.push(["Cache-Control", "public"]); - puts("static file " + filename + " loaded"); + sys.puts("static file " + filename + " loaded"); callback(); }); promise.addErrback(function () { - puts("Error loading " + filename); + sys.puts("Error loading " + filename); }); }